簡體   English   中英

GDB回溯在Mac上不顯示函數名稱

[英]GDB backtrace don't show function names on 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不用它們就可以展開堆棧(僅需要展開描述符)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM