Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB breakpoints

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?

like image 676
Sachin Khot Avatar asked Feb 01 '09 15:02

Sachin Khot


People also ask

What are breakpoints in GDB?

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.

How do I use breakpoints in GDB?

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.

Does GDB use hardware breakpoints?

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.

What is the GDB command to set a breakpoint in line 7?

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.


1 Answers

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 ... 
like image 186
Mark Renouf Avatar answered Sep 28 '22 20:09

Mark Renouf