Skip to content

Breakpoints

Ernie Pasveer edited this page Jan 4, 2025 · 10 revisions

Introduction

Seer supports most types of breakpoints that gdb provides. Here is the supported list.

  • Breakpoints - Typical breakpoint that stops execution at a line of code.
  • Watchpoints - Stop execution if a variable is accessed (read, write, or rw)
  • Printpoints - Prints a "printf" style message at a line of code. The program then continues.
  • Catchpoints - Stop execution on these conditions.
    • C++ throw/catch
    • Shared Library load
    • Ada exception/handle

Seer does not support, yet, this type of breakpoint.

Breakpoints

The is the typical type of breakpoint. It stops the execution of your program when a location is reached. This is Seer's dialog to create a breakpoint.

image

The location of the breakpoint can be provided in one of 4 ways.

  • A filename and line number.
  • A function name. Execution stops just after function is entered.
  • A label. eg: a C/C++ label like "LOOP:". This can be used with Function for finer scoping. eg: A label withing a certain function.
  • An address. Execution stops after address is reached.

The type of breakpoint specify certain breakpoint attributes.

  • Temporary - Create a temporary breakpoint. It is deleted after the breakpoint is reached.
  • Hardware - Create a hardware based breakpoint, which is the default. Most hardware supports this but some may not. If selected, Seer will show a message saying a hardware breakpoint can't be created. Otherwise, Seer will fall back to a software breakpoint.
  • Pending - If the current debug information loaded from the executable doesn't know about the location, then still allow the breakpoint.
  • Disabled - Create the breakpoint and mark it as disabled. Can be enabled via the Breakpoints tab.
  • Condition if - Add a simple condition to the breakpoint. eg: break if loop == 10.
  • Ignore Count - Stop execution after the breakpoint has been reached N times.
  • Thread Id - The breakpoint applies to a specific thread id.

Resource on types: https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_33.html

There are 3 ways to create a breakpoint.

  • Double LMB click on a line of code will create a "quick" breakpoint.

image

  • RMB click on a line of code will bring up the breakpoint dialog.

image

  • Click on "Add a New Breakpoint" in the Breakpoint tab will bring up the breakpoint dialog.

image

The created breakpoints will appear in the Breakpoints tab. They can be further modified by the controls on the right.

image

They can also be saved to a file for later use by another debug session, and reloaded from the saved file.

image

Finally, if you LMB click on the breakpoint icon in the source editor, you can bring up the breakpoints details.

image

Watchpoints

A Watchpoint monitors if a variable is accessed. If so, the execution is stopped at the line of code, including the machine language code if the Assembly tab is shown.

There are these types of variable access methods.

  • Read - If the variable is read from.
  • Write - If the variable is written to.
  • Read/Write - If the variable is read or written to.

A message is printed to the Message tab if a Watchpoint is triggered.

Printpoints

A Printpoint is a type of breakpoint that merely prints a message when a location is reached. The message is printed and the execution resumes.

Catchpoints

A Catchpoint is a type of breakpoint that stop's the execution if a certain even is encounter.

Tracepoints

I have no clear idea what Tracepoints are. I'm looking for a good reference for them. Are they actually used by anyone?

Breakpoint Modifiers

Once a breakpoint is created, you can further modify its behavior. This applies to most types of breapoints (breakpoint, watchpoint, etc.).

Modifiers includes:

  1. Enable a previously disabled breakpoint.
  2. Disable a previously enabled breakpoint.
  3. Add a condition to a breakpoint. eg: "if x > 0"
  4. Add an ignore count. eg: don't stop until the breakpoint has been hit N times.
  5. Add a list of gdb commands to run if the breakpoint is hit.

image

Enable ("1")

This enables a breakpoint. By default, breakpoints start as enabled. If the breakpoint is reached, the execution stops if the breakpoint is enabled.

Disable ("2")

This disables a breakpoint. If the breakpoint is reached, it is ignored.

Add a Condition ("3")

Simply, this is adding an "if statement" to the breakpoint. In this example, a condition of "i > 5" will stop execution for the breakpoint only when the value of "i" is greater than 5.

image

Add an Ignore Count ("4")

Another way to skip breakpoints. An ignore count of greater than 0 will skip the first N occurrences. After that, when the breakpoint is reached, execution stops.

image

Add Commands ("5")

This adds a list of gdb commands to run when the breakpoint is triggered.

image

Check the GDB tab for the "printf" messages after you run the program.

image