Author Topic: gdb and shared library  (Read 16638 times)

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
gdb and shared library
« on: June 30, 2008, 11:42:10 AM »
I'm trying to do remote debug on a linux program which loads dynamic library.

1- I start gdbserver on target
2- under SE -> Attach to remote process using gdb
3- start debug (stop on the first break point in main function)
4- Verify that shared library are loaded with the following command :
    > debug-send-command info shared
    I obtain the result of the figure "info shared.JPG"
5- Get the address of the dynamic library with the command :
    > debug-send-command info file ./libSEPApi.so
    (see figure "info file.JPG")
6- Add this library new symbols :
    > debug-send-command add-symbol-file ./libSEPApi 0x80494b0
    (see figure "add-symbol-file.JPG")
7- try to step into a function of the library, I get the error message shown by figure "Error SIGILL.JPG"

First, I don't understand why the command "info shared" doesn't return any address of loaded shared libraries? Column "Syms read" is always "No".

I have set the variable "def_debug_logging" to 1.  So this some extracs of vs.log files :

-------------------------------------------------------------------------
...
GDB command_reply: reply time=15940235 elapsed=360
GDB started 'vs-gdb-proxy' with arguments: C:\PROGRA~1\SLICKE~1\win\vs-gdb-proxy.exe -nodelay  -server 172.30.32.8:8000 -listen localhost:8002
======================================
GDB command_reply: time=15940235 command=-target-select remote localhost:8002
GDB command_reply: send time=15940235 elapsed=0
GDB event: time=15940313 &"warning: Unable to find dynamic linker breakpoint function.\nGDB will be unable to debug shared library initializers\nand track explicitly loaded dynamic code."

...

_UpdateDebugger: status=0 event= flags=0 thread=0 time=7712940042817970 mtime=13:53:37 ELAPSED TIME=0
GDB handle_event: time=15944734 event=&"Error while mapping shared library sections:\n"

_UpdateDebugger: status=0 event= flags=0 thread=0 time=7712940042817970 mtime=13:53:37 ELAPSED TIME=0
GDB handle_event: time=15944734 event=&"./libSEPApi.so: No such file or directory.\n"
...

-------------------------------------------------------------------------------------
I've been working on this problem for few days, I don't have any idea...

Thanks
« Last Edit: June 30, 2008, 12:41:28 PM by gregos_b »

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: gdb and shared library
« Reply #1 on: July 02, 2008, 04:23:40 PM »
It is a remote debug problem. When I run the program on the target (Linux 32 bits) everything is OK (see figure below).
Does that mean remote debug with cross gdb is not able to load dynamic libraries symbols ?

« Last Edit: July 02, 2008, 04:30:02 PM by gregos_b »

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Re: gdb and shared library
« Reply #2 on: July 08, 2008, 10:51:17 AM »
I seem to recall a long time back I managed to debug a remote app that used shared libs, but I don't think I stepped into the libs. Do you have insight installed? If so, can you do what you need to do with insight? That might show if it's a gdb or SE issue.

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: gdb and shared library
« Reply #3 on: July 08, 2008, 01:15:02 PM »
I don't have insight installed. What is insight ?
I think it is a problem with my cross gdb, windows gdb is not exactly configured as the Linux once.

On linux :

GNU gdb Red Hat Linux (6.3.0.0-1.63rh)
--target= "i386-redhat-linux-gnu"

On Windows (gdb.exe)
GNU gdb 6.4
--target=i686-linux-gnu

However, I succeed in remote debug with this configuration...

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Re: gdb and shared library
« Reply #4 on: July 08, 2008, 05:39:25 PM »
Insight is a GUI front end to GDB, so it kind of does the same thing as SE.

http://sourceware.org/insight/

Great if one isn't a console jockey :)

gregos_b

  • Community Member
  • Posts: 53
  • Hero Points: 0
Re: gdb and shared library
« Reply #5 on: July 09, 2008, 06:52:01 AM »
I have 'ddd' installed on the target, it does the same thing as Insight. When I run my program and directly debug on the target, which is a Linux station (using ddd), there is no problem. Dynamic libraries are well loaded.
The problem is when I try to do remote debugging with SlickEdit (on a Windows PC) and my cross gdb.

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Re: gdb and shared library
« Reply #6 on: July 09, 2008, 10:22:14 AM »
Running ddd on the target is not the same thing. If you ran ddd on the same machine as SE is installed then you'd be using your cross-gdb and that would be the same as the SE setup (but without SE). The problem in undoubtedly to do with remote debugging, and my uneducated guess would be that it's a (cross)gdb problem, but since you're posting here there's a small possibility that SE isn't helping at all. Running a gui debugger (ddd or insight) on your dev machine would replicate both gdb and the method of driving it to ensure that it isn't a SE problem (or show that it is, of course).

Is it only a stepping problem? That is, if you step to a lib call then step over it (instead of into it) does it all still work? If so, it might be something like the running lib (on your target) is stripped whereas the original (on your dev system) is not, leading to breakpoints being put at the wrong location.