Hi,
Debugging trivial C++ programs in GDB is knackered, complaining about "ABI
doesn't define required function XXX" when doing operations such as printing
classes and structures which inherit from others, and setting breakpoints in
virtual functions, etc.

Adding "gnu-v2-abi.c" and "gnu-v3-abi.c" to XSRCS in
src/gnu/usr.bin/binutils/gdb/Makefile
fixes the problem. 

This seems like a reasonably large problem with GDB as it stands currently.
Does someone fancy committing this? patch and before/after example follow.

Index: Makefile
===================================================================
RCS file: /pub/FreeBSD/development/FreeBSD-CVS/src/gnu/usr.bin/binutils/gdb/Makefile,v
retrieving revision 1.62
diff -u -r1.62 Makefile
--- Makefile    12 Oct 2002 21:23:53 -0000      1.62
+++ Makefile    3 Jan 2003 11:40:52 -0000
@@ -37,6 +37,7 @@
        ui-file.c ui-out.c wrapper.c cli-out.c \
        cli-cmds.c cli-cmds.h cli-decode.c cli-decode.h cli-script.c    \
        cli-script.h cli-setshow.c cli-setshow.h cli-utils.c cli-utils.h
+XSRCS+= gnu-v2-abi.c gnu-v3-abi.c
 XSRCS+=        freebsd-uthread.c kvm-fbsd.c
 SRCS=  init.c ${XSRCS} nm.h tm.h xm.h gdbversion.c xregex.h


petere@rocklobster$  cat > test.cc << .
heredoc> 
petere@rocklobster$ cat > test.cc << . 
heredoc> #include <unistd.h>
heredoc> 
heredoc> struct A {
heredoc>     const char *fieldOfA;
heredoc>     A() : fieldOfA("A's field") {}
heredoc> };
heredoc> 
heredoc> struct B : public A {
heredoc>     const char * fieldOfB;
heredoc>     B() : fieldOfB("B's field") {}
heredoc> };
heredoc> 
heredoc> main()
heredoc> {
heredoc>     B myB;
heredoc>     pause();
heredoc> }
heredoc> .
petere@rocklobster$ g++ -g test.cc
petere@rocklobster$ /usr/bin/gdb ./a.out
GNU gdb 5.2.1 (FreeBSD)
Copyright 2002 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 "i386-undermydesk-freebsd"...
(gdb) b 16
Breakpoint 1 at 0x80485b7: file test.cc, line 16.
(gdb) run
Starting program: /local/petere/a.out 

Breakpoint 1, main () at test.cc:16
16          pause();
(gdb) p myB
$1 = {ABI doesn't define required function baseclass_offset
(gdb) quit
The program is running.  Exit anyway? (y or n) y
petere@rocklobster$ /tmp/peters_fixed_gdb ./a.out
GNU gdb 5.2.1 (FreeBSD)
Copyright 2002 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 "i386-undermydesk-freebsd"...
(gdb) b 16
Breakpoint 1 at 0x80485b7: file test.cc, line 16.
(gdb) run
Starting program: /local/petere/a.out 

Breakpoint 1, main () at test.cc:16
16          pause();
(gdb) p myB
$1 = {
  <A> = {
    fieldOfA = 0x8048692 "A's field"
  }, 
  members of B: 
  fieldOfB = 0x8048688 "B's field"
}
(gdb) 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to