Opened 12 years ago
Closed 7 years ago
#36727 closed defect (fixed)
gdb 7.5 BFD unknown load command & Unable to find Mach task port
Reported by: | jb_duffy@… | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.1.2 |
Keywords: | Cc: | lpsinger (Leo Singer), evandrix (Lee Wei Yeong), ldalessandro@…, maligree@…, jdswinbank (John Swinbank), karl.smeltzer@…, thomas.fanghaenel@…, jdegenhardt@…, ltalirz (Leopold Talirz), cooljeanius (Eric Gallager) | |
Port: | gdb |
Description
Hi
Mountain Lion OS X 10.8.2, XCode 4.5.1, MacBook Pro 2.4 GHz Intel Core i7, 4 GB 1333 MHz DDR3
I have successfully installed MacPorts gcc-mp-4.7. And, gdb 7.5 appears to have installed successfully. I can build a simple Hello World C program but when I try to debug it with gdb I get one possibly two separate errors.
Below is a sample build and debug session:
macbook:test john$ make gcc-mp-4.7 -Wall -std=c99 -pedantic -g -O0 hello.c -o hello macbook:test john$ ls -l total 40 -rw-r--r-- 1 john staff 69 25 Oct 15:20 Makefile -rwxr-xr-x 1 john staff 8756 25 Oct 15:22 hello -rw-r--r-- 1 john staff 110 25 Oct 15:22 hello.c drwxr-xr-x 3 john staff 102 25 Oct 15:22 hello.dSYM macbook:test john$ ggdb hello 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-darwin12.2.0". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... BFD: /Users/john/test/hello: unknown load command 0x2a BFD: /Users/john/test/hello: unknown load command 0x28 BFD: /Users/john/test/hello: unknown load command 0x2b BFD: /Users/john/test/hello: unknown load command 0x2a BFD: /Users/john/test/hello: unknown load command 0x28 BFD: /Users/john/test/hello: unknown load command 0x2b Reading symbols from /Users/john/test/hello...Reading symbols from /Users/john/test/hello.dSYM/Contents/Resources/DWARF/hello...done. done. (gdb) l 1 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main(void) 5 { 6 printf("Hello, World!\n"); 7 exit(EXIT_SUCCESS); 8 } (gdb) b 6 Breakpoint 1 at 0x100000f62: file hello.c, line 6. (gdb) r Starting program: /Users/john/test/hello Unable to find Mach task port for process-id 77680: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8)) (gdb) quit
Any help would be greatly appreciated with the BFD error and guidance on how to solve the code signing issue.
Regards
John
Attachments (1)
Change History (28)
comment:1 Changed 12 years ago by mf2k (Frank Schima)
Keywords: | gdb BFD Mach task port removed |
---|---|
Owner: | changed from macports-tickets@… to dweber@… |
comment:6 follow-up: 7 Changed 12 years ago by maligree@…
Has anyone had any luck with this? I'm willing to dive into this one to get it work and come up with a clear answer, but I don't want to reinvent the wheel.
comment:7 Changed 12 years ago by jb_duffy@…
Replying to maligree@…:
Has anyone had any luck with this? I'm willing to dive into this one to get it work and come up with a clear answer, but I don't want to reinvent the wheel.
I'm not aware of any luck with this. I would help but I don't have the technical skills. I'm very happy to help out testing etc.
comment:9 Changed 12 years ago by jdswinbank (John Swinbank)
http://sourceware.org/gdb/wiki/BuildingOnDarwin explains how to generate a certificate and sign the gdb executable, and, indeed, signing the gdb executable installed by Macports following those instructions solves the issue for me. I'm not sure how easy it would be to automate within the Macports infrastructure, though.
comment:10 follow-up: 12 Changed 12 years ago by dave@…
Interesting; codesigning doesn't solve the problem for me. My /usr/bin/gdb works, but my /opt/local/bin/ggdb doesn't. The only differences I can see are in the files' extended attributes:
cube:/tmp/bld/modhist/debug dave% codesign --verify --verbose $(which gdb) $(which ggdb) /usr/bin/gdb: valid on disk /usr/bin/gdb: satisfies its Designated Requirement /opt/local/bin/ggdb: valid on disk /opt/local/bin/ggdb: satisfies its Designated Requirement cube:/tmp/bld/modhist/debug dave% ls -l@ $(which gdb) $(which ggdb) -rwxr-sr-x 1 root wheel 5206576 Jan 10 10:53 /opt/local/bin/ggdb -rwxr-xr-x@ 1 root wheel 11032 Nov 27 14:29 /usr/bin/gdb com.apple.cs.CodeDirectory 112 com.apple.cs.CodeRequirements 80 com.apple.cs.CodeSignature 1346
However, I don't know how to produce those attributes on ggdb, nor do I know what the correct numbers would be.
comment:12 Changed 12 years ago by thomas.fanghaenel@…
Same issue here. I have code-signed the executable, but am still getting the "Unable to find Mach task port" error when I try to run the executable in gdb.
bash-3.2$ ~/local/bin/gdb a.out GNU gdb (GDB) 7.5.50.20130115 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-darwin11.4.2". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /Users/xxx/tmp/a.out...Reading symbols from /Users/xxx/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out...done. done. (gdb) break main Breakpoint 1 at 0x100000f0b: file foo.c, line 5. (gdb) run Starting program: /Users/xxx/tmp/a.out Unable to find Mach task port for process-id 70913: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8)) (gdb)
Here's the information that I get back from codesign on the executable:
bash-3.2$ codesign -d -v ~/local/bin/gdb Executable=/Users/xxx/local/bin/gdb Identifier=org.gnu.gdb Format=Mach-O thin (x86_64) CodeDirectory v=20100 size=31400 flags=0x0(none) hashes=1565+2 location=embedded Signature size=1605 Signed Time=Jan 15, 2013 1:24:47 PM Info.plist entries=4 Sealed Resources=none Internal requirements count=1 size=88
The only difference I can see between the default gdb executable and the one I built are, as Dave pointed out, the extra permissions. Any pointers anybody?
comment:16 Changed 11 years ago by cooljeanius (Eric Gallager)
If codesigning failed to work, did you try modifiying the launchd plist for taskgated as described in #39349 and port notes gdb
? Also does this still happen with gdb 7.6?
comment:18 Changed 10 years ago by mf2k (Frank Schima)
Owner: | changed from dweber@… to macports-tickets@… |
---|
dweber has retired. See #43834.
comment:19 Changed 10 years ago by mf2k (Frank Schima)
Owner: | changed from macports-tickets@… to stuartwesterman@… |
---|
comment:20 Changed 10 years ago by stuartwesterman (Stuart Westerman)
This can be fixed by setting the -p in the taskgated plist:
/System/Library/LaunchDaemons/com.apple.taskgated.plist
<key>ProgramArguments</key> <array> <string>/usr/libexec/taskgated</string> <string>-sp</string> </array>
This is not a problem. Please close.
comment:21 Changed 10 years ago by mf2k (Frank Schima)
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:22 Changed 9 years ago by plinss (Peter Linss)
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Having the same issue with El Capitan and GDB @7.9.1_3+python34 (MacPorts 2.3.4).
I have turned off System Integrity Protection and added the 'p' argument to taskgated as above (and rebooted) and still get: Unable to find Mach task port for process-id 537: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
comment:23 Changed 9 years ago by malaperle@…
I was able to make it work on El Capitan by following https://sourceware.org/gdb/wiki/BuildingOnDarwin *then* changing the group of ggdb from procmon to admin, so
sudo chgrp admin /opt/local/bin/ggdb
Changed 9 years ago by malaperle@…
Attachment: | Portfile-gdb.diff added |
---|
Patch that removes the chgrp to procmon and links to the new instructions
comment:24 Changed 8 years ago by mf2k (Frank Schima)
Owner: | stuartwesterman deleted |
---|---|
Status: | reopened → assigned |
comment:25 Changed 8 years ago by evandrix (Lee Wei Yeong)
Cc: | evandrix added |
---|
comment:26 Changed 8 years ago by evandrix (Lee Wei Yeong)
Cc: | evandrix removed |
---|
comment:27 Changed 7 years ago by raimue (Rainer Müller)
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
gdb notes hint at codesigning as of [380ef99dde4cec0516cba66797d478ff0d97239d/macports-ports] (#54217).
In the future, please Cc the port maintainer(s).