Interface Target

interface Target {
    connect(): void;
    disconnect(): void;
    getResets(): Record<string, boolean>;
    halt(): void;
    isConnected(): boolean;
    isHalted(): boolean;
    reset(resetType?: string): void;
    run(waitForHalt?: boolean): void;
    stepInto(explicitlyAsm?: boolean): void;
    stepOut(): void;
    stepOver(explicitlyAsm?: boolean): void;
    waitForHalt(): void;
}

Methods

  • Connect or reconnect the debugger to the target.

    Returns void

    Returns once the target is connected and the debugger is idle.

    Will throw if the target target is already connected.

    // connects and disconnects from the target
    session.target.connect()
    session.target.disconnect()
  • Disconnect the debugger from the target

    Returns void

    Returns once the target is disconnected and the debugger is idle.

    Will throw if not connected to the target.

    // connects and disconnects from the target
    session.target.connect()
    session.target.disconnect()
  • Query the target's available reset types.

    Returns Record<string, boolean>

    A mapping where the keys are the reset types, and the associated values indicate whether is it currently valid to issue a reset of this type.

    // Get a list of the resets which can currently be performed
    let resets = session.target.getResets();
    // This might look like
    // resets = {
    // "CPU Reset": true,
    // "Board Reset": false
    // }
    let allowedResets = Object.keys(resets).filter((reset) => resets[reset]);
    // allowedResets = ["CPU Reset"];
  • Halt the target.

    Returns void

    Returns immediately if the target is already halted.

    session.target.halt();
    
  • Query if the target is connected

    Returns boolean

    session.target.connect();
    let status = session.target.isConnected(); // will be true
    session.target.disconnect();
    status = session.target.isConnected(); // will be false
  • Query if the target is halted.

    Returns boolean

    session.target.halt();
    let status = session.target.isHalted(); // will be true
    session.target.run(false);
    status = session.target.isHalted(); // will be false
  • Issue the specified reset on the target

    Parameters

    • OptionalresetType: string

      The type of reset to be issued. If not provided, the default reset is issued.

    Returns void

    Returns once the debugger is idle.

    If the reset requires the target to be halted, use Target.halt or Target.waitForHalt.

    Does not throw if the reset fails.

    // Issue the System Reset (possible reset types vary by target)
    session.target.reset("System Reset");
  • Issue a run command to the target, and wait until it has halted.

    Parameters

    • OptionalwaitForHalt: boolean

      Whether the command should wait until the target halts. Defaults to true.

    Returns void

    By default, this will wait until the target has halted after running. If waitForHalt is false this will return as soon as the target begins to run.

    Will throw if the target is not halted.

    // run to foo
    session.breakpoints.add("foo");
    session.target.run();

    // run and return once the target is running
    session.target.run(false);
  • Steps the target, stepping into function calls. Returns once the step operation is completed and the target is once again halted.

    If symbol information is loaded for the location at which the target is currently halted, then a source step is performed. Otherwise, or if explicitly ordered to do so, an assembly step is performed.

    Parameters

    • OptionalexplicitlyAsm: boolean

      If true, an assembly step into operation will always be performed regardless of loaded symbols

    Returns void

    Will throw if the target is not halted.

    // source step into (assuming symbol information is loaded for the target's current location)
    session.target.stepInto();

    // explicit assembly step into
    session.target.stepInto(true);
  • Steps the target, stepping out of the current function. Returns once the step operation is completed and the target is once again halted.

    Returns void

    Will throw if the target is not halted.

    This operation requires symbol imformation to be loaded for the location at which the target is currently halted.

    session.target.stepOut();
    
  • Steps the target, stepping over function calls. Returns once the step operation is completed and the target is once again halted.

    If symbol information is loaded for the location at which the target is currently halted, then a source step is performed. Otherwise, or if explicitly ordered to do so, an assembly step is performed.

    Parameters

    • OptionalexplicitlyAsm: boolean

      If true, an assembly step over operation will always be performed regardless of loaded symbols

    Returns void

    Will throw if the target is not halted.

    // source step over (assuming symbol information is loaded for the target's current location)
    session.target.stepOver();

    // explicit assembly step over
    session.target.stepOver(true);
  • Waits until the target has halted for any reason.

    Returns void

    // run the target and separately wait until it is halted
    session.target.run(false);
    session.target.waitForHalt();