11-29-2012 02:50 PM - last edited on 11-29-2012 10:30 PM by Cathy_xu
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
Solved! Go to Solution.
11-29-2012 08:06 PM
>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.
11-30-2012 09:51 AM
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.
11-30-2012 12:00 PM
> 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.