I have always had difficulty using gdb with C++ code, but recently it has
gotten literally unusable I have resorted to debugging with print statements!
I don't know what's changed.

This bug report concerns using gdb's print to evalulate a class member
function. I have a simple test case which demonstrates this problem. The
following is a transcript. I trust I have included all necessary details?

-- begin transcript --

redsavina% uname -a
SunOS redsavina 5.7 Generic_106541-09 sun4u sparc SUNW,Ultra-Enterprise
redsavina% g++ --version
2.95.2
redsavina% gdb --version
GNU gdb 4.18
Copyright 1998 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 "sparc-sun-solaris2.7".
redsavina% cat test3.cc
struct C {

  int f (int);

};

int C::f (int x) {return x + 9;}

int main ()
{
  C c;
  return c.f(3);
}
redsavina% g++ -g -o test3 test3.cc
redsavina% gdb -n ./test3
GNU gdb 4.18
Copyright 1998 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 "sparc-sun-solaris2.7"...
(gdb) break 12
Breakpoint 1 at 0x1093c: file test3.cc, line 12.
(gdb) run
Starting program: 
/data/redsavina0/cogen/l/env/src/util/derive_message_stream_files/./test3 

Breakpoint 1, main () at test3.cc:12
12        return c.f(3);
(gdb) print c.f(1)
Cannot resolve method C::f to any overloaded instance
(gdb) 

-- begin transcript --

So you see, I cannot evaluate C::f(1) using gdb's print command. Even though
there is only one C:f; it is not even overloaded.

This is the simplest example I could come up with it. But it doesn't appear to
be anything specifically related to this example. I get the "Cannot resolve"
error no matter what.

What am I doing wrong? Wrong gdb/g++ combination?

Or is gdb really not being maintained for C++ anymore? (I doubt that,
obviously.)

-- David C

Reply via email to