Operating System - HP-UX
1745853 Members
4447 Online
108723 Solutions
New Discussion

Debugging shared libraries with gdb

 
SOLVED
Go to solution
tlo
Occasional Visitor

Debugging shared libraries with gdb

HP-UX 11.23, ia64.

 

I am using gcc 4.7.0 and gdb 7.5, and I am having problems debugging anything inside a shared library.

 

The creation of the shared library:

  $ gcc -c -g3 -fPIC hello.c

  $ gcc -g3 -shared hello.o -o libhello.so


I then compiled and linked an executable against it:

  $ gcc -c -g3 foo.c

  $ gcc -g3 foo.o -lhello -L.

 

 

I can post the contents of hello.c and foo.c if necessary, but I doubt it will matter. The main() in foo.c calls a function in hello.c

 

When I try to set a breakpoint in gdb, I get this:

(gdb) break hello
Function "hello" not defined.
Make breakpoint pending on future shared library load? (y or [n])

 

Even if I answer yes, the breakpoint is never reached, even though the function is called on execution.  Also, if I attempt to step through the statements in foo.c, it steps over the call into the shared library.

 

I have also attempted chatr +dbg enable on both the resulting binary and the shared object itself, with the same result. What do I need to do in order to debug a shared library?

 

 

P.S.This thread has been moved from HP-UX>System Administration to HP-UX > languages- HP Forums Moderator

 

 

4 REPLIES 4
Dennis Handly
Acclaimed Contributor
Solution

Re: Debugging shared libraries with gdb

>I am using gcc 4.7.0 and gdb 7.5,

 

What happens when you used HP's gdb instead?

 

>What do I need to do in order to debug a shared library?

 

Use HP's gdb instead, that works.

tlo
Occasional Visitor

Re: Debugging shared libraries with gdb

The gdb 6.3 from the HP WDB package does work. Functions from shared libraries are not immediately recognizable (.i.e., I still get "Breakpoint deferred until a shared library containing "hello" is loaded."), but that's only a minor annoyance as program execution actually does break when it hits that function.

 

Thanks for the assistance.

 

Dennis Handly
Acclaimed Contributor

Re: Debugging shared libraries with gdb

>Thanks for the assistance.

 

If you are happy with your answers, please click on the Kudos star.

 

Was there a particular feature you wanted in gdb 7.5?

tlo
Occasional Visitor

Re: Debugging shared libraries with gdb

Was there a particular feature you wanted in gdb 7.5?

 

Nothing in particular, no. Python scripting support and reversible debugging would be nice, but they're not essential.

 

I just downloaded and installed the latest version I could find on the Porting and Archive Centre, rather than going to the official HP packages. It usually works for everything else, and since the debugger seemed to work and run, I expected that it would work for more or less all features.  I knew that HP had some people working on GDB and other open source projects a long time ago (I was a member of the initial HP Caliper team on the same floor as you, Dennis), but I didn't know that it continued to this day.