【问题标题】:gdb set breakpoint at address, but not stopgdb 在地址处设置断点,但不停止
【发布时间】:2014-08-22 22:28:31
【问题描述】:

我使用 gdb 从可执行代码中检查程序集转储。我设置了两个断点。一个总是被击中,但下一个断点不是。我不知道为什么。我用:

   (gdb) b phase_2   
   (gdb) b *0x400ec0

设置断点,注意到 *0x400ec0 是从阶段 2 开始的 。 这是disas的结果:

         Dump of assembler code for function phase_2:
=> 0x0000000000400e8c <+0>:     mov    %rbx,-0x20(%rsp)
   0x0000000000400e91 <+5>:     mov    %rbp,-0x18(%rsp)
   0x0000000000400e96 <+10>:    mov    %r12,-0x10(%rsp)
   0x0000000000400e9b <+15>:    mov    %r13,-0x8(%rsp)
   0x0000000000400ea0 <+20>:    sub    $0x48,%rsp
   0x0000000000400ea4 <+24>:    mov    %rsp,%rsi
   0x0000000000400ea7 <+27>:    callq  0x401743 <read_six_numbers>
   0x0000000000400eac <+32>:    mov    %rsp,%rbp
   0x0000000000400eaf <+35>:    lea    0xc(%rsp),%r13
   0x0000000000400eb4 <+40>:    mov    $0x0,%r12d
   0x0000000000400eba <+46>:    mov    %rbp,%rbx
   0x0000000000400ebd <+49>:    mov    0xc(%rbp),%eax
   0x0000000000400ec0 <+52>:    cmp    %eax,0x0(%rbp)
   0x0000000000400ec3 <+55>:    je     0x400eca <phase_2+62>
   0x0000000000400ec5 <+57>:    callq  0x40163d <explode_bomb>
   0x0000000000400eca <+62>:    add    (%rbx),%r12d
   0x0000000000400ecd <+65>:    add    $0x4,%rbp
   0x0000000000400ed1 <+69>:    cmp    %r13,%rbp
   0x0000000000400ed4 <+72>:    jne    0x400eba <phase_2+46>
   0x0000000000400ed6 <+74>:    test   %r12d,%r12d
   0x0000000000400ed9 <+77>:    jne    0x400ee0 <phase_2+84>
   0x0000000000400edb <+79>:    callq  0x40163d <explode_bomb>
   0x0000000000400ee0 <+84>:    mov    0x28(%rsp),%rbx
   0x0000000000400ee5 <+89>:    mov    0x30(%rsp),%rbp
   0x0000000000400eea <+94>:    mov    0x38(%rsp),%r12
   0x0000000000400eef <+99>:    mov    0x40(%rsp),%r13
   0x0000000000400ef4 <+104>:   add    $0x48,%rsp
   0x0000000000400ef8 <+108>:   retq   
End of assembler dump.

为什么我在第一个断点后输入“c”后,它没有在第二个断点处停止?在第二个断点之前我没有看到任何可能的跳跃。谢谢!

【问题讨论】:

  • 你想要b 0x400ec0而不是b *0x400ec0吗?

标签: assembly gdb


【解决方案1】:

我明白了。该函数将有条件地跳转到 phase_2 函数的末尾。这就是程序没有在断点 2 处停止的原因。

【讨论】:

  • 条件跳转不是after你的第二个断点吗?以前没有?你确定它不只是卡在read_six_numbers 中等待输入吗?
  • 进入read_six_numbers函数后,会检查我的输入是否有6个数字,如果没有,就会调用explode_the_bomb函数,退出程序。
猜你喜欢
  • 2013-07-20
  • 2012-03-11
  • 1970-01-01
  • 1970-01-01
  • 2020-12-30
  • 2013-09-26
  • 2021-12-07
  • 2020-02-25
  • 2017-01-24
相关资源
最近更新 更多