【问题标题】:What can cause gdb to not stop on a breakpoint?什么会导致 gdb 不在断点处停止?
【发布时间】:2021-12-07 07:08:05
【问题描述】:

我在 gdb 中的函数标签上放置了一个断点。 这个断点被多次命中,但这是最后一次 - 它被错过并且发生了分段错误。

什么可能导致 gdb 不在断点处停止? 上次为什么没有停在 1018 行?

(gdb) b ambl_test_event_processor
Breakpoint 1 at 0x5852d6e0: file code/comn/ambl/ambltest.c, line 1018.
(gdb) c
Continuing.
[LWP 1139 exited]
[Switching to LWP 1148]

Thread 39 "Metaswitch_0_3" hit Breakpoint 1, ambl_test_event_processor (ambl_data=0x72f97b28, mib_data=0x7922b8f4, req_data=0x7280e784, row_cb=0x0, 
    rc=1, ambl_replication=0 '\000') at code/comn/ambl/ambltest.c:1018
1018    code/comn/ambl/ambltest.c: No such file or directory.
(gdb) c 
Continuing.
[Switching to LWP 1151]

Thread 42 "Metaswitch_0_6" hit Breakpoint 1, ambl_test_event_processor (ambl_data=0x72ff9508, mib_data=0x7932bda0, req_data=0x7280e71c, row_cb=0x0, 
    rc=1, ambl_replication=0 '\000') at code/comn/ambl/ambltest.c:1018
1018    in code/comn/ambl/ambltest.c
(gdb) c
Continuing.
[Switching to LWP 1145]

Thread 36 "Metaswitch_0_0" hit Breakpoint 1, ambl_test_event_processor (ambl_data=0x72efb544, mib_data=0x7280b4e4, req_data=0x7280e6e8, row_cb=0x0, 
    rc=1, ambl_replication=0 '\000') at code/comn/ambl/ambltest.c:1018
1018    in code/comn/ambl/ambltest.c
(gdb) c
Continuing.
[Switching to LWP 1150]

Thread 41 "Metaswitch_0_5" hit Breakpoint 1, ambl_test_event_processor (ambl_data=0x72ffbc8c, mib_data=0x79622694, req_data=0x7280e750, row_cb=0x0, 
    rc=1, ambl_replication=0 '\000') at code/comn/ambl/ambltest.c:1018
1018    in code/comn/ambl/ambltest.c
(gdb) 
Continuing.

Thread 42 "Metaswitch_0_6" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 1151]
0x5852d996 in ambl_test_event_processor (ambl_data=0x0, mib_data=0x7932bda0, req_data=0x7280e71c, row_cb=<optimized out>, rc=<optimized out>, 
    ambl_replication=0 '\000') at code/comn/ambl/ambltest.c:1568
1568    in code/comn/ambl/ambltest.c

【问题讨论】:

  • 可能很简单,您的代码没有到达那个地方。 SV 发生得更早。
  • 它是从代码中的不同点调用的,其中一些参数已被优化。 ambl_data 是被取消引用的指针吗?
  • @0___________,有没有办法知道 SV 发生在哪里?根据 gdb 它发生在第 1568 行... gdb 在这里错了吗?
  • @ThomasJager 是的,它在第 1568 行被取消引用
  • @manishma 看起来你正在传递NULL。您正在取消引用它并导致SIGSEGV。看起来调用代码甚至不需要处理所有参数,因为它知道它会出现段错误。

标签: c segmentation-fault gdb


【解决方案1】:

什么可能导致 gdb 不在断点处停止?上次为什么没有停在 1018 行?

你没有证明它没有。

你有:

Thread 42 "Metaswitch_0_6" hit Breakpoint 1
Thread 36 "Metaswitch_0_0" hit Breakpoint 1,
Thread 41 "Metaswitch_0_5" hit Breakpoint 1,
Thread 42 "Metaswitch_0_6" received signal SIGSEGV

no 表明线程 42 已完成在遇到断点后运行 ambl_test_event_processor(),然后以某种方式跳过该断点,然后崩溃。

更有可能是它到达断点(然后一些其他线程也到达它,但这无关紧要),然后崩溃。

【讨论】:

    猜你喜欢
    • 2013-07-20
    • 1970-01-01
    • 2017-01-24
    • 2020-12-30
    • 2013-09-26
    • 1970-01-01
    • 2012-01-07
    • 2012-03-11
    • 1970-01-01
    相关资源
    最近更新 更多