LLVM Discussion Forums

[LLDB] Having issues with lookup

This might sound like I’m taking a pretty roundabout way of doing things, but I’m having an issue doing something and I can’t tell if I’m just doing something wrong or if this is an issue on lldb’s side.
I’m using lldb to get the symbols from addresses produced by crash logs, that’s mostly all fine and good. Makes perfect sense. What doesn’t make sense is that when I have modules with separated, associated symbol files, target module lookup -a only ever pulls from the executable’s symbol tables. target module dump symtab dumps the executable’s symbol table but not the debug symbols. The result is that certain symbols that got stripped by the compiler into the debug info only come out as ___lldb_unnamed_symbol

I’m loading the main executable and supporting frameworks essentially as follows, with actual filenames and folder layout removed for anonymity:
target create --no-dependents 'main.o' -s 'main.dsym'
image add 'dependency.o' -s 'dependency.dsym'
image load -f 'main.o' __TEXT [offset address]
image load -f 'dependency.o' __TEXT [offset address]
image lookup -a [address]

When I do the above, on the specific items that are crashing, the resulting symbol is a variant of ___lldb_unnamed_symbol.

Just to make me hate it more, there’s something even worse going on here as far as I can tell.
target create --no-dependents dependency.dsym
image load -f 'dependency.o' __TEXT [offset address]
image lookup -a [address]
Same offsets and address as before, and for some reason targets can be debug info files but modules can’t be, this one actually finds the correct, matching, named symbol. So I know for a fact that the symbol is accessible and in a file that I’ve informed lldb about, it’s just using the wrong file to find it.
Could I get some direction on this? I’ve never delved into lldb like this before and I’m probably doing something wrong somewhere.

It’s unclear what you’re trying to achieve, but the above commands cannot work. They do not conceptually make sense.

A dSYM is completely linked, you cannot apply offsets to different object files that have been linked. Also, the Darwin linker can and will reorder functions, so a single offset per object file segment doesn’t make sense.

Why do you need the object files if you have the dSYM which is supposed to have all the debug information and symbols? I’m not sure what you mean by “targets can be debug info files”. A target uses modules (binary images), but it isn’t a file.

You’re usually supposed to use a dSYM with the main linked executable. If you put them side-by-side the dSYM should be loaded automatically. Then you can just use target modules load to set the sections addresses.

You can also look at https://github.com/llvm/llvm-project/blob/master/lldb/examples/python/crashlog.py which might be doing just what you want?