[comp.lang.c++] Problems with gdb 3.5?

lotridge@charlie.ccd.bnl.gov (Charlie Lotridge) (05/20/91)

This is ridiculous.  I've posted to gnu.g++ about this problem and have
gotten minimal response (although my appreciation goes to those that did).

This is the deal.  I'm on a sparc running sunos 4.1.1.  I've obtained and
built gcc-1.39, g++-1.39.1, and gdb-3.5 (plus several other ancillary things
that make these things work).  This all went smoothly.

According to the g++ README, gdb 3.5 should operate just fine on this version
of g++.  Yet I'm finding it almost completely unusable for two reasons.  First,
the names are all screwed up: instead of String::String I get something like
__6StringPCc.  Second, I can't seem to access any of the data members of
a class from within one of its member functions.  To exemplify, let me steal
from my original post, where I set up a simple String class:

**** String.h ****
class String {
private:
  char *string;
  int size;
public:
  String(const char *);
  ...
};

**** String.cc ****
String::String(const char *str){
=>size = strlen(str) + 1;
  string = new char[size];
  strcpy(string, str);
}

Now, when I step into the constructor to the indicated point (the => symbol),
I get this:

  Reading in symbols for String.cc...done.
  __6StringPCc ($t=(String *) 0xf7fffe50, str=(char *) 0x22b5 "AAAAA") (String.cc line 14)

 (gdb) info args
 $t = (String *) 0xf7fffe50
 str = (char *) 0x22b5 "AAAAA"

 (gdb) info locals
 str = (char *) 0x22b5 "AAAAA"

 (gdb) p $t
 $1 = void

 (gdb) p $this
 $2 = void

 (gdb) p this
 No symbol "this" in current context.

 (gdb) p size
 No symbol "size" in current context.

 (gdb) p string
 No symbol "string" in current context.

I can't seem to access the 'this' pointer, member 'size', or member 'string'.

I *must* have done, or be doing something wrong.  I mean, I could live with
the mangled names, but not being able to see data members makes the debugger
USELESS on c++ code.  I compile everything with the '-g' option as the
literature suggests I should, so it's not as if the symbol tables are lacking.

Some of the folks who responded to my original post mentioned a gdb version
3.6 (sometimes 3.6- ) as being the solution, but I haven't been able to find
such an animal anywhere.  And anyway, to restate, the g++ README *does* say
that gdb 3.5 should work.

I should make it clear - I'm real new to all this stuff, to the point that
I only became aware of this newsgroup a few weeks ago.  So it wouldn't
surprise me at all to find I've missed something really obvious.  Somebody
please help.

C
-- 
					Charlie Lotridge
					Brookhaven National Laboratory
					Upton, NY 11793