First proposal for debugging support in JITLink. For now, only in-process x86-64 ELF. Please consider it a work-in-progress.
The JITLinkGDBLoaderPlugin forwards object files from ObjectLinkingLayer to an attached debugger through the GDB JIT Interface [1]. It implements ObjectLinkingLayer::Plugin::notifyLoaded() and expects an additional argument: a callback function that prepares a in-memory debug object for the given MaterializationResponsibility on request. The patch aims to keep overhead in generic execution paths minimal. Additional efforts for debug registration should reside in the callback.
Furthermore, responsibility for the preparation of the actual debug object buffer lies with the respective JITLink backend, so we can keep all format/architecture-specific code in one place. In this first sketch it's accomplished with another callback from linkPhase1 to the backend. While the JITLinkContext might be considered the natural owner of the function pointer, it is currently stored in the LinkGraph, because this is our only connection to the backend. The goal was to keep patch small and seek feedback first.
[1] https://sourceware.org/gdb/current/onlinedocs/gdb/JIT-Interface.html
clang-tidy: warning: invalid case style for function 'patchSectionLoadAddressesInELFObject_x86_64' [readability-identifier-naming]
not useful