I have a list of breakpoints which I want to add each time I debug a particular program.
Is there a way I can put all of the breakpoint information in a file and use it at the start of each debug session? In other words can I provide a script file with breakpoint information to GDB before I give the 'run' command?
A breakpoint makes your program stop whenever a certain point in the program is reached. For each breakpoint, you can add conditions to control in finer detail whether your program stops.
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.
This applies to breakpoints set with the break command as well as to internal breakpoints set by commands like next and finish . For breakpoints set with hbreak , GDB will always use hardware breakpoints. You can control this automatic behaviour with the following commands: set breakpoint auto-hw on.
c file listed in Example 7.1, “Compiling a C Program With Debugging Information” with debugging information, you can set a new breakpoint at line 7 by running the following command: (gdb) break 7 Breakpoint 2 at 0x4004e3: file fibonacci.
From man gdb(1):
-x file Execute GDB commands from file file.
You could then put your breakpoints in a file:
break [file:]function break [file:]function ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With