mqt.debugger.dap

This module handles DAP capabilities of the debugger.

class DAPServer(host: str = '127.0.0.1', port: int = 4711)[source]

Bases: object

The DAP server class.

can_step_back: bool
code_coordinates_to_pos(line: int, col: int) int[source]

Helper method to convert a code line and column to its position idnex.

Parameters:
  • line (int) – The 0-or-1-indexed line in the code.

  • col (int) – The 0-or-1-indexed column in the line.

Returns:

The 0-indexed position in the code.

Return type:

int

code_pos_to_coordinates(pos: int) tuple[int, int][source]

Helper method to convert a code position to line and column.

Parameters:

pos (int) – The 0-indexed position in the code.

Returns:

The line and column, 0-or-1-indexed.

Return type:

tuple[int, int]

columns_start_at_one: bool
exception_breakpoints: list[str]
format_error_cause(cause: ErrorCause) str[source]

Format an error cause for output.

Parameters:

cause (ErrorCause) – The error cause.

Returns:

The formatted error cause.

Return type:

str

handle_assertion_fail(connection: socket) None[source]

Handles the sending of output events when an assertion fails.

Parameters:

connection (socket) – The client socket.

handle_client(connection: socket) None[source]

Handle incoming messages from the client.

Parameters:

connection (socket) – The client socket.

handle_command(command: dict[str, Any]) tuple[dict[str, Any], DAPMessage][source]

Handle an incoming command from the client and return the corresponding response.

Parameters:

command (dict[str, Any]) – The command read from the client.

Raises:

RuntimeError – If the command is not supported.

Returns:

The response to the message as a dictionary and the message object.

Return type:

tuple[dict[str, Any], DAPMessage]

host: str
lines_start_at_one: bool
port: int
regular_checks(connection: socket) None[source]

Perform regular checks and send events to the client if necessary.

Parameters:

connection (socket) – The client socket.

send_message_hierarchy(message: dict[str, str | list[Any] | dict[str, Any]], line: int, column: int, connection: socket) None[source]

Send a hierarchy of messages to the client.

Parameters:
  • message (dict[str, str | list[str], dict[str, Any]]) – An object representing the message to send. Supported keys are “title”, “body”, “end”.

  • line (int) – The line number.

  • column (int) – The column number.

  • connection (socket) – The client socket.

simulation_state: SimulationState
source_code: str
source_file: dict[str, Any]
start() None[source]

Start the DAP server and listen for one connection.