NEW RESEARCH REPORT: Overcoming the limitations of coding agents in complex software systems

Products

Pricing

Solutions

Customers

Resources

Company

Products

Pricing

Solutions

Customers

Resources

Company

WatchPoint

GDB breakpoints commands

Introduction

Sometimes you want to execute a command or sequence of commands every time a breakpoint is hit.

GDB let’s you do this using:

commands [NUMBER]

…where [NUMBER] is the identifier of the breakpoint that you are interested in.

This will give you a secondary prompt where you can type any valid GDB commands. Once you’ve finished entering the commands to be executed, type end to return to the regular GDB prompt.

For example, if you’ve set a breakpoint (1) and want to print the call stack with variables you can do:

commands 1

You are then prompted with:

Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".

So you type:

where full
end

The commands you just entered will now be executed whenever the specified breakpoint is hit.

For an extra tip: You can use the extra command silent if you want to suppress normal breakpoint output when the breakpoint is hit.

Want debugging tips directly in your inbox?

Sure, why not?

Become a C/C++ Debugging Ninja.

Get debugging tutorials straight to your inbox

Become a C/C++ Debugging Ninja.

Get debugging tutorials straight to your inbox

Become a C/C++ Debugging Ninja.

Get debugging tutorials straight to your inbox