How to debug a system extension from scratch with LLDB

Hi Experts,


I can add WaitForDebugger to file in /Library/LaunchDaemon/*.plist to debug launch daemons from scratch with LLDB.

Is it possible to debug a system extension from scratch with LLDB? Thanks a lot.

Replies

Is it possible to debug a system extension from scratch with LLDB?

I can think of various avenues that you might explore here but the easiest approach is to add a call to

pause
at the start of
main
. That generally works pretty well unless your program runs a lot of code prior to
main
starting (for example, C++ static initialisers) but that’s generally bad form in the first place.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks, eskimo:P

How about if I don't have the source code?

Well, this is exactly what a bunch of the SIP and Hardened Runtime provisions were explicitly made to prevent from happening.


There are lots of instructions out there on the internet about attaching debuggers to things you aren't activly developing, but I'll leave those as an exercise for the reader.

How about if I don't have the source code?

Why? Because it’s not your product? If so, my advice is that you engage with the product’s vendor. Helping folks debug other folks’s product is outside of my remit.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi eskimo,


My library was integrated with a system extension developed by another team, I just want to debug it quickly without code change due to I already have dSYM and source code.