Reputation: 12727
The dsymutil
man page indicates that there is an option to dsymutil
called --flat
which will create a single file debug package, with the .dwarf
extension. I tried this, and while the expected .dwarf
files do get created, it doesn't appear that lldb
actually loads them, unlike if you generate a regular .dSYM
directory. I can't find a whole lot of documentation other than what the man page says.
Is there an intended scenario for such files, or is this something left over from long ago that should no longer be used?
It was appealing because as a single file it would be easier to manage in a build system, rather than needing to manage the generated .dSYM
directory.
$ cat > hello_world.cpp
#include <iostream>
int main() {
std::cout << "Hello, World\n";
return 0;
}
$ clang++ ./hello_world.cpp -g -c -o hello_world.o
$ clang++ ./hello_world.o -o hello_world
$ dsymutil ./hello_world
$ tree ./hello_world.dSYM
./hello_world.dSYM
└── Contents
├── Info.plist
└── Resources
└── DWARF
└── hello_world
$ lldb hello_world
(lldb) target create "./hello_world"
Current executable set to './hello_world' (x86_64).
(lldb) image list
[ 0] 7984B8FE-1C4E-3468-9819-C3BE4E50456D 0x0000000100000000 .../hello_world
.../hello_world.dSYM/Contents/Resources/DWARF/hello_world
$ \rm -rf hello_world.dSYM
$ dsymutil --flat ./hello_world
$ file hello_world.dwarf
hello_world.dwarf: Mach-O 64-bit dSYM companion file x86_64
(lldb) target create "./hello_world"
Current executable set to './hello_world' (x86_64).
(lldb) image list
[ 0] 7984B8FE-1C4E-3468-9819-C3BE4E50456D 0x0000000100000000 .../hello_world
[ 1] F217F7F8-A795-3109-B77F-B1E2277F3E3B 0x0000000000000000 /usr/lib/dyld
As you can see, lldb
happily and automatically finds and loads the .dSYM
, but doesn't do so for the .dwarf
file version.
Is there a way to make lldb
load these files, or, better, load them automatically? Other tools? Is there some other step required to "link up" the executable to the .dwarf
file, like an analog to --add-gnu-debuglink
? Or is dsymutil --flat
something not really supported and to be avoided? Are there any use cases for it?
Upvotes: 2
Views: 489
Reputation: 1031
The --flat
option isn't really supported. It exists for testing, where we usually want to check the generated DWARF, rather than the dSYM bundle structure which should always be the same.
Upvotes: 2