llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Replace `ObjectLinkingLayer::Plugin::notifyMaterializing`.

Open lhames opened this issue 2 years ago • 7 comments

This method was introduced in ef2389235c5de to support ELF debugging, but it's very special purpose and not otherwise a good fit for the ObjectLinkingLayer::Plugin interface. We should replace it with a special section, .jitlink.original_object_content (or something like that), which could be created by the ELFLinkGraphBuilder. The debug plugins could then detect this section and use it to copy out the debug content.

lhames avatar Nov 07 '24 03:11 lhames

@llvm/issue-subscribers-orcjit

Author: Lang Hames (lhames)

This method was introduced in ef2389235c5de to support ELF debugging, but it's very special purpose and not otherwise a good fit for the `ObjectLinkingLayer::Plugin` interface. We should replace it with a special section, `.jitlink.original_object_content` (or something like that), which could be created by the `ELFLinkGraphBuilder`. The debug plugins could then detect this section and use it to copy out the debug content.

llvmbot avatar Nov 07 '24 03:11 llvmbot

request to be assigned this issue :)

sonar3d avatar Nov 10 '24 01:11 sonar3d

request to be assigned this issue :)

Done! :)

lhames avatar Nov 10 '24 02:11 lhames

Just to clarify the method notifyMaterializing in ObjectLinkingLayer.cpp would be replaced by a method/section added to ELFLinkGraphBuilder.h? (and of course replace all calls to it as part of ObjectLinkingLayer to change the functionality to be a part of ELFLinkGraphBuilder?)

sonar3d avatar Nov 12 '24 11:11 sonar3d

@sonar3d That's right. The only Plugin to implement notifyMaterializing is DebugObjectManagerPlugin, and that could be updated to look for a special section in the LinkGraph instead (it should do this by inserting a PrePrunePass to inspect the graph).

lhames avatar Nov 13 '24 05:11 lhames

@sonar3d That's right. The only Plugin to implement notifyMaterializing is DebugObjectManagerPlugin, and that could be updated to look for a special section in the LinkGraph instead (it should do this by inserting a PrePrunePass to inspect the graph).

What would be a good way to check the functionality is still working?

sonar3d avatar Nov 27 '24 11:11 sonar3d

@sonar3d That's right. The only Plugin to implement notifyMaterializing is DebugObjectManagerPlugin, and that could be updated to look for a special section in the LinkGraph instead (it should do this by inserting a PrePrunePass to inspect the graph).

What would be a good way to check the functionality is still working?

I would try out the following example: https://github.com/llvm/llvm-project/blob/main/llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp

If you're building on Linux it's already available as a target: ninja LLJITWithRemoteDebugging.

If the example still builds and runs as expected then your changes are all good. :)

If you're building on Darwin then you'll want to test this in a Linux docker container -- just let me know and I'll send the commands that I use to set mine up.

lhames avatar Dec 02 '24 00:12 lhames