Homebrew GDB cannot open main file on Yosemite 10.10

I installed GDB 7.8.1 and GCC 4.9 via Homebrew.

When I open the main file generated by the compiled GCC program ( gcc-4.9 -g xxx.c -o xxx ), 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 that someone suggested using LLDB instead of GDB.

Can I use GDB to debug the main file? And because GDB does not support Yosemite binary format?

+6
source share
1 answer

Based on the discussion thread of GDB developers on this issue , it seems that Apple has not combined its changes with the official GNU base and instead chose to publish the modified source code on its own website. As a result, installing Homebrew GDB (which uses the original GDB sources) cannot load the main OS X files.

At this moment, I see three options:

  • Give and recognize LLDB. There is a GDB to LLDB cheat sheet to help.

  • Install Apple GDB from MacPorts. I forgot MacPorts long ago, so I can't test it, but if you have MacPorts, 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 
  • Translate the GDB MacPorts patches and build the specification into the Homebrew formula. Theoretically, this is possible, but I do not have time for this.

Personally, I decided to just learn LLDB. Apple has constantly switched to LLVM, so maybe it's just a matter of time before the old fixed GDB stops working with the latest and best Xcode tools.

+12
source

Source: https://habr.com/ru/post/980233/


All Articles