如何使用GDB删除单个断点?


143

我可以在GDB中添加一个断点:

b <filename>:<line no>

如何在特定位置删除现有断点?


您是否尝试过D <filename>:<lino no>?
Eineki

不幸的是,否:它产生一个错误:“警告:'<file>:<no>'或附近的坏的断点编号”
Chris Smith,2010年

1
@Eineki是断点号,不是行号。喜欢:d <filename>:<breakpoint no>
凯文

Answers:



281

您可以使用以下方式列出断点:

info break

这将列出所有断点。然后可以通过相应的编号删除断点:

del 3

例如:

 (gdb) info b
 Num     Type           Disp Enb Address    What
  3      breakpoint     keep y   0x004018c3 in timeCorrect at my3.c:215
  4      breakpoint     keep y   0x004295b0 in avi_write_packet atlibavformat/avienc.c:513
 (gdb) del 3
 (gdb) info b
 Num     Type           Disp Enb Address    What
  4      breakpoint     keep y   0x004295b0 in avi_write_packet atlibavformat/avienc.c:513

3
您也可以缩写info breaki b
Nickolai,2017年

22

您可以使用删除所有断点

del <start_breakpoint_num> - <end_breakpoint_num>

要查看start_breakpoint_numend_breakpoint_num,请使用:

info break

4

用:

clear fileName:lineNum   // Removes all breakpoints at the specified line.
delete breakpoint number // Delete one breakpoint whose number is 'number'
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.