2014-12-28 57 views
6

我通過Homebrew安裝了GDB 7.8.1和GCC 4.9。Homebrew GDB無法打開優勝美地10.10的核心文件

當我打開由GCC編譯(gcc-4.9 -g xxx.c -o xxx)程序生成的核心文件,它會報告:

→ gdb ./list_test /cores/core.1176 
GNU gdb (GDB) 7.8.1 
Copyright (C) 2014 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "x86_64-apple-darwin14.0.0". 
Type "show configuration" for configuration details. 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>. 
Find the GDB manual and other documentation resources online at: 
<http://www.gnu.org/software/gdb/documentation/>. 
For help, type "help". 
Type "apropos word" to search for commands related to "word"... 
Reading symbols from ./list_test... 
warning: `/var/folders/r1/3sx4x5k1557g_v5by83k4hg00000gn/T//cchuMtAU.o': can't open to read symbols: No such file or directory. 
(no debugging symbols found)...done. 
"/cores/core.1176": no core file handler recognizes format 

我用Google搜索,發現有人建議使用LLDB而不是GDB。

可以使用GDB調試核心文件嗎?是因爲GDB不支持優勝美地的二進制格式?

回答

12

根據the long GDB developers' discussion thread on this issue,似乎蘋果沒有將他們的修改合併回官方GNU主線,而是選擇在他們自己的站點上發佈修改後的源代碼。因此,Homebrew GDB安裝(使用庫存GDB源代碼)無法加載OS X核心文件。

在這一點上,我看到三個選項:

  1. 讓步,學習LLDB。有一個GDB to LLDB cheat sheet來幫忙。

  2. 從MacPorts安裝Apple的自定義GDB。我早就拋棄的MacPorts,所以我不能測試它,但如果你有安裝的MacPorts,請嘗試以下操作:

    $ sudo port install gdb-apple 
    $ codesign -s <your_GDB_cert_id> /opt/local/bin/gdb-apple 
    $ /opt/local/bin/gdb-apple ./list_test /cores/core.1176 
    
  3. 翻譯的MacPorts' GDB補丁,並建立規範成一個自制配方。這在理論上是可行的,但我沒有時間自己做。

就我個人而言,我選擇了學習LLDB。 Apple已經永久移動到LLVM,因此,舊版補丁GDB停止使用最新最好的Xcode工具可能只是時間問題。

相關問題