9.2.12 __builtin_software_breakpoint Builtin

A builtin function that triggers a software breakpoint.

  • Usable with all devices but has no effect when used with 8-bit Baseline PIC targets.

Include

<xc.h>

Prototype

void __builtin_software_breakpoint(void);

Remarks

This is an inbuilt function that is expanded by the code generator. When called, this routine unconditionally triggers a software breakpoint when the code is executed using a debugger.

The software breakpoint code is only generated for mid-range and PIC18 devices. Baseline devices do not support software breakpoints in this way, and the builtin will be ignored if used with these devices.

Example

The following example shows different types of breakpoints added to an MCC-generated function.
#include <xc.h>

static i2c1_fsm_states_t I2C1_DO_BUS_COLLISION(void)
{
  // Clear bus collision status flag
  I2C1_MasterClearIrq();

  I2C1_Status.error = I2C1_FAIL;
  switch (I2C1_Status.callbackTable[I2C1_WRITE_COLLISION](I2C1_Status.callbackPayload[I2C1_WRITE_COLLISION])) {
  case I2C1_RESTART_READ:
    return I2C1_DO_SEND_RESTART_READ();
  case I2C1_RESTART_WRITE:
    __debug_break();                 /* break when debugging only */
    return I2C1_DO_SEND_RESTART_WRITE();
  default:
    __builtin_software_breakpoint(); /* unconditional break */
    return I2C1_DO_RESET();
  }
}