Fixes #28667
There's a bunch of ways to end up building split DWARF where the
DWO file is not next to the program file. On top of that you may
distribute the program in various ways, move files about, switch
machines, flatten the directories, etc.
This change adds a few more strategies to find DWO files:
- Appending the DW_AT_COMP_DIR and DWO name to all the debug search paths.
- Appending the same to the binary's dir.
- Appending the DWO name (e.g. a/b/foo.dwo) to all the debug search paths.
- Appending the DWO name to the binary's location.
- Appending the DWO filename (e.g. foo.dwo) to the debug search paths.
- Appending the DWO filename to the binary's location.
They are applied in that order and some will be skipped
if the DW_AT_COMP_DIR is relative or absolute, same for
the DWO name (though that seems to always be relative).
This uses the setting target.debug-file-search-paths, which
is used for DWP files already.
The added tests likely do not cover every part of the
strategies listed, it's a best effort.
Maybe we can also check the debug info search paths to see if they contain just the basename in case someone sends you a binary and any needed .dwo files?
So if we have a DWO path of "/users/someone/build/foo.dwo", we would check each of the debug info search paths for:
This would allow someone to send a binary to someone else and allow them to load it up.
But any such search might belong down below this entire if/else statement when the file isn't found: