0

ブレークポイントに到達するのに時間がかかる長時間実行プログラムがあります。gdbの別のインスタンスに基づいて、何かを検査するために以前にどこかで停止したいので、ブレークポイントに向かう途中のgdbを一時停止し、別のブレークポイントを挿入して再開したいと思います。Ctrl+を実行した場合プログラムを中断するCで、最初から再起動する必要があります。これを行う方法はありますか?

4

1 に答える 1

4

if I do Ctrl+C that interrupts my program and i have to restart from the beginning

It does not (normally) interrupt your program, it should only interrupt the GDB itself. If you continue from that point, the program will continue without receiving SIGINT.

Example:

int main()
{
  int i = 0;
  while (1) {
    sleep(1);
    i += 1;
  }
}

gdb ./a.out
(gdb) run
Starting program: /tmp/a.out 
^C
Program received signal SIGINT, Interrupt.
0x00007ffff7b03b10 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82
(gdb) bt
#0  0x00007ffff7b03b10 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82
#1  0x00007ffff7b039a0 in __sleep (seconds=<optimized out>) at ../sysdeps/unix/sysv/linux/sleep.c:138
#2  0x0000000000400542 in main () at t.c:5
(gdb) fr 2
#2  0x0000000000400542 in main () at t.c:5
5       sleep(1);
(gdb) print i
$1 = 1
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x00007ffff7b03b10 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82
(gdb) bt
#0  0x00007ffff7b03b10 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:82
#1  0x00007ffff7b039a0 in __sleep (seconds=<optimized out>) at ../sysdeps/unix/sysv/linux/sleep.c:138
#2  0x0000000000400542 in main () at t.c:5
(gdb) fr 2
#2  0x0000000000400542 in main () at t.c:5
5       sleep(1);
(gdb) print i
$2 = 4
(gdb) q
于 2012-10-11T15:31:12.897 に答える