Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
185 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...