mdb package

class mdb.async_client.AsyncClient(opts: AsyncClientOpts)[source]

Bases: ABC

async close() None[source]
async connect_to_exchange(msg: Message) Message[source]
async init_connection() None[source]
class mdb.async_client.AsyncClientOpts

Bases: TypedDict

connection_attempts: int
exchange_hostname: str
exchange_port: int
class mdb.async_connection.AsyncConnection(reader: StreamReader, writer: StreamWriter)[source]

Bases: object

async recv_message() Message[source]
async send_message(msg: Message) None[source]
class mdb.backend.DebugBackend[source]

Bases: ABC

abstract property argument_separator: str
abstract property debug_command: str
abstract property default_options: list[str]
abstract property float_regex: str
abstract property name: str
abstract property prompt_string: str
abstractmethod runtime_options(opts: dict[str, str]) list[str][source]
abstract property start_command: str
mdb.backend.load_plugins() None[source]
class mdb.debug_client.DebugClient(opts: dict[str, str])[source]

Bases: AsyncClient

async execute_command(message: Message, prev: Task[Any] | None) None[source]
async init_debug_proc() None[source]
async run() None[source]

Main loop of the asynchronous debugger wrapper.

class mdb.exchange_server.AsyncExchangeServer(opts: dict[str, Any])[source]

Bases: object

async client_loop(conn: AsyncConnection) None[source]
async ensure_debuggers() bool[source]
async handle_connection(reader: StreamReader, writer: StreamWriter) None[source]
async kill() None[source]
async shutdown(signame: str) None[source]

Cleanup tasks tied to the service’s shutdown.

start_server() Coroutine[Any, Any, Any][source]
mdb.mdb.run_main() None[source]

Wrapper around main function to add click environment variable support

