程序集-无法设置断点lldb [英] Assembly - Unable to set breakpoints lldb

查看:150
本文介绍了程序集-无法设置断点lldb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这些选项nasm -O0 -g -f macho64进行组装,但是lldb抱怨无法将断点解析到任何实际位置".当我尝试在文件的行号上设置任何断点时.

I assembled with these options nasm -O0 -g -f macho64 but lldb complains of "Unable to resolve breakpoint to any actual locations." when i try to set any breakpoints at line numbers in the file.

我已经开始尝试学习OS X的64位汇编程序,但是到目前为止,这证明是一个真正的挑战,似乎几乎没有学习资源.

I've started trying to learn 64 bit assembly for OS X but it's proving a real challenge so far, there seems to be hardly any resources for learning.

推荐答案

您的汇编程序可能未针对您创建的二进制文件发出任何调试信息.您可以通过在.o文件或二进制文件的.dSYM捆绑软件上运行dwarfdump --debug-line来判断是否存在.

Your assembler probably didn't emit any debug information for the binary you created. You can tell by running dwarfdump --debug-line on your .o file or on the .dSYM bundle for your binary if there is one.

将二进制文件加载到lldb中,然后运行disassemble -n function-name命令.这将向您显示程序集-然后可以使用breakpoint set -a address设置断点.默认情况下,lldb将在关闭地址空间随机化(ASLR)的情况下运行您的二进制文件-因此,二进制文件每次都将在同一地址运行,而不是在随机地址处加载程序.

Load the binary into lldb and run the disassemble -n function-name command. That will show you the assembly - then you can set a breakpoint with breakpoint set -a address. By default lldb will run your binary with address space randomization (ASLR) turned off -- so the binary will run at the same address every time, instead of loading your program at a randomized address.

一个简单的例子:

%  echo 'int main () { }' > a.c
% clang a.c
% lldb a.out
(lldb) target create "a.out"
Current executable set to 'a.out' (x86_64).
(lldb) disass -n main
a.out`main:
a.out[0x100000fb0] <+0>: pushq  %rbp
a.out[0x100000fb1] <+1>: movq   %rsp, %rbp
a.out[0x100000fb4] <+4>: xorl   %eax, %eax
a.out[0x100000fb6] <+6>: popq   %rbp
a.out[0x100000fb7] <+7>: retq   

(lldb) br s -a 0x100000fb4
Breakpoint 1: address = 0x0000000100000fb4
(lldb) r
Process 32406 launched: '/private/tmp/a.out' (x86_64)
Process 32406 stopped
* thread #1: tid = 0x145576, 0x0000000100000fb4 a.out`main + 4, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100000fb4 a.out`main + 4
a.out`main:
->  0x100000fb4 <+4>: xorl   %eax, %eax
    0x100000fb6 <+6>: popq   %rbp
    0x100000fb7 <+7>: retq   
    0x100000fb8:      addl   %eax, (%rax)
(lldb) 

这篇关于程序集-无法设置断点lldb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