您可以设置断点,enable
并且disable
这些命令将接受一个范围。在程序执行过程中,在战略点使用这些命令和一个范围。
我假设当您提到断点#2时,您指的是断点的 gdb 编号。这是一个简单的 gdb 会话示例:
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00001ddb in main at example.c:34
2 breakpoint keep y 0x00001e00 in main at example.c:39
3 breakpoint keep y 0x00001e15 in main at example.c:40
(gdb) disable 1-3
(gdb) enable 2
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep n 0x00001ddb in main at example.c:34
2 breakpoint keep y 0x00001e00 in main at example.c:39
3 breakpoint keep n 0x00001e15 in main at example.c:40
(gdb)
现在只启用断点#2。运行程序,当执行在 #2 处中断时,重新启用所有所需的断点,范围为:
(gdb) enable 1-3
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00001ddb in main at example.c:34
2 breakpoint keep y 0x00001e00 in main at example.c:39
3 breakpoint keep y 0x00001e15 in main at example.c:40
您还可以混合断点编号和范围:
(gdb) disable 1 4 6-7
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep n 0x00001ddb in main at example.c:34
2 breakpoint keep y 0x00001e00 in main at example.c:39
3 breakpoint keep y 0x00001e15 in main at example.c:40
4 breakpoint keep n 0x00001e4f in main at example.c:43
5 breakpoint keep y 0x00001e4f in main at example.c:44
6 breakpoint keep n 0x00001e5e in main at example.c:45
7 breakpoint keep n 0x00001e5e in main at example.c:46