When lli runs the below IR, it emits in-memory debug objects and registers them with the GDB JIT interface. The tests dump and check the registered information. IR has limited ability to produce complex output in a portable way. Instead the tests rely on built-in functions implemented in lli. They use a new command line flag -generate=function-name to instruct the ORC JIT to expose the built-in function with the given name to the JITed program.
debug-descriptor-elf-minimal.ll calls __dump_jit_debug_descriptor() to reflect the list of debug entries issued for itself after emitting the main module. The output is textual and can be checked straight away.
debug-objects-elf-minimal.ll calls __dump_jit_debug_objects(), which instructs lli to walk through the list of debug entries and append the encountered in-memory objects to the program output. We feed this output into llvm-dwarfdump to parse the DWARF in each file and dump their structures.
We can do the same for JITLink once D97335 has landed.
This global static pointer is working for the moment, but of course it's not exactly ideal. I need a better way to expose a member function callback. TPCIndirectionUtils offers writeResolverBlock(), but it only works with TPC. LocalTrampolinePool also uses resolver blocks, but I don't need the landing address resolution.
@lhames Can you think of a solution that also works for RuntimeDyld?