[lldb-dev] LLDB Plugin: Listen for SBEvents when SBTarget is created from Xcode
Derek Selander via lldb-dev
lldb-dev at lists.llvm.org
Tue Jun 23 11:43:53 PDT 2020
Forgive me if this was asked in the past. I did some combing through the archives with a "site:lists.llvm.org/pipermail/lldb-dev/ plugininitialize | Xcode | sbtarget” google query, but didn’t find anything relevant
My ultimate goal is to build a helper tool which compliments Xcode when debugging something.
To do this: I am using the C++ bool lldb::PluginInitialize(lldb::SBDebugger dbg) function call to initialize my plugin within LLDB’s process. From there, I am spawning a mach XPC anonymous service to coordinate talking with my LLDB plugin and a macOS GUI application. This code is working great!
My problem is that at the time of my code being initialized (via Xcode calling into it via XPC), the SBDebugger is valid, but no SBTarget is valid (even the dummy one). This means I can not listen for events when the process starts up (i.e. SBProcess’s eBroadCastBitStateChanged), nor monitor for any events being from the SBTarget.
Since I am running code inside the LLDB.framework, I can of course do some wild and crazy stuff by injecting code to intercept when an SBTarget is being created, but I’d really rather avoid that in case you change the lldb_private APIs around. So my question is: do you have a recommended way to be notified via code in a LLDB plugin when a target is initialized through Xcode?
PS. I’ve read through the examples where a target is created directly via the SB APIs, but I can’t use those when Xcode is responsible for launching the SBTarget and SBProcess.
Thanks! Y’all are awesome
More information about the lldb-dev