Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install gdb on OSX 10.9

How to install gdb on OSX 10.9?

I try to use macports:

port install gdb
Password:
...
--->  Updating database of binaries: 100.0%
--->  Scanning binaries for linking errors: 100.0%
--->  No broken files found.

But I don't have gdb executable:

$ which gdb
$ 

I found out that macports gdb on mac is called ggdb. So I make a link:

sudo ln -s /opt/local/bin/ggdb /opt/local/bin/gdb

$ gdb --args ./prog -time
GNU gdb (GDB) 7.6
Copyright (C) 2013 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-darwin13.0.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /prog...done.
(gdb) r
Starting program: /prog -time
Unable to find Mach task port for process-id 65740: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
(gdb) 

So how to install gdb correctly on OSX 10.9?

P.S. Related questions, which doesn't help:

How to get a "codesigned" gdb on OSX?

"please check gdb is codesigned - see taskgated(8)" - How to get gdb installed with homebrew code signed?

like image 346
klm123 Avatar asked Nov 16 '13 18:11

klm123


People also ask

How do I get GDB on my Mac?

As with GCC, the easiest way to install GDB is through Homebrew. In a Terminal window, run the command brew install gdb , and wait for it to complete. (As usual, it may ask for your password.) Now, we need to code-sign the GDB executable, so it will be allowed to control other processes, as necessary for a debugger.

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 Xcode use GDB?

Xcode 5.1 no longer officially supports GDB, instead defaulting only to LLDB. The problem with LLDB is that it shows no useful debug information on app crashes. Furthermore, all Exception Breakpoints simply break on main.

How do I know if LLDB is installed?

You can check if GDB is installed on your PC with following command. If GDB is not installed on your PC, install it using your package manager (apt, pacman, emerge, etc). GDB is included in MinGW. If you use package manager Scoop on Windows, GDB is installed when you install gcc with scoop install gcc.


1 Answers

I made it this way (described here):

  1. sudo nano /System/Library/LaunchDaemons/com.apple.taskgated.plist

    change option string from -s to -sp at line 22, col 27.

  2. reboot the computer.

  3. Use gdb

like image 142
klm123 Avatar answered Sep 16 '22 14:09

klm123