I compiled my library (specifically protbuf-2.3.0) using -g -O0
on a SunOS 5.10.
A sample line in the make log is this:
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -pthreads -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -g -O0 -MT text_format.lo -MD -MP -MF .deps/text_format.Tpo -c -o text_format.lo `test -f 'google/protobuf/text_format.cc' || echo './'`google/protobuf/text_format.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -D_REENTRANT -pthreads -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -g -O0 -MT text_format.lo -MD -MP -MF .deps/text_format.Tpo -c google/protobuf/text_format.cc -fPIC -DPIC -o .libs/text_format.o
And then, I attached my gdb using the following steps:
gdb -p XXX
(where XXX is the pid I got from ps
).file libprotobuf.so
from the gdb prompt.But I can't see my function names from bt
. My GDB backtrace command shows something like this:
(gdb) bt
#0 0xf8f98914 in ?? ()
#1 0xf8f98830 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
I also tried doing #1 & #2 only, #1 & #3 only, and #1 & gdb libprotobuf.so -p XXX
.
Aside from those, I also tried running my jvm on debug mode and added a breakpoint on the System.loadLibrary(..)
command, and after stepping over that command, I then did the gdb attachment process again....but still nothing.
However, I am able to put breakpoints given function names and list the contents of a function via list
. But then again, I can place breakpoints but they don't stop as well on those function names (I know it went to that function because it's in the jvm hs_err_pid report after every jvm crash).
Any ideas come it's not showing me my function names?
The problem is most likely in that GDB does not know how to figure out full executable path for the given PID. If it did know full path, you wouldn't need to do step #3 -- GDB would have added it automatically.
You can verify whether GDB deduced executable name correctly with (gdb) info file
command.
If my guess is correct, help GDB by invoking it like this:
gdb /path/to/java <PID>
That should immediately solve all of your problems.