GDB没有看到消息来源

时间:2014-03-11 08:20:47

标签: c++ gdb shared-libraries

我有以下问题。我运行了一个已创建多个线程的程序。 Gdb输出以下线程:

(gdb) info thread
  Id   Target Id         Frame 
  3    LWP 23941         0x00007f5fc327c2d4 in ?? ()
  2    LWP 22925         0x00007f5fc327e420 in ?? ()
* 1    LWP 23934         0x00007f5fc2779475 in ?? ()

第二个线程的Backtrace如下所示:

(gdb) thread 2
[Switching to thread 2 (LWP 22925)]
#0  0x00007f5fc327e420 in ?? ()
(gdb) bt
#0  0x00007f5fc327e420 in ?? ()
#1  0x00007f5fb406f300 in ?? ()
#2  0x0000000000439021 in AaSemWait (semPtr=0x7f5fb406f300) at ../bm/testing/unit/src/ccs/AaSem.cpp:97
#3  0x00000000004197d5 in bm_semaphore_base::wait (this=0x7fff75b01db8) at /home/michaelfrysztacki/bm_local_build2/BTS_SC_BM/bm/interface/framework/bm_semaphore.h:174
#4  0x0000000000500e1c in radio::thread_synchroniser::wait (this=0x7fff75b01c00) at /home/michaelfrysztacki/bm_local_build2/BTS_SC_BM/bm/radio/testing/stubs/radio_module_receiver.h:107
#5  0x00000000005034a5 in radio::mt_radio_service::send_messages (this=0x7f5fb406d140) at ../bm/radio/testing/unit/mt_radio_service.cpp:236
#6  0x0000000000503010 in radio::mt_radio_service::simulate_radio_modules (this=0x7f5fb406d140, set_timeoff_test=false) at ../bm/radio/testing/unit/mt_radio_service.cpp:189
#7  0x00000000004fde77 in radio::mt_radio_service_module_test_sending_message_and_receive_from_radio_service_Test::TestBody (this=0x7f5fb406d140) at ../bm/radio/testing/unit/mt_radio_service.cpp:347
#8  0x000000000069cab1 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ()
....

这个回溯满足我,因为我知道程序停止的位置。 我对第一次回溯感到困惑:

(gdb) thread 1
[Switching to thread 1 (LWP 23934)]
#0  0x00007f5fc2779475 in ?? ()
(gdb) bt
#0  0x00007f5fc2779475 in ?? ()
#1  0x00007f5fc277c675 in ?? ()
#2  0x0000000000000000 in ?? ()

也许这个线程运行到一个共享库,我没有调试符号和源代码,我很好。我想知道我的程序在哪里调用了共享库方法。我无法通过此回溯确定它。我可以使用debuging符号下载一些共享库但是如何知道哪个共享库进入了我的线程?或者这可能是使用pthread启动线程的入口点?为什么这种回溯如此糟糕?最后我不完全确定这是一个共享库我怎么能得到它?

(gdb) info sharedlibrary 
warning: Can't read pathname for load map: Input/output error.
From                To                  Syms Read   Shared Object Library
                                        No          /lib/x86_64-linux-gnu/librt.so.1
                                        No          /lib/x86_64-linux-gnu/libexpat.so.1
                                        No          /usr/lib/libboost_thread.so.1.49.0
                                        No          /usr/lib/libboost_system.so.1.49.0
                                        No          /usr/local/lib/libprotobuf.so.8
                                        No          /lib/x86_64-linux-gnu/libpthread.so.0
                                        No          /usr/lib/x86_64-linux-gnu/libstdc++.so.6
                                        No          /lib/x86_64-linux-gnu/libm.so.6
                                        No          /lib/x86_64-linux-gnu/libgcc_s.so.1
                                        No          /lib/x86_64-linux-gnu/libc.so.6
                                        No          /lib64/ld-linux-x86-64.so.2
'info sharedlibrary'命令列出了我没有调试符号的共享库。如何获取库,例如/usr/lib/libboost_thread.so.1.49.0与debuging符号(和来源)?

1 个答案:

答案 0 :(得分:0)

您的info shared输出显示GDB未为任何共享库加载符号。

最可能的原因:您set auto-solib-add off文件中的某个地方~/.gdbinit

您应该可以使用

解决此问题
  • (gdb) shared . - 强制GDB读取所有共享库,或
  • 从任何地方取出set auto-solib-add off