Skip to content

Conversation

@weliveindetail
Copy link
Member

@weliveindetail weliveindetail commented Nov 13, 2025

The DebugObjectManagerPlugin implements debugger support for ELF platforms with the GDB JIT Interface. It emits a separate debug object allocation in addition to the LinkGraph's own allocation. This used to happen in the plugin's notifyEmitted() callback, i.e. after the LinkGraph's allocation was finalized. In the meantime, it had to block finalization of the corresponding materialization unit to make sure that the debugger can register the object before the code runs.

This patch switches the plugin to use an allocation action instead. We can remove the notifyEmitted() hook and implement all steps as JITLink passes:

  1. We keep fixing up section load addresses in PostAllocationPasses
  2. We now emit the debug object already in PreFixupPasses, i.e. before the LinkGraph's allocation is finalized. This is great, because it can run in parallel to the LinkGraph's link phase 3.
  3. We await the finalization of the debug object in PostFixupPasses and run the GDB JIT Interface registration in an AllocAction when finalizing the LinkGraph's allocation.

Main benefits are:

  • plugin is ported to the new AllocAction approach
  • we save at least one RPC round-trip
  • concurrent emission of the debug object reduces wall-time
  • once this landed, we can drop EPCDebugObjectRegistrar

This PR implements the basic switch. I want to add some more improvements to the plugin in a follow-up (mostly NFC then).

@weliveindetail
Copy link
Member Author

FYI: the Windows build failed with an unrelated error

2025-11-13T18:23:06.0717371Z [10620/11138] Linking CXX executable bin\mlir-capi-pass-test.exe
2025-11-13T18:23:06.0718013Z FAILED: [code=4294967295] bin/mlir-capi-pass-test.exe 
2025-11-13T18:23:06.0728799Z lld-link: error: undefined symbol: void __cdecl mlir::ptr::registerConvertPtrToLLVMInterface(class mlir::DialectRegistry &)
2025-11-13T18:23:06.0730811Z >>> referenced by MLIRRegisterAllExtensions.lib(RegisterAllExtensions.cpp.obj):(void __cdecl mlir::registerAllExtensions(class mlir::DialectRegistry &))

@lhames
Copy link
Contributor

lhames commented Nov 16, 2025

If we switch to a dealloc action for deallocation I think that would simplify this a lot further: At that point DebugObjectManagerPlugin doesn't need to track the resources at all since they'll be covered by the actions attached to the memory allocation.

@weliveindetail
Copy link
Member Author

Thanks for the feedback. Yes, exactly! I have a patch for it already: weliveindetail@2cf880f, but there are 2 open issues. I will sort it out into PRs next week. I think it's good to review in isolation.

Copy link
Contributor

@lhames lhames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. Yes, exactly! I have a patch for it already: weliveindetail@2cf880f, but there are 2 open issues. I will sort it out into PRs next week. I think it's good to review in isolation.

LGTM. Thanks @weliveindetail -- I look forward to checking out the upcoming PRs too. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants