Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Homebrew GDB can't open core file on Yosemite 10.10

I installed GDB 7.8.1 and GCC 4.9 through Homebrew.

When I open a core file generated by a GCC-compiled (gcc-4.9 -g xxx.c -o xxx) program, it reports:

→  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

I googled and found someone suggested to use LLDB instead of GDB.

Is is possible to use GDB to debug the core file? And is it because GDB does not support the binary format on Yosemite?

like image 488
pjhades Avatar asked Dec 28 '14 21:12

pjhades


1 Answers

Based on the long GDB developers' discussion thread on this issue, it seems Apple did not merge their changes back to the official GNU mainline, and instead chose to publish the modified source code on their own site. As a result, the Homebrew GDB install (which uses the stock GDB sources) can't load OS X core files.

At this point, I see three choices:

  1. Give in and learn LLDB. There's a GDB to LLDB cheat sheet to help.

  2. Install Apple's custom GDB from MacPorts. I've long forsaken MacPorts, so I can't test it, but if you have MacPorts installed, try the following:

    $ 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. Translate MacPorts' GDB patches and build spec into a Homebrew formula. It's theoretically possible, but I don't have the time to do it myself.

Personally, I've opted to just learn LLDB. Apple has moved permanently to LLVM, so it's probably just a matter of time before the old patched GDB stops working with the latest-and-greatest Xcode tools.

like image 189
Adrian Avatar answered Nov 15 '22 16:11

Adrian