This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Try to find relative DWO files by file name only, as a last resort
AbandonedPublic

Authored by DavidSpickett on Aug 17 2023, 7:05 AM.

Details

Summary

Relative DWO files are normally found at some/path/to/file.dwo.
Currently lldb will find the file by adding that path to the
binary's location and to any debug search paths that are set.

This patch adds a fallback on top of that where lldb will look
for just the filename (file.dwo) in those same places.

So if you had flattened a build directory before distribution,
you could still get symbols. Or perhaps you send out a DWO file
on demand, and don't want people to have to recreate the directory
layout.

For example if you were built:
program
obj/program.dwo

And changed to:
program
program.dwo

<binary dir>/obj/program.dwo is not found.
<binary dir>/program.dwo is.

If the layout was changed to:
program
mydebuginfo/progam.dwo

And we had a debug search path of <binary dir>/mydebuginfo:

  • <binary dir>/mydebuginfo/obj/program.dwo is not found.
  • <binary dir>/mydebuginfo/program.dwo is found.

Diff Detail

Event Timeline

DavidSpickett created this revision.Aug 17 2023, 7:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2023, 7:05 AM
DavidSpickett requested review of this revision.Aug 17 2023, 7:05 AM
Herald added a project: Restricted Project. · View Herald Transcript

@clayborg This is I think what you meant. I'm not 100% sure it's safe because I keep wondering if we could find the wrong files this way, but with 1 DWO file per program it seems unlikely.

I've reduced the nesting in the new tests compared to the previous patch. Also this version builds all the possible paths first, then tries them all. I can try to rework that so we do it as we go, but tell me what you think of the functionality first.

clayborg requested changes to this revision.Aug 17 2023, 11:23 AM
clayborg added inline comments.
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
1784–1804

Would it be better to move this out of the "if (!dwo_file.IsRelative())" and else statement?

1815

Maybe move it here? That way even if we have a non-relative path to a .dwo file, it could find it locally or in the search paths?

This revision now requires changes to proceed.Aug 17 2023, 11:23 AM
DavidSpickett abandoned this revision.Sep 1 2023, 4:35 AM

Squashed into previous review.