226

I can add a breakpoint in GDB with:

b <filename>:<line no> 

How can I remove an existing breakpoint at a particular location?

4
  • have you tried D <filename>:<lino no> ? Commented Dec 2, 2010 at 22:42
  • 1
    Unfortunately no: It produces an error: "warning: bad breakpoing number at or near '<file>:<no>'" Commented Dec 2, 2010 at 22:49
  • 1
    @Eineki it's the breakpoint no., not the line no. like : d <filename>:<breakpoint no>. Commented Oct 7, 2013 at 16:17
  • Wouldn't it be nice if break worked as a toggle? Commented Jan 8 at 11:26

5 Answers 5

397

You can list breakpoints with:

info break 

This will list all breakpoints. Then a breakpoint can be deleted by its corresponding number:

del 3 

For example:

 (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 
Sign up to request clarification or add additional context in comments.

3 Comments

You can also abbreviate info break to i b
you can also delete multiple breakpoints like "(gdb) del 3 4 5"
Or you can even use ranges as in del 1-4
148

Try these (reference):

clear linenum clear filename:linenum 

Comments

28

You can delete all breakpoints using

del <start_breakpoint_num> - <end_breakpoint_num> 

To view the start_breakpoint_num and end_breakpoint_num use:

info break 

1 Comment

But that wasn't the question: "...remove an existing breakpoint at a particular location"
12

Use:

clear fileName:lineNum // Removes all breakpoints at the specified line. delete breakpoint number // Delete one breakpoint whose number is 'number' 

Comments

2

To delete the breakpoint at the current line you can also run clear without any arguments:

clear 

Handy for when you hit something you didn't want to hit.

TODO any way to disable instead of deleting without typing the line number? disable without arguments just disables all breakpoints. I wish I could disable . or something like that.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.