See [here](https://click.palletsprojects.com/en/8.1.x/options/#values-from-environment-variables) for more info.

class mdb.mdb_attach.ShellOpts

Bases: TypedDict

backend_name: str
exchange_select: str
exec_script: str | None
plot_lib: str
ranks: int
mdb.mdb_attach.attach_shell(client_opts: AsyncClientOpts, plot_lib: str, script_path: None | str = None) mdbShell[source]

Attach to mdb debug server. Returns the shell instance. Intended use is for within wrappers, scripts, or tests.

For details about the arguments, see the docstring of attach.

class mdb.mdb_client.Client(opts: AsyncClientOpts)[source]

Bases: AsyncClient

async connect() None[source]

Connect to exchange server.

async run_command(command: str, select: list[int]) Message[source]
async send_interrupt(signame: str) None[source]
class mdb.mdb_launch.Server_opts

Bases: TypedDict

appfile: str
args: str
hostname: str
mpi_command: str
port: int
ranks: int
select: str
class mdb.mdb_shell.mdbShell(shell_opts: ShellOpts, client: Client)[source]

Bases: Cmd

broadcast_mode: bool = False
default(line: str) bool | None[source]

Method called on an input line when the command prefix is not recognized.

do_broadcast(line: str) None[source]

Description: Broadcast mode (bcm) sends commands to the selected ranks (see help select for more info). Broadcast mode is enabled/(disabled) by typing broadcast start/(stop). To exit broadcast mode, enter command [broadcast stop] or [quit] or press CTRL+D.

Example: The following command will start broadcast mode.

(mdb) broadcast start

do_command(line: str) None[source]

Description: Run [command] on every selected process. Alternatively, manually specify which ranks to run the command on.

Example: The following command will run “print myvar” command on every process.

(mdb) command print myvar

The following command will run “print myvar” command on processes 0,3,4 and 5.

(mdb) command 0,3-5 print myvar

do_dump(line: str) None[source]

Description: Dump variable in memory to binary file Example: The following command will dump variable [var] to a file with the name [var].dmp.[rank].

(mdb) dump [var]

do_execute(line: str) None[source]

Description: Execute commands from an mdb script file.

Example: Run commands from script file test.mdb

(mdb) execute test.mdb

do_help(arg: str) None[source]

Print help text for commands and aliases.

do_plot(line: str) None[source]

Description: Print basic statistics (min, mean, max) and produce a bar chart for a given variable [var] on all selected processes. This is intended for float/integer variables.

Example: The following command will plot a graph of variable [var] on all selected processes.

(mdb) plot [var]

do_quit(line: str) bool[source]

Description: Quit mdb.

Example: Quit the mdb debugger using the following command:

(mdb) quit

do_select(line: str) None[source]

Description: Change which rank(s) are manually controlled.

Example: Manually control ranks 0,2,3 and 4 using the following command:

(mdb) select 0,2-4

do_set(line: str) None[source]

Description: Set mdb options.

Example: Switch output format between separate and combined mode:

(mdb) set output combined (mdb) set output separate

  • separate shows all output for each rank separate by ***’s

  • combined reduces common output across the ranks

Show current settings:

(mdb) set

do_shell(line: str) None[source]

Description: Run shell (UNIX) command.

Alias [!]

Example: Run a UNIX shell command from mdb.

(mdb) !ls

execute_script(script: str, queue: bool = False) None[source]
hist_file: str = '/home/docs/.mdb_history'
hist_filesize: int = 10000
intro: str = 'mdb - mpi debugger - built on various backends. Type ? for more info. To exit interactive mode type "q", "quit", "Ctrl+D" or "Ctrl+]".'
postloop() None[source]

Override Cmd.postloop() to save mdb history.

precmd(line: str) str[source]

Override Cmd.precmd() to only run the command if debug processes are open.

preloop() None[source]

Override Cmd.preloop() to load mdb history.

class mdb.mdb_wrapper.MPI_Mode(*values)[source]

Bases: Enum

INTEL = 'Intel'
MPICH = 'MPICH'
OPENMPI = 'Open MPI'
UNSUPPORTED = 'unsupported'
class mdb.mdb_wrapper.WrapperLauncher(prog_opts: Wrapper_opts)[source]

Bases: object

launch_command() str[source]

run a gdb server on the current rank.

Parameters:
  • rank – rank on which gdb server is running.

  • start_port – starting port. Port number will be port+rank. Defaults to 2000.

  • args – binary to debug and optional list of arguments for that binary.

Returns:

None

mpi_mode: MPI_Mode
set_mpi_mode() None[source]

Set mpi_mode depending on which mpirun implementation is being used.

write_app_file() None[source]

Generate an app file for mpi launcher.

Returns:

None

class mdb.mdb_wrapper.Wrapper_opts

Bases: TypedDict

appfile: str
args: str
backend: str
connection_attempts: int
hostname: str
mpi_command: str
mpi_config_opt: str
port: int
ranks: int
redirect_stdout: str
select: str
target: str
class mdb.messages.Message(msg_type: str, data: dict[str, Any])[source]

Bases: object

data: dict[str, Any]
static debug_command_response(result: dict[int, str]) Message[source]
static debug_conn_request() Message[source]
static debug_conn_response() Message[source]
static debug_init_complete() Message[source]
static exchange_command_response(messages: list[Message]) Message[source]
static exchange_info(message: str) Message[source]
static from_json(text: bytes) Message[source]
static mdb_command_request(command: str, select: list[int]) Message[source]
static mdb_conn_request() Message[source]
static mdb_conn_response(no_of_ranks: int, backend_name: str, select_str: str) Message[source]
static mdb_interrupt_request() Message[source]
msg_type: str
static ping() Message[source]
static pong() Message[source]
to_json() bytes[source]
mdb.utils.collapse_ranges(values: list[int]) str[source]

Collapse a list of integers into minimal range notation.

e.g. [1, 2, 3, 6, 7, 10, 11, 12] -> ‘1-3,6-7,10-12’

mdb.utils.extract_float(line: str, backend: DebugBackend) float[source]
mdb.utils.parse_ranks(ranks: str) list[int][source]

Parse a string of ranks into a set of integers. E.g., parse_ranks("1,3-5") would return the following: set(1,3,4,5).

Parameters:

ranks – string of ranks using either a mix of comma separation and ranges using hyphen.

Returns:

A set of ranks represented by integers.

mdb.utils.prepend_ranks(rank: int, result: str) str[source]
mdb.utils.pretty_print_response(response: dict[int, str]) None[source]
mdb.utils.reduce_response(response: dict[int, str]) None[source]

Reduce debug output by deduplicating common lines across ranks.

Parses each rank’s output, groups identical lines together, and prints each unique line prefixed by the collapsed set of ranks that produced it. Lines from only one rank appear normally; shared lines are printed once with all contributing ranks.

Example output before and after:

Before (raw output per rank):

0: process 45402 0: cmdline = ‘/mdb/examples/simple-mpi.exe’ 0: cwd = ‘/mdb’ 0: exe = ‘/mdb/examples/simple-mpi.exe’ ******************************************************************** 1: process 45403 1: cmdline = ‘/mdb/examples/simple-mpi.exe’ 1: cwd = ‘/mdb’ 1: exe = ‘/mdb/examples/simple-mpi.exe’

After (deduplicated, ranks collapsed):

0: process 45402

0-1: cmdline = ‘/mdb/examples/simple-mpi.exe’ 0-1: cwd = ‘/mdb’ 0-1: exe = ‘/mdb/examples/simple-mpi.exe’

1: process 45403

Parameters:

response – dict mapping process rank (int) to its output string.

mdb.utils.sort_debug_response(results: dict[int, str]) dict[int, str][source]

Sort debug output by process rank.

Parameters:

response – dict containing the

Returns:

The string with bracketted paste escape sequence removed.

mdb.utils.ssl_cert_path() str[source]
mdb.utils.ssl_key_path() str[source]
mdb.utils.strip_bracketted_paste(text: str) str[source]

Strip bracketted paste escape sequence from text (see issue #669 https://github.com/pexpect/pexpect/issues/669).

Parameters:

text – string that contains bracketted paste escape sequence,

Returns:

The string with bracketted paste escape sequence removed.

mdb.utils.strip_control_characters(text: str) str[source]

Strip ANSI control characters from a string.

Parameters:

text – string that contains ANSI control characters.

Returns:

The string with ANSI control characters removed.