04.06.2015 Views

Red Hat Developer Toolset 1.x User Guide - Linux

Red Hat Developer Toolset 1.x User Guide - Linux

Red Hat Developer Toolset 1.x User Guide - Linux

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

32 Chapter 3. GNU Debugger (GDB)<br />

Setting a New Breakpoint<br />

To set a new breakpoint at a certain line, run the following command:<br />

break [file_name:]line_number<br />

You can also set a breakpoint on a certain function:<br />

break [file_name:]function_name<br />

Example 3.5. Setting a New Breakpoint<br />

Assuming that you have compiled the fibonacci.c file listed in Example 3.1, “Compiling a C<br />

Program With Debugging Information” with debugging information, you can set a new breakpoint at line<br />

10 by running the following command:<br />

(gdb) break 10<br />

Breakpoint 1 at 0x4004e5: file fibonacci.c, line 10.<br />

Listing Breakpoints<br />

To display a list of currently set breakpoints, run the following command:<br />

info breakpoints<br />

Example 3.6. Listing Breakpoints<br />

Assuming that you have followed the instructions in Example 3.5, “Setting a New Breakpoint”, you can<br />

display the list of currently set breakpoints by running the following command:<br />

(gdb) info breakpoints<br />

Num Type Disp Enb Address What<br />

1 breakpoint keep y 0x00000000004004e5 in main at fibonacci.c:10<br />

Deleting Existing Breakpoints<br />

To delete a breakpoint that is set at a certain line, run the following command:<br />

clear line_number<br />

Similarly, to delete a breakpoint that is set on a certain function, run:<br />

clear function_name<br />

You can also delete all breakpoints at once. To do so, run the clear command with no additional<br />

arguments:<br />

clear

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!