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 – The 0-or-1-indexed line in the code.

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

Returns:

The 0-indexed position in the code.

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

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

Parameters:

pos – The 0-indexed position in the code.

Returns:

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

collect_highlight_entries(failing_instruction: int, error_causes: list[ErrorCause] | None = None) list[dict[str, Any]][source]

Collect highlight entries for the current assertion failure.

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

Format an error cause for output.

Parameters:

cause – The error cause.

Returns:

The formatted error cause.

handle_assertion_fail(connection: socket) None[source]

Handles the sending of output events when an assertion fails.

Parameters:

connection – The client socket.

handle_client(connection: socket) None[source]

Handle incoming messages from the client.

Parameters:

connection – 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 – The command read from the client.

Returns:

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

Raises:

RuntimeError – If the command is not supported.

host: str
lines_start_at_one: bool
port: int
queue_parse_error(error_message: str, line: int | None = None, column: int | None = None) None[source]

Store highlight data for a parse error to be emitted later.

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, category: str = 'console') None[source]

Send a hierarchy of messages to the client.

Parameters:
  • message – An object representing the message to send. Supported keys are “title”, “body”, “end”.

  • line – The line number.

  • column – The column number.

  • connection – The client socket.

  • category – The output category (console/stdout/stderr).

send_message_simple(title: str, body: list[str] | None, end: str | None, line: int, column: int, connection: socket, category: str = 'console') None[source]

Send a simple message to the client.

Parameters:
  • title (str) – The title of the message.

  • body (list[str]) – The body of the message.

  • end (str | None) – The end of the message.

  • line (int) – The line number.

  • column (int) – The column number.

  • connection (socket) – The client socket.

  • category (str) – The output category (console/stdout/stderr).

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

Start the DAP server and listen for one connection.