我最近注意到 gdb 需要很长时间才能开始从我的目标应用程序执行代码。我不明白为什么。我使用的是 MacOS 10.6.5 和 GNU gdb 6.3.50-20050815(苹果版 gdb-1510)
如果我用 CTRL-C 中断它,我可以从回溯(下面)看到以下输出。看起来它在加载符号时卡住了?
无论如何,我对 gdb 的幕后工作方式相当不熟练。有人可以给我建议改善事情的建议吗?
#0 0x00007fff5fc05136 in __dyld__ZN4dyldL10loadPhase5EPKcRKNS_11LoadContextEPSt6vectorIS1_SaIS1_EE ()
#1 0x00007fff5fc0523f in __dyld__ZN4dyldL10loadPhase4EPKcRKNS_11LoadContextEPSt6vectorIS1_SaIS1_EE ()
#2 0x00007fff5fc0599e in __dyld__ZN4dyldL10loadPhase3EPKcRKNS_11LoadContextEPSt6vectorIS1_SaIS1_EE ()
#3 0x00007fff5fc05a47 in __dyld__ZN4dyldL10loadPhase1EPKcRKNS_11LoadContextEPSt6vectorIS1_SaIS1_EE ()
#4 0x00007fff5fc05b65 in __dyld__ZN4dyldL10loadPhase0EPKcRKNS_11LoadContextEPSt6vectorIS1_SaIS1_EE ()
#5 0x00007fff5fc05bf0 in __dyld__ZN4dyld4loadEPKcRKNS_11LoadContextE ()
#6 0x00007fff5fc06a5d in __dyld__ZN4dyldL14libraryLocatorEPKcbS1_PKN11ImageLoader10RPathChainE ()
#7 0x00007fff5fc0c746 in __dyld__ZN11ImageLoader22recursiveLoadLibrariesERKNS_11LinkContextEbRKNS_10RPathChainE ()
#8 0x00007fff5fc0c66f in __dyld__ZN11ImageLoader22recursiveLoadLibrariesERKNS_11LinkContextEbRKNS_10RPathChainE ()
#9 0x00007fff5fc0c66f in __dyld__ZN11ImageLoader22recursiveLoadLibrariesERKNS_11LinkContextEbRKNS_10RPathChainE ()
#10 0x00007fff5fc0c7b6 in __dyld__ZN11ImageLoader4linkERKNS_11LinkContextEbbRKNS_10RPathChainE ()
#11 0x00007fff5fc04d48 in __dyld__ZN4dyld4linkEP11ImageLoaderbRKNS0_10RPathChainE ()
#12 0x00007fff5fc068d6 in __dyld__ZN4dyld5_mainEPK12macho_headermiPPKcS5_S5_ ()
#13 0x00007fff5fc016d2 in __dyld__ZN13dyldbootstrap5startEPK12macho_headeriPPKcl ()
#14 0x00007fff5fc01052 in __dyld__dyld_start ()
最佳答案
我认为这是由在 gdb 代码中重复设置/恢复信号处理程序引起的。当我使用
ptrace -p
我得到匹配系统调用的页面......
rt_sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, NULL, 8) = 0
rt_sigaction(SIGSEGV, {0x68a820, [], SA_RESTORER|SA_STACK, 0x3bfc60f710}, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, NULL, 8) = 0
rt_sigaction(SIGSEGV, {0x68a820, [], SA_RESTORER|SA_STACK, 0x3bfc60f710}, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, 8) =
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, NULL, 8) = 0
rt_sigaction(SIGSEGV, {0x68a820, [], SA_RESTORER|SA_STACK, 0x3bfc60f710}, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, 8) =
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, NULL, 8) = 0
rt_sigaction(SIGSEGV, {0x68a820, [], SA_RESTORER|SA_STACK, 0x3bfc60f710}, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, 8) =
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, NULL, 8) = 0
rt_sigaction(SIGSEGV, {0x68a820, [], SA_RESTORER|SA_STACK, 0x3bfc60f710}, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, 8) =
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, NULL, 8) = 0
rt_sigaction(SIGSEGV, {0x68a820, [], SA_RESTORER|SA_STACK, 0x3bfc60f710}, {SIG_DFL, [], SA_RESTORER, 0x3bfc60f710}, 8) =
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
关于c++ - 符号加载非常慢,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10469508/