Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify the line of a breakpoint in gdb?

I set a breakpoint and set its conditions and some other commands. Now I realize that I should had set it a few lines ahead. How can I change the line of the breakpoint without deleting it and losing its settings?

like image 677
Gabriel Diego Avatar asked May 07 '16 01:05

Gabriel Diego


People also ask

How do you set a breakpoint in gdb at a specific line?

Setting breakpoints A breakpoint is like a stop sign in your code -- whenever gdb gets to a breakpoint it halts execution of your program and allows you to examine it. To set breakpoints, type "break [filename]:[linenumber]". For example, if you wanted to set a breakpoint at line 55 of main.

How do you create a breakpoint on a specific line?

You can create a breakpoint at an offset from the current stopped position with gdb breakpoint +<offset> . You can also create a breakpoint on a specific line number using either gdb break <linenumber> (for the current source file) or gdb break <filename>:<linenumber> (for a file other than the current file).

Does breakpoint execute the line?

The breakpoint will stop your program just before it executes any of the code on that line. Set a breakpoint at line linenum in source file filename . Set a breakpoint at entry to function function found in file filename .


1 Answers

How can I change the line of the breakpoint without deleting it and losing its settings?

You can't.

What you can do is use save breakpoints /tmp/bp.txt command to save current settings for all breakpoints, edit the /tmp/bp.txt file to update the line info (or anything else), and finally delete to remove current breakpoints and source /tmp/bp.txt to reload them.

like image 68
Employed Russian Avatar answered Oct 13 '22 17:10

Employed Russian