目标 C - GDB 回溯在 Mac 上不显示函数名称



我用这段代码用gdb测试了一些东西(这是一个错误的代码,我只是为了测试目的而使用它):

#import <Foundation/Foundation.h>
int main (int argc, char **argv)
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int i = 1;  
    NSLog(@"Hi GDB, i is %@", i);
    [pool release];
    return 0;
}

然后我编译它:gcc -Wall -g -framework Foundation testGdb.m -o testGdb,并运行它:

gdb ./a.out 
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ..... done
(gdb) run
Starting program: /Users/Tarek/Desktop/a.out 
Reading symbols for shared libraries .++++....................... done
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x000000000000002a
0x00007fff82d7a0a3 in objc_msgSend_fixup ()
(gdb) bt
#0  0x00007fff82d7a0a3 in objc_msgSend_fixup ()
#1  0x0000000000000000 in ?? ()

(gdb)

奇怪的是,(#1)中没有名字,正确的输出通常会打印NSLog(崩溃的原因)和main。

感谢你帮助我们理解这种奇怪的行为。

这个答案很可能在这里也适用。

调试符号和这个问题无关——没有它们,GDB可以很好地展开堆栈(只需要展开描述符)。

最新更新