During finalization the debug object is registered with the target. Materialization must wait for this process to finish. Otherwise we might start running code before the debugger finished processing the corresponding debug info.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This means that materialization is blocked until finalization of the debug object allocation is done, i.e.:
- memory was copied over to the target
- an entry was added to the JIT descriptor (locks a global mutex)
- the executing process ran into the rendezvous breakpoint (1st process switch)
- the debugger processed the debug object, read the symbol table and returned control back to the executor (2nd process switch)
This might introduce a considerable delay in materialization. I wonder if this points out an interesting design question for the plugin API: Debug registration could run safely in parallel up to the point that execution reaches the emitted code. The only way I see to achieve it with the current API is blocking the notifyEmitted() callback. Could we instead return the promise and wait for it at a later point in time?
LGTM.
This might introduce a considerable delay in materialization. I wonder if this points out an interesting design question for the plugin API...
I think you're right, but rather than approach this through the plugin API I think the solution will come from rethinking "finalization" on the memory manager API: If we represented all the various pieces of metadata (eh-frames, objc registration, debug registration, etc.) as sections in the allocation, and allowed additional operations to be attached to the finalization call, then we could do everything in one RPC round trip.
I think you're right, but rather than approach this through the plugin API I think the solution will come from rethinking "finalization" on the memory manager API
Alright, that sounds reasonable. Having this delay for debugging use cases should be acceptable for the moment. It can be avoided by feeding in modules without debug info. The plugin detects that and stops any further processing early on.