[insert your favorite tennis or Keanu Reeves pun here]
Breakpoints can be considered the sorcerers of debugging. Want to know if a function is giving the correct result of 42
? Set a breakpoint, and all will be revealed.
There are a few different ways to set a breakpoint. In the previously mentioned situation, where the board was paused and the function we want to set a breakpoint for is in the callstack, it's as simple as right-clicking on the function in the Call Stack window and adding the breakpoint in the Breakpoint sub-menu:
However, if you need to find a function not in the callstack there are a few options.
The easiest option is to try using the New->Function Breakpoint in the Breakpoints window. Simply type the name of the function you want to set a breakpoint for in the "Function Name" textbox, and set any conditions and actions (explained below). This method can even be used while the board is running. There is a minor downside to this method, which is detailed in the Using New Firmware section.
Another option is the Disassembly window. In the Disassembly window, you can type a function name in the "Address" combo-box and hit the Enter key.
You'll usually get lucky and it will highlight the memory address of the function. Then you can do a simple right-click and add the breakpoint. This method can only be used when the board is paused.
The last option, is the GDB Console window. I have found a few function addresses here, that weren't found in the Disassembly window.
In the GDB Command textbox, type "print" and the function name. Example: print SysTick_Handler
If GDB finds the function, it will print some info including the memory address. Then you can use either option above using the address. This method can only be used when the board is paused.
If none of these options result in a breakpoint, you might be forced to Step Over and/or Step In to find the function in the Call Stack window (have only had to this once on a deeply optimized function, so it's a low-rate occurrence).
Once you've set the breakpoint (as you may have seen, I set two for this PulseIn issue), you can customize it a little. You can do this while the target board is running; no need to pause. You can even turn them on and off while the board is running with the checkbox.
Text editor powered by tinymce.