gpt4 book ai didi

程序集 - lldb 在 macOS 上找不到正确的调试信息

转载 作者:行者123 更新时间:2023-12-02 21:37:42 24 4
gpt4 key购买 nike

我正在 macOS 10.14 上学习汇编语言,我的汇编器 nasm 的版本是 2.14.02,链接器 ld 的版本是 ld64-409.12,调试器 lldb 的版本是 lldb-1000.11.38.2。

我有一个名为 test.asm 的源代码文件,我用

nasm -f macho64 -F dwarf -g test.asm
ld -e _start -o test test.o -lSystem

我使用 lldb 来调试:

lldb test

当我想在某行设置断点时,例如:

(lldb)b test.asm:3

事实证明:

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.

我用

nm -pa test

查看调试信息,结果是:

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

如果我使用

dsymutil -dump-debug-map test

事实证明

---
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 }
...

如果我使用dsymutil打包调试信息,例如:

dsymutil test

并尝试 lldb test事实证明:

warning: (x86_64) xxxx/test empty dSYM file detected, dSYM was created with an executable with no debug info.

最佳答案

终于,我锻炼了。 LLDB支持GAS使用AT&T语法用源代码组装的程序。而如果你确实想在 macOS 上使用 intel 语法调试 NASM 用源代码组装的程序,只需使用 GDB 即可。

关于程序集 - lldb 在 macOS 上找不到正确的调试信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54838553/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com