Interface Breakpoints

interface Breakpoints {
    add(locationExprOrSrcFile: Address, line?: number): number;
    addWithProperties(id: number): number;
    createProperties(type?: number): number;
    getDetailedProperties(id: number): BreakpointProperty[];
    getProperty(id: number, propertyId: string): string | bigint | boolean;
    remove(id: number): void;
    removeAll(): void;
    setProperty(id: number, propertyId: string, value:
        | string
        | number
        | bigint
        | boolean): void;
    setPropertySourceLocation(id: number, propertyId: string, filepath: string, line: number): void;
}

Methods

  • Adds a breakpoint at the specified location. The location can be an address, a symbolic expression, or a source file and line number

    Parameters

    • locationExprOrSrcFile: Address

      Either an expression that evaluates to the location or a source file. The source file can be specified as the full path to the file at compilation time, or as just the file name. In the latter case, the breakpoint will be set in the first source file with a matching name.

    • Optionalline: number

      The line number. If provided, the first argument must be a source file.

    Returns number

    An index identifying the breakpoint created

    Will throw if breakpoint location cannot be resolved.

    // Adds a breakpoint at 0x2400
    let id = session.breakpoints.add(0x2400n);

    // Adds a breakpoint at symbol 'main'
    let id = session.breakpoints.add("main");

    // Adds a breakpoint at an offset from symbol 'main'
    let id = session.breakpoints.add("main + 0x8");

    // Adds a breakpoint at line 24 of main.c
    let id = session.breakpoints.add("C:/my_project/source/main.c", 24);
    // or if we know there is only one main.c
    let id = session.breakpoints.add("main.c", 24);
  • Add a breakpoint based on properties that have been set in advance. A set of breakpoint properties can be created using createProperties

    Parameters

    • id: number

      The index identifying the set of breakpoint properties

    Returns number

    An index identifying the breakpoint created

    const propsId = session.breakpoints.createProperties();
    //
    // Configure properties...
    //
    let id = session.breakpoint.addWithProperties( propsId );
  • Creates a new set of breakpoint properties. A breakpoint can later be created from this set of properties using addWithProperties. Only one breakpoint can be added with each set of properties. Properties must be configured before calling addWithProperties.

    Parameters

    • Optionaltype: number

      The type of breakpoint to create properties for. 0 for a software breakpoint, 1 for a hardware breakpoint (if supported). Defaults to a software breakpoint.

    Returns number

    An index identifying the set of properties

    Will throw if the breakpoint type is not valid

    let id = session.breakpoints.createProperties();
    
  • Get a detailed list of all breakpoint properties currently available in the specified set of properties. Configuring some properties can cause other properties to become available or become unavailable.

    Parameters

    • id: number

      The index identifying the set of breakpoint properties. This index is obtained from createProperties.

    Returns BreakpointProperty[]

    A list of objects which detail each breakpoint property

    let id = session.breakpoints.createProperties();
    let properties = session.breakpoints.getDetailedProperties(id);

    // print details of properties
    for (const prop of properties) {
    console.log(`${prop.id}:`);
    console.log(` type: ${prop.type}`);
    console.log(` description: ${prop.description}`);
    console.log(` value: ${prop.value}`);
    if (prop.allowedValues) {
    console.log(` allowedValues: ${JSON.stringify(prop.allowedValues)}`);
    }
    if (prop.allowedRange) {
    console.log(` allowedRange: [${prop.allowedRange.min}, ${prop.allowedRange.max}]`);
    }
    console.log("");
    }
  • Get the value of a specific breakpoint property

    Parameters

    • id: number

      The index identifying the set of breakpoint properties. This index is obtained from createProperties.

    • propertyId: string

      The identifier for the desired property

    Returns string | bigint | boolean

    The value of the property

    Will throw if the property does not exist

    // Get the value of the Skip Count property. This is an integral value
    let skipCount = session.breakpoints.getProperty(id, "Debugger Response.Skip Count");

    // Get the breakpoint's location
    let location = session.breakpoints.getProperty(id, "Hardware Configuration.Location");
    // location might be an integral value (e.g. 0x1000n)
    // it might also be a string if the location is a symbolic expression (e.g. "main + 0x8") or
    // a source-based location (e.g. "C:/my_project/Debug/my_project.out@C:/my_project/main.c, line 12")
  • Removes a breakpoint

    Parameters

    • id: number

      The index identifying the breakpoint to be removed

    Returns void

    Will throw if the breakpoint does not exist

    // Adds and then removes a breakpoint
    let id = session.breakpoints.add(0x2400n);
    session.breakpoints.remove(id);
  • Removes all user created breakpoints

    Returns void

    session.breakpoint.removeAll();
    
  • Set the value of a specific breakpoint property. You can only configure properties before they are used to add a breakpoint.

    Parameters

    • id: number

      The index identifying the set of breakpoint properties. This index is obtained from createProperties.

    • propertyId: string

      The identifier for the desired property

    • value:
          | string
          | number
          | bigint
          | boolean

      The new value of the property

    Returns void

    Will throw if the property does not exist, the provided value cannot be set on the property, or if a breakpoint has already been added with this set of properties.

    // Set the Skip Count property to 5
    session.breakpoints.setProperty(id, "Debugger Response.Skip Count", 5);

    // Set the location to a symbolic expression
    session.breakpoints.setProperty(id, "Hardware Configuration.Location", "main + 0x8");
  • Set the value of a location property to a source file and line number

    Parameters

    • id: number

      The index identifying the set of breakpoint properties. This index is obtained from createProperties.

    • propertyId: string
    • filepath: string

      Like for add this can be either the full path to the file at compilation time, or as just the file name. In the latter case, the breakpoint will be set in the first source file with a matching name.

    • line: number

      The line number

    Returns void

    Will throw if the property does not exist, is not a location property, or if a breakpoint has already been added with this set of properties.

    // Set the location property to line 24 of our project's main.c file
    session.breakpoints.setPropertySourceLocation(id, "Hardware Configuration.Location", "C:/my_project/source/main.c", 24);
    // or if we know there is only one main.c
    session.breakpoints.setPropertySourceLocation(id, "Hardware Configuration.Location", "main.c", 24);