I'm learning assembly language on macOS 10.14, and my assembler nasm's version is 2.14.02, linker ld's version is ld64-409.12, debugger lldb's version is lldb-1000.11.38.2.
I have a source code file named test.asm
, and I use
nasm -f macho64 -F dwarf -g test.asm
ld -e _start -o test test.o -lSystem
And I use lldb to debug:
lldb test
When I want to set breakpoints at certain line like:
(lldb)b test.asm:3
It turns out that:
error: parsing line table prologue at 0x00000000 (parsing ended around 0x00000006
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
I use
nm -pa test
to check the debug information, and it turns out:
0000000000000000 - 00 0000 SO xxxx(the directory)
0000000000000000 - 00 0000 SO test.asm
000000005c70cdfd - 03 0001 OSO xxxx/test.o
0000000000001f88 - 01 0000 BNSYM
0000000000001f88 - 01 0000 FUN _start
0000000000000078 - 00 0000 FUN
0000000000000078 - 01 0000 ENSYM
0000000000002000 - 02 0000 STSYM query_string
0000000000002014 - 02 0000 STSYM out_string
0000000000002025 - 03 0000 STSYM in_char
0000000000000000 - 01 0000 SO
0000000000002000 d query_string
0000000000002014 d out_string
0000000000000011 a out_string_len
0000000000000014 a query_string_len
0000000000002025 b in_char
0000000000001000 T __mh_execute_header
0000000000001f88 T _start
U dyld_stub_binder
And if I use
dsymutil -dump-debug-map test
It turns out
---
triple: 'x86_64-apple-darwin'
binary-path: test
objects:
- filename: xxxx/test.o
timestamp: 1550896637
symbols:
- { sym: in_char, objAddr: 0x000000000000009D, binAddr: 0x0000000000002025, size: 0x00000000 }
- { sym: query_string, objAddr: 0x0000000000000078, binAddr: 0x0000000000002000, size: 0x00000000 }
- { sym: _start, objAddr: 0x0000000000000000, binAddr: 0x0000000000001F88, size: 0x00000078 }
- { sym: out_string, objAddr: 0x000000000000008C, binAddr: 0x0000000000002014, size: 0x00000000 }
...
If I use dsymutil
to pack the debug info like:
dsymutil test
And try the lldb test
again, it turns out:
warning: (x86_64) xxxx/test empty dSYM file detected, dSYM was created with an executable with no debug info.
Finally, I worked out. LLDB supports program assembled by GAS with source code using AT&T syntax. And if you really want to debug program assembled by NASM with source code using intel syntax on macOS, just use GDB.
User contributions licensed under CC BY-SA 3.0