Adding OS support to LLDB; `thread backtrace` missing symbols, but `image lookup` works

I’m in the process of adding os-specific support to lldb 13.0.1.

I figured out the custom RegisterContext, and adding parsing for my PT_NOTE section to ProcessElfCore. I’ve gotten to the point where thread backtrace will output the correct addresses for each frame, but it does not resolve those addresses to symbol names.

With the same target, lldb is able to resolve the symbol names for each of the addresses using image lookup -a <addr>.

I’m create the target using target create --arch i386-nto ./hello --core ./corefile, where hello was compiled both with -g and -gdwarf-4, so all needed symbols should be in there. This works for every address reported by thread backtrace.

From a few hours of debugging lldb while it’s running the thread backtrace command, I am seeing that the Target, has the binary in the module list, but the section list is empty. It does look like the section list is what’s used to resolve the symbols during the backtrace, but I’m not 100% certain.

What is the critical piece I’m missing here?

The piece I was missing:

The DynamicLoader is responsible for creating the sections in the target.
ProcessElfCore uses DynamicLoaderPOSIXDYLD, but that plugin expects either FreeBSD, Linux or NetBSD OS in the triple.

As the dynamic libraries for this platform are stored in a different way for this OS, I’ll need to write my own DynamicLoader plugin, which I have been avoiding.