Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB kind of doesn't work on macOS Sierra

It is a problem that appeared when I first updated to macOS Sierra yesterday.

GDB itself is running OK. However, somehow, it cannot run my program. When I type 'run' and 'enter', it immediately crashes with the information: During startup program terminated with signal SIG113, Real-time event 113.

My GDB is based on homebrew. So today, I uninstalled the whole homebrew package and reinstalled it. After the codesign step, I still faced the same error.

I tried 'sudo' and a few other things. Google had no idea what happened. So I was wondering if you guys might have some magical solution.

like image 599
Scott Chang Avatar asked Sep 26 '16 12:09

Scott Chang


People also ask

Why does gdb not work on Mac?

The problem is caused by Apple switching away from GDB, the GNU debugger, to LLDB, the LLVM debugger, in their Xcode toolchain (along with the transition from GCC to Clang). Unfortunately, Eclipse is not capable of communicating with any debugger other than GDB (yet).

Does gdb work on Mac?

I just installed it (gdb 8.0) following this procedure as of today, it works on Mac OS High Sierra 10.13. 2 (17C88). For the latest version "brew install gdb" is fine. However, the steps above will allow you to install older versions which is handy.

Do you have to install gdb on Mac?

If you don't already have gdb on your system, then you'll need to install it. I'm going to show you how to install gdb by using Homebrew. If you have gdb on your system already, you can skip to the Generate a certificate step. If you received an error, then you'll need to install gdb using Homebrew.

Does gdb work on Mac m1?

gdb is not support, but you can use lldb .


2 Answers

This is how I easily fixed the issue. [Update: based on feedback received and yet to be verified, it seems that this solution works with macOS Sierra 10.12 but not with macOS Sierra 10.12.2]

See video instructions here

  1. Quit gdb
  2. Using your text editor e.g. Sublime Text, save a file called .gdbinit in your user folder.
  3. In the file add the following: set startup-with-shell off
  4. Save the file
  5. gdb should now work

Sources

https://discussions.apple.com/thread/7684629?start=0&tstart=0

Where is .gdbinit is located and how can I edit it?

https://sourceware.org/gdb/onlinedocs/gdb/Starting.html

like image 176
Salamit Avatar answered Sep 28 '22 13:09

Salamit


I got the same error after updating to macOS Sierra. Temporarily I changed debugger to LLDB using the library lldbmi2:
1. git clone https://github.com/freedib/lldbmi2.git lldbmi2
2. cd lldbmi2
3. mkdir build
4. cd build
5. cmake ../
6. make
7. sudo make install

Once lldbmi2 is installed, you can debug your application by creating a new C/C++ Application in Debug Configurations... and change the GDB debugger (in Debugger tab) from gdb to lldbmi2. Options to lldbmi2 may be set there. Something like /usr/local/bin/lldbmi2 --log.

enter image description here

Everything seems to be working fine, and even better as GDB.

like image 45
Michał Ciołek Avatar answered Sep 28 '22 11:09

Michał Ciołek