gdb fails on mountain lion
Asked Answered
G

4

2

I tried to compile a 7.x Version of gdb without any luck. I codesigned the executable(http://sourceware.org/gdb/wiki/BuildingOnDarwin).

With following version there were these problems.

7.5,7.4,git clone: unknown load command 0x2a (and others) for my application and different system libraries when starting gbd. When trying to print a vector for example i always get: Could not find the frame base for "main(int, char**)"

7.3 (macports and from gdb-website): on starting the application it fails to set the breakpoint and continues to run.

(gdb) start
Temporary breakpoint 1 at 0x100000950: file ../src/main.cpp, line 15.
Starting program: [...]
BFD: unable to read unknown load command 0x24
BFD: unable to read unknown load command 0x2a
BFD: unable to read unknown load command 0x26
Error in re-setting breakpoint 1: Cannot access memory at address 0x100000950
[application continues]

I used the system llvm-gcc, gcc4.7 and svn-gcc4.8 to compile. Has anybody succeeded in installing gdb on Mountain Lion?

Gantz answered 21/8, 2012 at 7:38 Comment(6)
Why not just use the version of gdb that comes with Xcode ?Floss
Xcode's gdb is 6.3.x which is pretty old. I want to use the pretty printing of stl containers feature of gdb 7.x.Gantz
Did you try lldb ? Is that any better at printing STL containers ?Floss
lldb is quite comfortable for this task but unfortunately i want to use gdb with eclipse IDE which only supports gdb.Gantz
I ran into the same problem on Lion. It worth noticing that the executable /usr/bin/gdb is not signed at all (check by codesign -d /usr/bin/gdb), instead, when debugging anything using /usr/bin/gdb, a popup will appear to request permission to debug. Maybe gdb7.5 should somehow request permission like this too.Grau
/usr/bin/gdb is a shell script which tries to find the correct debugger instance for the given architecture. The x86 debugger is under /usr/libexec/gdb and it is signed. Verify with codesign -d --verbose=4 /usr/libexec/gdb/gdb-i386-apple-darwinOptimize
B
11

i installed gdb 7.5 on mountain lion without problems...

  1. those steps might help you: ./configure --prefix=/usr/local --enable-targets=x86_64-apple-darwin10 --enable-64-bit-bfd --disable-werror --build=x86_64-apple-darwin10 --host=x86_64-apple-darwin10 --target=x86_64-apple-darwin10

  2. then make install gdb.

  3. create your own certificate like discribed here and sign the gdb http://sourceware.org/gdb/wiki/BuildingOnDarwin

  4. you have to explicitly state: codesign -s gdb-cert /usr/local/gdb before you sign the gdb make sure you already set your certificate to trusted. also close the keychain before signing your gdb.

hope this also works for your

Budde answered 11/9, 2012 at 14:28 Comment(4)
Thanks, this works perfectly for me. I think I've been missing the close the keychain before signing your gdb step.Grau
That didn't solve the problem for me. make check still fails and the unknown load command errors are still there. Probably there's something wrong with my compiler.Gantz
Unfortunately this doesn't work for me either. I'd been doing steps 2-4 correctly with no success and thought step 1 might solve the problem but sadly it didn't work. This homebrew pull request (for a gdb formula) mentions the above "BFD: unable to read unknown load command" stuff as a gdb issue on Mountain Lion.Milda
This also doesn't work for me with GCC 4.9 and GDB 7.7.1 on Mavericks. After doing the four steps, I can set breakpoints perform related GDB functions without problems, but I cannot query the values of variables. GDB always reports that it could not find the frame base for some functions. If I use Eclipse rather than a terminal, then when I want to inspect the value of a variable, Eclipse would complain that it failed to execute mi command.Fixation
M
5

I resolved this issue by following the steps tried here: http://coding.derkeiler.com/Archive/Ada/comp.lang.ada/2012-09/msg00305.html

Steps

  1. sudo chgrp procmod /usr/local/bin/gdb
  2. sudo chmod g+s /usr/local/bin/gdb
  3. Edit /System/Library/LaunchDaemons/com.apple.taskgated.plist and add +p argument to taskgated process
  4. Force kill taskgated process (it will restart)
  5. Try again

Other links:

  1. https://blogs.oracle.com/dns/entry/understanding_the_authorization_framework_on
Morello answered 1/12, 2012 at 1:7 Comment(4)
I've followed the steps in Matthew Purland's answer, but after codesigning my newly minted gdb binary the permissions string given by 'ls -l' doesn't include the '@' character I'd expect to see. Sure enough, the command 'xattr -l' also shows no extended attributes, though the xcode-supplied version of gdb in '/usr/bin/gdb' is fine. Any thoughts on why not?Kuhlman
how to force kill task gated?Clove
@Clove kill -9 [pid]Flout
@Clove ps ax | grep taskgated, then you will get the PID, normally, the PID for taskated is very small.Flout
C
2

it doesn't seem to work for me... same issue as with the default homebrew settings

v1:src zeph$ brew install gdb
==> Downloading http://ftpmirror.gnu.org/gdb/gdb-7.5.tar.bz2
Already downloaded: /Library/Caches/Homebrew/gdb-7.5.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/gdb/7.5 --with-python=/usr --with-system-readline --enable-targets=x86_64-apple-darwin10 --enable-64-bit-bfd --disable-werror --build=x86_64-apple-darwin10 --hos
==> make
==> make install
==> Caveats
gdb requires special privileges to access Mach ports.
You will need to codesign the binary. For instructions, see:

  http://sourceware.org/gdb/wiki/BuildingOnDarwin
==> Summary
/usr/local/Cellar/gdb/7.5: 62 files, 9.3M, built in 119 seconds
v1:src zeph$ codesign -s gdb-cert /usr/local/Cellar/gdb/7.5/bin/gdb 
v1:src zeph$ /usr/local/Cellar/gdb/7.5/bin/gdb --args /Users/zeph/tmp/CouchBase/src/install/bin/memcached -d -u root -P /tmp/0libmemcached_memc.pid -t 1 -p 11221 -U 11221 -m 128
GNU gdb (GDB) 7.5
Copyright (C) 2012 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-darwin10".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
BFD: /Users/zeph/tmp/CouchBase/src/install/bin/memcached: unknown load command 0x29
BFD: /Users/zeph/tmp/CouchBase/src/install/bin/memcached: unknown load command 0x29
Reading symbols from /Users/zeph/tmp/CouchBase/src/install/bin/memcached...done.
(gdb) run
Starting program: /Users/zeph/tmp/CouchBase/src/install/bin/memcached -d -u root -P /tmp/0libmemcached_memc.pid -t 1 -p 11221 -U 11221 -m 128
Unable to find Mach task port for process-id 28755: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
(gdb) 

k, I had to re-sign it after having TRUSTED the certificate all across the board

codesign -fs gdb-cert /usr/local/Cellar/gdb/7.5/bin/gdb

Cadge answered 15/11, 2012 at 18:5 Comment(2)
does it work for you? c>codesign -s gdb-cert /usr/local/bin/gdb /usr/local/bin/gdb: is already signed but it still gives me the error message Unable to find Mach task port for process-id 838: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))Excessive
This also does not work for me. I've signed the binary multiple times with different certificates but still no luck. Not sure what I'm doing wrong.Optimize
W
2

There were two issues in the OP's question. The one regarding signing the executable or modifying taskgated and using setgid procmod has been covered. The second issue is the warnings about unknown load commands. I too ran into this and after a bunch of searching came across the following patches, that fix it:

https://gist.github.com/davidbalbert/4197567

Wylen answered 5/2, 2013 at 17:45 Comment(1)
Thank you!! Your solution was perfect for me. I almost want to say, "I love you!". ;)Consubstantiation

© 2022 - 2024 — McMap. All rights reserved.