I have a program built in both release and debug modes. The released binary of my program has been crashed on a user machine (let the sysroots be the same, for simplicity), so now I have got a core file from this user. I want to debug this core file on my macOS using LLDB.
Let's consider I have these files on my machine:
a.out
a.out.dSYM
user_core
program.c
Now I'm trying to open user_core
using LLDB, but no debug info or sources are available:
$ lldb
(lldb) target create --core user_core
Core file '~/user_core' (x86_64) was loaded.
(lldb) f
frame #0: 0x00000001023b4f77 a.out`main + 39
a.out`main:
-> 0x1023b4f77 <+39>: xorl %ecx, %ecx
0x1023b4f79 <+41>: movl %eax, -0xc(%rbp)
(lldb) image lookup -v --address 0x00000001023b4f77
Address: a.out[0x0000000100003f77] (a.out.__TEXT.__text + 39)
Summary: a.out`main + 39
Module: file = "~/a.out", arch = "x86_64"
Symbol: id = {0x00000002}, range = [0x00000001023b4f50-0x00000001023b4f84), name="main"
(lldb) image list
[ 0] <...> 0x00000001023b1000 ~/a.out (0x00000001023b1000)
After executing (lldb) target modules add ~/a.out
, I got:
[ 0] <UUID #0> 0x00000001023b1000 ~/a.out (0x00000001023b1000)
...
[ 44] <UUID #44> a.out[0x0000000100000000] ~/a.out
~/a.out.dSYM/Contents/Resources/DWARF/a.out
As far as I understand, a.out
has been loaded twice, but LLDB still ignores the debug symbols.
I have also tried these techniques, with no effect:
(lldb) target create a.out --symfile a.out.dSYM --core user_core
(lldb) settings set target.debug-file-search-paths .
before opening a core file(lldb) setting set target.exec-search-paths .
before opening a core file(lldb) target symbols add ~/a.out.dSYM
So the question is how to properly debug a core dump of release binary with the specified debug symbols using LLDB?
You have to give lldb both the binary image and the core file when doing core file debugging. But unless the dSYM is in a different directory from the a.out (and that different location is somewhere that Spotlight isn't indexing), you should not need to pass the symfile. So your first command in the list of things you tried while a bit redundant, should have worked.
Are you sure the a.out.dSYM you have actually matches your a.out binary? When the dSYM is made, the UUID of the binary that it's made from gets copied into the dSYM, and lldb will only use debug information from a dSYM if it matches the UUID of the associated binary.
You can find the uuid's of a binary or of a dSYM by running the command:
$ dwarfdump -uuid
There isn't a way to force lldb to use the wrong dSYM for an executable. There's such a low percentage chance that's going to do anything useful that there isn't an override.
User contributions licensed under CC BY-SA 3.0