Article View: gnu.gdb.bug
Article #373(none)
From: Peggy Fieland
Date: Thu, 13 Aug 1992 20:15
Date: Thu, 13 Aug 1992 20:15
148 lines
5908 bytes
5908 bytes
On a stratus i860, using gdb-4.6 and cfront, gdb prints the virtual
table field, which it doesn't do when the program is compiled with
g++. This is because gdb is not accounting for the difference
between the naming conventions of g++ and cfront for the virtual
table.
Here is a sample debugging session. It includes the type information
for the variable animal. I didn't include the whole program, as
it is about 200 lines.
maestro-tests% /usr/c++/bin/CC -g -o class class.c
CC class.c:
cc -L/usr/c++/lib -o class -g class.c -Xt -lC
maestro-tests% /net/citron/home/citron/pfieland/gdb-4.6/gdb-4.6/gdb/gdbx class
GDB is free software and you are welcome to 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.
GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
(gdb) list 1 30
Junk at end of line specification.
(gdb) list 1
1
2 class a {
3 private:
4 int data;
5 public:
(gdb)
6 a() { data =0; }
7 a(a & val) { data = val.data; }
8 a(int val) { data = val; }
9 };
10
11 void foo( a temp)
12 {
13 a b(temp);
14 a c=temp;
15 }
(gdb)
16
17 main()
18 {
19 a one(3);
20
21 foo(one);
22 foo(2);
23 }
24
(gdb) ptype a
type = class a {
private:
int data;
public:
a ();
a (struct a &);
a (int);
}
(gdb) break a::operator()
warning: the class a does not have any method named __cl
Hint: try 'a::operator()<TAB> or 'a::operator()<ESC-?>
(Note leading single quote.)
(gdb) q
maestro-tests% /net/citron/home/citron/pfieland/gdb-4.6/gdb-4.6/gdb/gdbx clas
maestro-tests%
maestro-tests%
maestro-tests% /net/citron/home/citron/pfieland/gdb-4.6/gdb-4.6/gdb/gdbx class
maestro-tests%
maestro-tests% /net/citron/home/citron/pfieland/gdb-4.6/gdb-4.6/gdb/gdbx zoo
GDB is free software and you are welcome to 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.
GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
(gdb) b main
Breakpoint 1 at 0x1ebc: file zoo.c, line 193.
(gdb) r
Starting program: /home2/maestro/pfieland/tests/zoo
Breakpoint 1, main () at zoo.c:193
193 Lion a1;
Current Language: auto; currently c++
Type checking: auto; currently off
Range checking: auto; currently off
(gdb) ptype a1
type = class Lion : public ZooAnimal {
private:
char mytype[255];
public:
Lion (char *);
Lion (struct Lion &);
virtual char draw ();
virtual char feed (fruit);
virtual char feed (meat);
}
(gdb) print a1
$1 = {<ZooAnimal> = {zooanimalhood = 0,
mytype = {'\000' <repeats 102 times>, "\020h\000\000\000\000\000\000\020\000\201\004!\211\201\004@`\177|`\201
\001\006H\177|`", '\000' <repeats 12 times>, "\201\004\200\f\000\000\000\a\201\004@`\000\000\000\005\000\000\000
\201\000= \201\004A|\000\000\020T\177~\030\201\000\000\000\000\000\000\005\201\000V@\000\000\022\034\201\004!\204
\177| \201\001\0318\000\000\000 \201\000= \201\004A|\000\000\020T\177~\030\201\000\000\000\000\000\000\000\000\0
00\022\034\201\004D\034\201\004\200\f\201\004@`\201\000="}, __vptr = 0x81042d40},
mytype = {"\201\000\000\224\000\000\000\000\000\000\020\000\000\000\0240\201\004@`\177}\000\201\001\006H\177}\
000\000\000\000\001\000\000\0204\000\000\000\000\201\004\200\f\000\000\001l\201\004@`\000\000\000\000\000\000\000\
000\000\022%\b\000\000\000\000\000\000\023<\000\000\000\030\000\005p\210\000\005z\b\000\000\024\210\000\000\024'\2
01\004\200\f\177}@\201\000><\000\000\000\000\201\004D\f\000\000\000\000\201\000\000\000\201\004D\034\201\004@`\00
0\000\000\000\000\000\027!\000\000\000\001\000\005p\210\000\005z\b\000\005\211H\177}@\201\000k0\177}(\201\000@(\
201\004,p\000\000\000\000\000\b\233Z\000\000\b,\200\020\021\200\000\000\000\000?a\016\207"...}}
(gdb)
Here is a fix:
*** /home/tools/gnu/gdb-4.6/gdb/values.c Tue Jul 14 03:34:32 1992
--- gdb-4.6/gdb/values.c Thu Aug 13 13:35:38 1992
***************
*** 1625,1630 ****
--- 1678,1686 ----
struct type **args = TYPE_ARG_TYPES (type);
fprintf_filtered (stream, "(");
+
+ /* Peggy Fieland -- fixed problem of possible null args */
+ if (args != NULL)
if (args[1] == 0)
fprintf_filtered (stream, "...");
else for (i = 1; args[i] != 0 && args[i]->code != TYPE_CODE_VOID; i++)
***************
*** 1772,1779 ****
{
QUIT;
/* Don't print out virtual function table. */
! if ((TYPE_FIELD_NAME (type, i))[5] == CPLUS_MARKER &&
! !strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5))
continue;
/* If this is a C++ class we can print the various C++ section
--- 1828,1838 ----
{
QUIT;
/* Don't print out virtual function table. */
! /* code altered by Peggy Fieland (Margaret_Fieland@vos.stratus.com
! to account for cfront naming conventions */
! if ( ((TYPE_FIELD_NAME (type, i))[5] == CPLUS_MARKER &&
! !strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5)) ||
! !strncmp (TYPE_FIELD_NAME (type, i),"__vptr",6))
continue;
/* If this is a C++ class we can print the various C++ section
Technical Details
Message-ID:
<9208132015.AA15960@citron.sw.stratus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!citron.sw.stratus.com!pfielandShow Full Headers
Complete Article Headers
Newsgroups: gnu.gdb.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!citron.sw.stratus.com!pfieland From: pfieland@citron.sw.stratus.com (Peggy Fieland) Subject: (none) Message-ID: <9208132015.AA15960@citron.sw.stratus.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 13 Aug 1992 20:15:24 GMT Approved: bug-gdb@prep.ai.mit.edu Lines: 149