GDB:捕获信号并继续调试 [英] GDB: catching a signal and continue debugging

查看:253
本文介绍了GDB:捕获信号并继续调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在GDB中捕获浮点异常(SIGFPE),而不是将其传递给进程并继续进行调试. 我已经给了gdb:

I am trying to catch floating point exception (SIGFPE) in GDB, not pass it to the process and continue debugging onwards. I have given gdb this:

handle SIGFPE stop nopass

发生SIGFPE时,GDB会停在正确的位置.问题是我不能也不知道如何继续调试. 我曾经尝试过给GDB

When a SIGFPE occurs GDB stops at the correct place. The problem is I can't and don't know how can I continue debugging. I have tried giving GDB

continue

signal 0

但它仍然挂在违规行上,并拒绝继续.

but it still hangs on the offending line and refuses to continue.

有没有办法在收到信号后继续调试?

Is there a way to continue debugging after receiving a signal?

我正在使用自己编译的GDB 7.5.1,并且还尝试了12.04 Ubuntu发行版随附的GDB 7.4.两者具有相同的行为.

I am using GDB 7.5.1, which I have compiled myself and I have also tried with GDB 7.4, which comes with my 12.04 Ubuntu distribution. Both have the same behaviour.

推荐答案

问题是,当您在同步信号后继续执行程序时,它会重新执行引起该信号的同一条指令,这意味着您只会得到该信号再次.如果您告诉它忽略信号(直接或通过gdb),它将进入紧密循环,重复执行该指令.

The problem is that when you continue a program after a synchronous signal, it reexecutes the same instruction that caused the signal, which means you'll just get the signal again. If you tell it to ignore the signal (either directly or via gdb) it will go into a tight loop reexecuting that instruction repeatedly.

如果要在导致信号的指令之后实际继续执行程序,则需要在发出continue命令之前将$pc寄存器手动设置为下一条(或其他)指令.

If you want to actually continue the program somewhere after the instruction that causes the signal, you need to manually set the $pc register to the next (or some other) instruction before issuing the continue command.

这篇关于GDB:捕获信号并继续调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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