bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gdb demangling problem, with patch


From: Richard Sharman
Subject: gdb demangling problem, with patch
Date: Tue, 20 Nov 2001 00:00:03 -0500

gdb cannot demangle __vc__t6Xclass3Zii10i20i 
                                      ** **
but it can demagnle __vc__t6Xclass3Zii2i4i.
                                      * *

The problem seems to be that it is expected a single digit.

The following example shows that stepping into x[i] does not show the
demangled name, but stepping into y[i] does:

cat -n demo.cc
     1  #include <stdio.h>
     2  #include <stdlib.h>
     3  #include <time.h>
     4  #include <string.h>
     5  
     6  template<class T, int L, int H >
     7  class Xclass {
     8  
     9  private:
    10        char storage[(H - L + 1) * sizeof(T)];
    11  
    12  public:
    13        Xclass () { memset (this, 0, sizeof(storage));}
    14        T& operator[](int index) {
    15              return (T&)storage[sizeof(T)*(index-L)];
    16        }
    17  
    18  };
    19  
    20  
    21  int main(int argc, char **argv) {
    22        Xclass <int, 10, 20>x;
    23        Xclass <int, 2, 4>y;
    24  
    25        x[10] = 10;
    26        y[3] = 10;
    27  }
address@hidden 

~/src/gdb/gdb.orig demo
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) b 25
Breakpoint 1 at 0x804851a: file demo.cc, line 25.
(gdb) r
Starting program: /home/rs/c++/demo 

Breakpoint 1, main (argc=1, argv=0xbffffd3c) at demo.cc:25
25            x[10] = 10;
(gdb) s

VVV ******* The following line does not show the demangled name *****
__vc__t6Xclass3Zii10i20i (this=0xbffffca8, index=10) at demo.cc:15
^^^^^^^^^ *****************************************************

15                  return (T&)storage[sizeof(T)*(index-L)];
(gdb) fin

Run till exit from #0  __vc__t6Xclass3Zii10i20i (this=0xbffffca8,
index=10)
    at demo.cc:15
0x8048528 in main (argc=1, argv=0xbffffd3c) at demo.cc:25
25            x[10] = 10;
Value returned is $1 = (int &) @0xbffffca8: 0
(gdb) n
26            y[3] = 10;
(gdb) s
Xclass<int, 2, 4>::operator[] (this=0xbffffc9c, index=3) at demo.cc:15
15                  return (T&)storage[sizeof(T)*(index-L)];
(gdb) The program is running.  Exit anyway? (y or n) y
address@hidden ~/src/gdb/gdb demo
GNU gdb 5.0 patched
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) b 25
Breakpoint 1 at 0x804851a: file demo.cc, line 25.
(gdb) r
Starting program: /home/rs/c++/demo 

Breakpoint 1, main (argc=1, argv=0xbffffd3c) at demo.cc:25
25            x[10] = 10;
(gdb) s

VVVVVV *************** Here it is correct *******************
Xclass<int, 10, 20>::operator[] (this=0xbffffca8, index=10) at demo.cc:15
^^^^^^^ *************************************************************

15                  return (T&)storage[sizeof(T)*(index-L)];
(gdb) fin
Run till exit from #0  Xclass<int, 10, 20>::operator[] (this=0xbffffca8, 
    index=10) at demo.cc:15
0x8048528 in main (argc=1, argv=0xbffffd3c) at demo.cc:25
25            x[10] = 10;
Value returned is $1 = (int &) @0xbffffca8: 0
(gdb) n
26            y[3] = 10;
(gdb) s
Xclass<int, 2, 4>::operator[] (this=0xbffffc9c, index=3) at demo.cc:15
15                  return (T&)storage[sizeof(T)*(index-L)];
(gdb) The program is running.  Exit anyway? (y or n) y


Here is a patch that fixes it.  However,  I just found that while
c++filt 2.95.3 is ok c++filt 2.95.2 has the same problem,  so probably
whatever changed there might be the real way of fixing it.
Anyway,  this worked for me:

-------------------- Patch --------------------
*** libiberty/cplus-dem.c.orig  Tue Feb 22 11:14:35 2000
--- libiberty/cplus-dem.c       Thu Nov 15 14:21:32 2001
***************
*** 1443,1449 ****
        }
  
        /* Read the rest of the number.  */
!       value = consume_count_with_underscores (mangled);
        if (value != -1)
        {
          char buf[INTBUF_SIZE];
--- 1443,1456 ----
        }
  
        /* Read the rest of the number.  */
!       if (**mangled == '_')
!       {
!         value = consume_count_with_underscores (mangled);
!       }
!       else
!       {
!         value = consume_count (mangled);
!       }
        if (value != -1)
        {
          char buf[INTBUF_SIZE];
-----------------------------------------------

Richard



reply via email to

[Prev in Thread] Current Thread [Next in Thread]