I get gdb by brew install gdb
.
The source file content is:
#include
int main(){
int a = 10;
for(int i = 0; i<
I published a temporary brew formula that seems to work, while awaiting for official brew formula to be updated:
brew install https://raw.githubusercontent.com/timotheecour/homebrew-timutil/master/gdb_tim.rb
I got gdb working on Mojave by:
a) getting the latest gdb source archive (at time of writing, ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-8.2.50.20190212.tar.xz) - amongst other things, it adds handling for recognizing executables on Mac.
b) build gdb. I got errors for variable shadowing in darwin-nat.c so I edited the file and rebuilt.
c) follow steps in https://forward-in-code.blogspot.com/2018/11/mojave-vs-gdb.html
Voila.
(source: GDB on Mac/Mojave: During startup program terminated with signal ?, Unknown signal)
I have got a good solution for me from stack overflow and I do not know why it works. Here is the link.
I am new to macOS, and I do the following:
BFD: /Users/xxx/Codes/demo: unknown load command 0x32
Unknown Error -2,147,414,007
.
Solve this by getting the certificate in
Login
then export it and import it intoSystem
(Delete it from Login if unable to import).
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Unable to find Mach task port for process-id 1510: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
, according to how to undo codesign, something wrong still exist and the answer tells me to brew reinstall gdb
, but it still does not work, I called it a day yesterday.Hope my solution can help.
gdb 8.2 installed from Homebrew is not compatible with Mac mojave. I have upgrade to 8.2.1. The issue should be resolved.
The problem is that clang-1000.11.45.2
distributed with Apple LLVM version 10.0.0
add a new load command to o-mach executables named LC_BUILD_VERSION
.
$ otool -l test.o
...
Load command 1
cmd LC_BUILD_VERSION
cmdsize 24
platform macos
sdk n/a
minos 10.14
ntools 0
...
From the apple source:
/*
* The build_version_command contains the min OS version on which this
* binary was built to run for its platform. The list of known platforms and
* tool values following it.
*/
So currently bfd
(program used by gdb to manipulate executables) is not able to interpret this command, and returns the error.
The temporary solution I found is directly edit bfd
sources provide with gdb
.
I've only test with gdb-8.0.1
.
First, download gdb-8.0.1
sources from mirrors. Then add to gdb-8.0.1/bfd/mach-o.c
the following code at line 4649
:
case BFD_MACH_O_LC_BUILD_VERSION:
break;
And finally add int gdb-8.0.1/include/mach-o/loader.h
:
BFD_MACH_O_LC_BUILD_VERSION = 0x32
at line 189
(don't forget to add a ,
at the end of the line 188 after BFD_MACH_O_LC_VERSION_MIN_WATCHOS = 0x30
).
After these instructions you can follow a classic gdb
compilation as indicate inside the README :
run the ``configure'' script here, e.g.:
./configure
make
To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
make install
Don't forget to sign gdb
as explain here.
If you still get the (os/kern) failure (0x5) error, just run sudo gdb
.
This is a temporary solution waiting for the GNU team fix the problem directly on the repo.
EDIT
Binutils-gdb
has been updated, these changes are now implemented in commit fc7b364.
Hope It will be helpfull.
I got past this issue on Mojave by thinning the app. GDB does not understand universal binaries. So if file myapp
tells you myapp is a universal binary, try this:
lipo -thin x86_64 -output myapp-x86_64 myapp
And then
gdb myapp-x86_64