Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
奇怪的lldb行为(与gdb相比)C_C_Macos_Debugging_Gdb_Lldb - Fatal编程技术网

奇怪的lldb行为(与gdb相比)C

奇怪的lldb行为(与gdb相比)C,c,macos,debugging,gdb,lldb,C,Macos,Debugging,Gdb,Lldb,我来自freebsd,我习惯于用GDB进行调试,不幸的是,GDB在我的macbook上不是natif,我想用LLDB进行调试 不幸的是,我不理解这种奇怪的行为: 当我启动一个C程序,在一个函数上设置一个断点,然后使用“run”启动它时,我转到断点,但看起来我可以通读,但在汇编代码中=硬调试,不像GDB中那样,它是一行接一行=>轻松调试 看看.c,(我知道这段代码很糟糕,但这不是重点,它只是为了尝试正确设置lldb) main函数仅包含对此函数的调用,并返回0 看看我使用lldb在ft_count

我来自freebsd,我习惯于用GDB进行调试,不幸的是,GDB在我的macbook上不是natif,我想用LLDB进行调试

不幸的是,我不理解这种奇怪的行为:

当我启动一个C程序,在一个函数上设置一个断点,然后使用“run”启动它时,我转到断点,但看起来我可以通读,但在汇编代码中=硬调试,不像GDB中那样,它是一行接一行=>轻松调试

看看.c,(我知道这段代码很糟糕,但这不是重点,它只是为了尝试正确设置lldb)

main函数仅包含对此函数的调用,并返回0

看看我使用lldb在ft_count_point上设置断点时得到的结果:

(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) settings set -- target.run-args  "tests/error1"
(lldb) b ft_count_point
Breakpoint 1: where = a.out`ft_count_point + 35
    at ft_count_point.c:5, address = 0x00000001000073e3
(lldb) r
Process 17302 launched: './a.out' (x86_64)
AddressSanitizer debugger support is active. Memory error breakpoint
has been installed and you can now use the 'memory history' command.
Process 17302 stopped
* thread #1: tid = 0x43c1e7, 0x00007fff5fc01000 dyld`_dyld_start,
                   stop reason = exec
    frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
->  0x7fff5fc01000 <+0>: popq   %rdi
    0x7fff5fc01001 <+1>: pushq  $0x0
    0x7fff5fc01003 <+3>: movq   %rsp, %rbp
    0x7fff5fc01006 <+6>: andq   $-0x10, %rsp
(lldb)目标创建“/a.out”
当前可执行文件设置为“./a.out”(x86_64)。
(lldb)设置--target.run-args“tests/error1”
(lldb)b英尺计数点
断点1:where=a.out`ft\u count\u point+35
在ft_count_point.c:5处,地址=0x00000001000073e3
(lldb)r
已启动进程17302:“./a.out”(x86_64)
AddressSanitizer调试器支持处于活动状态。内存错误断点
已安装,您现在可以使用“内存历史记录”命令。
进程17302已停止
*线程#1:tid=0x43c1e7,0x00007fff5fc01000 dyld`\u dyld\u start,
停止原因=执行
帧#0:0x00007fff5fc01000 dyld`\u dyld\u开始
dyld`\u dyld\u开始:
->0x7fff5fc01000:popq%rdi
0x7fff5fc01001:pushq$0x0
0x7fff5fc01003:movq%rsp,%rbp
0x7fff5fc01006:andq$-0x10,%rsp

我可以一步一步地说,但说真的,这是浪费时间。

看起来像是你的程序重新执行本身——也许这实际上是ASAN为你做的事情?您可以在lldb输出中看到这一点,其中显示:

* thread #1: tid = 0x43c1e7, 0x00007fff5fc01000 dyld`_dyld_start,
                   stop reason = exec
如果您实际命中了断点,则原因可能是
stop reason=breakpoint 1.1
或任何合适的断点编号

在lldb中,我们在重新执行时停止,我猜gdb自动在执行后继续,这就是为什么您在gdb中没有注意到这一点。您应该能够继续,并且您将在一段时间内到达真正的断点


最好有一个设置来控制是否继续执行exec。请随时向lldb.llvm.org bug reporter提交bug。

您是否在可执行文件中启用了符号调试信息?我不知道,它是否与我的~/.lldbinit配置文件有关?您确实有调试信息。因为lldb为您的断点找到了一个文件和行号,所以您可以分辨出来。如果您没有调试信息,它将只是一个地址。我在macOS上调试arducopter时看到了这一点。现在有没有办法防止这种情况发生?它快把我逼疯了!啊,我明白了
* thread #1: tid = 0x43c1e7, 0x00007fff5fc01000 dyld`_dyld_start,
                   stop reason = exec