GDB 回溯在 Mac 上不显示函数名称

发布于 2024-11-17 10:38:03 字数 1417 浏览 3 评论 0原文

我正在使用此代码使用 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。

感谢您帮助理解这种奇怪的行为。

I was testing some things with gdb with this code (it's a wrong code, i use it just for testing purposes):

#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;
}

Then i compile it : gcc -Wall -g -framework Foundation testGdb.m -o testGdb, and i run it:

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)

The strange thing is that ther's no name in (#1), the correct output would normally print NSLog(the cause of the crash) and main.

Thanks for helping to understand this strange behavior.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不再见 2024-11-24 10:38:03

这个答案很可能也适用于此。

调试符号与问题无关——GDB 可以在没有它们的情况下很好地展开堆栈(只需要展开描述符)。

This answer is most likely applicable here as well.

Debug symbols have nothing to do with the problem -- GDB can unwind stack just fine without them (only unwind descriptors are necessary).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文