我在SunOS 5.10上使用-g -O0
编译我的库(特别是protbuf-2.3.0)。GDB回溯不显示函数名称
在make日志的样本行是这样的:
/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
然后,我附上我的gdb使用以下步骤:
- 运行我的应用程序(在这种情况下,我的Web服务器它启动一个java web应用程序,它在启动过程中通过jni使用库)。
- 我通过
gdb -p XXX
(其中XXX是我从ps
获得的pid)将我的gdb附加到该进程。 - 然后我从gdb使用
file libprotobuf.so
从gdb提示装入我的库。
但我从bt
看不到我的函数名。我GDB回溯命令显示了这样的事情:
(gdb) bt
#0 0xf8f98914 in ??()
#1 0xf8f98830 in ??()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
我也试图做#1 &#2只,#1 &#3只,和#1 & gdb libprotobuf.so -p XXX
。
除了这些之外,我还尝试在调试模式下运行我的jvm,并在System.loadLibrary(..)
命令中添加了一个断点,然后在执行该命令后,我再次执行gdb附件过程....但仍然没有任何结果。
但是,我可以通过list
给出功能名称给出断点并列出函数的内容。但是再次,我可以放置断点,但是它们不会停留在这些函数名称上(我知道它会转到该函数,因为它在每个jvm崩溃后都位于jvm hs_err_pid报告中)。
任何想法来它没有显示我的函数名?
很可能你没有正确调用GDB。请显示可执行文件如何链接,以及如何将GDB附加到它。 –
谢谢,我已经添加了更多关于我尝试过的gdb附件进程的信息。 –