This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Tracing ELF shared libs with GDB (Linux)


Hi there,

sorry for bringing this subject "back to life" (I found some references
to it in the May-1998 archives), but I'm having some problems I couldn't
solve with the instructions found in those messages.

My Linux configuration is:

kernel:		2.0.34
GCC:		2.7.2.2
GDB:		4.17
ld:		2.8.1
ldconfig:	1.9.5

What happens here is: I am unable to set a breakpoint at a function
which is in a dynamic lib, although gdb "thinks" it is actually doing it
right. I will put below a session grab, just to (hopefully) make things
easier to understand:

------------------------------------------------------
GNU gdb 4.17
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 "i686-pc-linux-gnulibc1"...
(gdb) info shared
No shared libraries loaded at this time.
(gdb) dir ~/prj/iup/motif
Source directories searched: /home/j/costa/prj/iup/motif:$cdir:$cwd
(gdb) b main
Breakpoint 1 at 0x804efe6: file text.c, line 16.
(gdb) r
Starting program:
/tmp_mnt/marc/home/j/costa/prj/iup/motif/test/bin/Linux/text 

Breakpoint 1, main () at text.c:16
16        IupOpen();
(gdb) info shared
>From        To          Syms Read   Shared Object Library
0x4000a000  0x400325cc  Yes        
/home/j/costa/prj/iup/lib/Linux/libiupmot.so
0x40033000  0x4004fd44  Yes        
/home/j/costa/prj/iup/lib/Linux/libiup.so
0x40050000  0x40061914  Yes         /usr/X11R6/lib/libXmu.so.6
0x40062000  0x400a416c  Yes         /usr/X11R6/lib/libXt.so.6
0x400a5000  0x40141fd8  Yes         /usr/X11R6/lib/libX11.so.6
0x40142000  0x4014c1a0  Yes         /usr/X11R6/lib/libXext.so.6
0x4014d000  0x4020e9b8  Yes         /lib/libc.so.5
0x4020f000  0x40217220  Yes         /usr/X11R6/lib/libSM.so.6
0x40218000  0x4022c9b4  Yes         /usr/X11R6/lib/libICE.so.6
0x40000000  0x40006324  Yes         /lib/ld-linux.so.1
(gdb) b drvcb_text
Breakpoint 2 at 0x40025653: file motproc.c, line 441.
(gdb) l motproc.c:441
436           {
437              fill[0] = 0;
438              info->status = 2;
439           }
440        }
441     }
442
443
444     void drvcb_button (Widget w, XtPointer client_data, XtPointer
call_data)
445     {
------------------------------------------------------

That's the problem: GDB put the breakpoint at a completely different
line of the source code (in this particular case, at the end of a
function!), therefore making it impossible to trace into this lib. What
is really annoying is that things go out just fine under IRIX 5.3 (GDB
v4.17, gcc v2.8.1):

------------------------------------------------------
GNU gdb 4.17
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 "mips-sgi-irix5.3"...
(gdb) info shared
No shared libraries loaded at this time.
(gdb) dir ~/prj/iup/motif
Source directories searched: /home/j/costa/prj/iup/motif:$cdir:$cwd
(gdb) b main
Breakpoint 1 at 0x400dbc: file text.c, line 16.
(gdb) r
Starting program:
/tmp_mnt/nethome/j/costa/prj/iup/motif/test/bin/IRIX/text 

Breakpoint 1, main () at text.c:16
16        IupOpen();
(gdb) info shared
>From        To          Syms Read   Shared Object Library
0x5ffa0000  0x5fff2dd0  Yes        
/home/j/costa/prj/iup/lib/IRIX/libiupmot.so
0x00440000  0x0046a1d0  Yes        
/home/j/costa/prj/iup/lib/IRIX/libiup.so
0x0e220000  0x0e3fb3e0  Yes         /usr/lib/libXm.so.1
0x0f620000  0x0f640b90  Yes         /usr/lib/libXmu.so
0x0f650000  0x0f6d5a40  Yes         /usr/lib/libXt.so
0x0f710000  0x0f7f7440  Yes         /usr/lib/libX11.so.1
0x0fa90000  0x0fb566d0  Yes         /usr/lib/libc.so.1
0x0f6e0000  0x0f700550  Yes         /usr/lib/libXext.so
(gdb) b drvcb_text
Breakpoint 2 at 0x5ffc43ac: file motproc.c, line 286.
(gdb) l motproc.c:286
281     }
282     
283     void drvcb_text (Widget w, XtPointer client_data, XtPointer
call_data)
284     {
285        Itextcb cb;
286        WidgetData *d = NULL;
287        Ihandle *n;
288        XmTextVerifyPtr text = (XmTextVerifyPtr)call_data;
289        char *tmpStr, *oldText = NULL, *newText = NULL;
290      
------------------------------------------------------
However, the scenario is slightly different: the application is compiled
with gcc, but the libs are compiled with the native compiler cc. The
dynamic linker/loader are the ones supplied with IRIX 5.3.

Who is the one to blame here? The dynamic linker/loader? The compiler?
Me?!? =) Anyone else has this problem?

TIA for any help, and sorry for the long post.

--
Andre Oliveira da Costa
(costa@tecgraf.puc-rio.br)