Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

ada - GDB errors on macOS Mojave

Environment: Mac/Mojave and GDB 8.2.1 (via homebrew).

I worked through instructions https://forward-in-code.blogspot.com/2018/11/mojave-vs-gdb.html i.e.:

  • latest GDB via brew, which solves the executable format issue

  • sign GDB with new entitlements

Additionally, I've also modified SIP to allow debugging (in Recovery OS terminal: csrutil enable --without debug).

However, I still can’t get gdb to work:

(gdb) file main
Reading symbols from main...done.
(gdb) run
Starting program: /Users/joubertold/code/Rhodus/obj/debug/main 
[New Thread 0x1a03 of process 5082]
[New Thread 0x2803 of process 5082]
During startup program terminated with signal ?, Unknown signal.
(gdb) 

Interestingly, lldb works for me on the same binary:

(lldb) file main
Current executable set to 'main' (x86_64).
(lldb) run
Process 5086 launched: '/Users/joubertold/code/Rhodus/obj/debug/main' (x86_64)
Rhodus
 1 is ONE
 1 is between 1 and 10
 1 is between 1 and 10
 1 is between 1 and 10
 1 is between 1 and 10
 1 is between 1 and 10
 1 is between 1 and 10
 1 is between 1 and 10
 1 is between 1 and 10
 1 is beyond
 1 is beyond
 1 is beyond
Process 5086 exited with status = 0 (0x00000000) 
(lldb) 

Any thoughts?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 (diff https://gist.github.com/joubertnel/267ca0fff4eaad494cc19ec3ba7953ed).

c) follow steps in https://forward-in-code.blogspot.com/2018/11/mojave-vs-gdb.html

Voila.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...