简体   繁体   中英

Why is it that assembling/linking in one step loses debug info for my assembly source?

When I build my source code using two steps:

localhost % clang -g -c factorial.s       
localhost % clang -o factorial factorial.o

I get debug info about the assembly source.

localhost % lldb factorial
(lldb) target create "factorial"
Current executable set to '/Users/chris/Dev/assembly/learning-assembly/chapter11/factorial' (x86_64).
(lldb) source info -f factorial.s 

Lines found for file factorial.s in compilation unit factorial.s in `factorial
[0x0000000100003f89-0x0000000100003f8b): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:10
[0x0000000100003f8b-0x0000000100003f8d): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:13
[0x0000000100003f92-0x0000000100003f93): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:15
[0x0000000100003f93-0x0000000100003f95): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:16
[0x0000000100003f95-0x0000000100003f9c): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:19
[0x0000000100003f9c-0x0000000100003f9d): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:22
[0x0000000100003f9d-0x0000000100003fa1): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:25
[0x0000000100003fa1-0x0000000100003fa7): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:26
[0x0000000100003fa7-0x0000000100003faa): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:29
[0x0000000100003faa-0x0000000100003fac): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:30
[0x0000000100003fac-0x0000000100003faf): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:33
[0x0000000100003faf-0x0000000100003fb6): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:34
[0x0000000100003fb6-0x0000000100003fb8): /Users/chris/Dev/assembly/learning-assembly/chapter11/factorial.s:35
(lldb)  

If I do this in one step I don't:

localhost % clang -g -o factorial factorial.s 
localhost % lldb factorial
(lldb) target create "factorial"
Current executable set to '/Users/chris/Dev/assembly/learning-assembly/chapter11/factorial' (x86_64).
(lldb) source info -f factorial.s
error: No source filenames matched 'factorial.s'.
(lldb) 

In another example, I did the one step build from source of a main.c along with function.s. In that case lldb knew about the main.c file, but not the assembly file.

Is there an option when building in one step with clang to get it to give me dwarf info for the assembly too?

This answer is the same as the one buried in a comment, but I thought it would be easier to find it here.

TL;DR —.o debug info + executable debug map is supposed to be the same as dSYM bundle, but in the case of assembly it turns out it isn't.

The complete discussion can be found at Why is LLDB not showing debug info for my assembly file?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM