1

When debugging a C++ program emit a SIGSEGV with gdb,it is possible to handle the signal and asked to nostop.

How gdb handles this kind of scenario ??

Have searched gdb source code and couldn't find a starting point.

Rimash Mohomed
  • 143
  • 1
  • 12

3 Answers3

1

You cannot automatically ignore SIGSEGV. I also wouldn't recommend doing that anyway. Although you can make gdb ignore the signal and not pass it to the program, the kernel will attempt to re-run the offending instruction once the signal handler returns and results in an infinite loop. See this answer for more information.

One way to work around it is to the skip the instruction or change register values so that it does not segfault. The link shows an example of setting a register. You can also use the jump command to skip over an instruction.

Community
  • 1
  • 1
Kurt Stutsman
  • 3,994
  • 17
  • 23
1

is possible to handle the signal and asked to nostop.

It's unclear whether you want GDB to handle the signal, or the program itself.

If the latter, gdb handle SIGSEGV nostop noprint pass will do exactly that.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
0

This is actually something the OS does. On Windows, if a program has a debugger attached and an exception is thrown, Windows will ask the debugger if it wants to handle it. If/when it declines, it passes it to the program. If the program doesn't handle it, Windows passes it to the debugger again.

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56