Skip to content

commands ¤

Modules:

Classes:

Functions:

Attributes:

log module-attribute ¤

log = getLogger(__name__)

T module-attribute ¤

T = TypeVar('T')

P module-attribute ¤

P = ParamSpec('P')

commands module-attribute ¤

commands: list[CommandObj] = []

command_names module-attribute ¤

command_names: set[str] = set()

GDB_BUILTIN_COMMANDS module-attribute ¤

GDB_BUILTIN_COMMANDS = commands()

pwndbg_is_reloading module-attribute ¤

pwndbg_is_reloading = False

CommandCategory ¤

Bases: str, Enum

Attributes:

START class-attribute instance-attribute ¤

START = 'Start'

NEXT class-attribute instance-attribute ¤

NEXT = 'Step/Next/Continue'

CONTEXT class-attribute instance-attribute ¤

CONTEXT = 'Context'

PTMALLOC2 class-attribute instance-attribute ¤

PTMALLOC2 = 'GLibc ptmalloc2 Heap'

JEMALLOC class-attribute instance-attribute ¤

JEMALLOC = 'jemalloc Heap'

BREAKPOINT class-attribute instance-attribute ¤

BREAKPOINT = 'Breakpoint'

MEMORY class-attribute instance-attribute ¤

MEMORY = 'Memory'

STACK class-attribute instance-attribute ¤

STACK = 'Stack'

REGISTER class-attribute instance-attribute ¤

REGISTER = 'Register'

PROCESS class-attribute instance-attribute ¤

PROCESS = 'Process'

LINUX class-attribute instance-attribute ¤

LINUX = 'Linux/libc/ELF'

DISASS class-attribute instance-attribute ¤

DISASS = 'Disassemble'

MISC class-attribute instance-attribute ¤

MISC = 'Misc'

KERNEL class-attribute instance-attribute ¤

KERNEL = 'Kernel'

INTEGRATIONS class-attribute instance-attribute ¤

INTEGRATIONS = 'Integrations'

WINDBG class-attribute instance-attribute ¤

WINDBG = 'WinDbg'

PWNDBG class-attribute instance-attribute ¤

PWNDBG = 'pwndbg'

SHELL class-attribute instance-attribute ¤

SHELL = 'Shell'

DEV class-attribute instance-attribute ¤

DEV = 'Developer'

InvalidDebuggerError ¤

Bases: Exception

Raised when a command is called in a debugger for which it is disallowed.

CommandFormatter ¤

Bases: RawDescriptionHelpFormatter

The formatter_class that is passed to argparse for all commands.

Subclassing this isn't officially supported, but there isn't a good alternative.

CommandObj ¤

CommandObj(
    function: Callable[..., str | None],
    parser: ArgumentParser,
    command_name: str | None,
    category: CommandCategory,
    aliases: list[str],
    examples: str,
    notes: str,
)

Represents a command that can be invoked from the debugger.

Methods:

Attributes:

builtin_override_whitelist class-attribute instance-attribute ¤

builtin_override_whitelist: set[str] = {
    "up",
    "down",
    "search",
    "pwd",
    "start",
    "starti",
    "ignore",
}

history class-attribute instance-attribute ¤

history: dict[int, str] = {}

function instance-attribute ¤

function = function

command_name instance-attribute ¤

command_name = command_name

category instance-attribute ¤

category = category

aliases instance-attribute ¤

aliases = aliases

examples instance-attribute ¤

examples = strip()

notes instance-attribute ¤

notes = strip()

parser instance-attribute ¤

parser = parser

repeat instance-attribute ¤

repeat = False

register_command ¤

register_command()

Register this object command with the underlying debugger and update pwndbg global state to know about this command.

initialize_parser ¤

initialize_parser()

invoke ¤

invoke(argument: str, from_tty: bool) -> None

Invoke the command with an argument string

check_repeated ¤

check_repeated(argument: str, from_tty: bool) -> bool

Keep a record of all commands which come from the TTY.

Returns:

  • bool

    True if this command was executed by the user just hitting "enter".

__call__ ¤

__call__(*args: Any, **kwargs: Any) -> str | None

Command ¤

Command(
    parser_or_desc: str | ArgumentParser,
    *,
    category: CommandCategory,
    command_name: str | None = None,
    aliases: list[str] = [],
    examples: str = "",
    notes: str = "",
    only_debuggers: set[DebuggerType] = None,
    exclude_debuggers: set[DebuggerType] = None,
)

Parametrized decorator for functions that serve as pwndbg commands.

Always use this to decorate your commands.

Methods:

Attributes:

parser instance-attribute ¤

parser = ArgumentParser(description=parser_or_desc)

category instance-attribute ¤

category = category

command_name instance-attribute ¤

command_name = command_name

aliases instance-attribute ¤

aliases = aliases

examples instance-attribute ¤

examples = examples

notes instance-attribute ¤

notes = notes

only_debuggers instance-attribute ¤

only_debuggers = only_debuggers

exclude_debuggers instance-attribute ¤

exclude_debuggers = exclude_debuggers

__call__ ¤

__call__(function: Callable[..., Any]) -> CommandObj

fix ¤

fix(
    arg: str | Value,
    sloppy: bool = False,
    quiet: bool = True,
    reraise: bool = False,
) -> str | Value | None

Fix a single command-line argument coming from the CLI.

Parameters:

  • arg (str | Value) –

    Original string representation (e.g. '0', '$rax', '$rax+44')

  • sloppy (bool, default: False ) –

    If arg cannot be evaluated, return arg. (default: False)

  • quiet (bool, default: True ) –

    If an error occurs, suppress it. (default: True)

  • reraise (bool, default: False ) –

    If an error occurs, raise the exception. (default: False)

Returns:

  • str | Value | None

    Ideally a Value object. May return a str if sloppy==True.

  • str | Value | None

    May return None if sloppy == False and reraise == False.

fix_reraise ¤

fix_reraise(*a, **kw) -> str | Value | None

fix_reraise_arg ¤

fix_reraise_arg(arg) -> Value

fix_reraise wrapper for evaluating command arguments

fix_int ¤

fix_int(*a, **kw) -> int

fix_int_reraise ¤

fix_int_reraise(*a, **kw) -> int

fix_int_reraise_arg ¤

fix_int_reraise_arg(arg) -> int

fix_int_reraise wrapper for evaluating command arguments

func_name ¤

func_name(function: Callable[P, T]) -> str

OnlyWhenLocal ¤

OnlyWhenLocal(function: Callable[P, T]) -> Callable[P, T | None]

OnlyWithFile ¤

OnlyWithFile(function: Callable[P, T]) -> Callable[P, T | None]

OnlyWhenQemuKernel ¤

OnlyWhenQemuKernel(function: Callable[P, T]) -> Callable[P, T | None]

OnlyWhenUserspace ¤

OnlyWhenUserspace(function: Callable[P, T]) -> Callable[P, T | None]

OnlyWithKernelDebugSyms ¤

OnlyWithKernelDebugSyms(function: Callable[P, T]) -> Callable[P, T | None]

OnlyWhenPagingEnabled ¤

OnlyWhenPagingEnabled(function: Callable[P, T]) -> Callable[P, T | None]

OnlyWhenRunning ¤

OnlyWhenRunning(function: Callable[P, T]) -> Callable[P, T | None]

OnlyWithTcache ¤

OnlyWithTcache(function: Callable[P, T]) -> Callable[P, T | None]

OnlyWhenHeapIsInitialized ¤

OnlyWhenHeapIsInitialized(
    function: Callable[P, T],
) -> Callable[P, T | None]

OnlyWithResolvedHeapSyms ¤

OnlyWithResolvedHeapSyms(function: Callable[P, T]) -> Callable[P, T | None]

sloppy_gdb_parse ¤

sloppy_gdb_parse(s: str) -> int | str

This function should be used as argparse.ArgumentParser .add_argument method's type helper.

This makes the type being parsed as gdb value and if that parsing fails, a string is returned.

:param s: String. :return: Whatever gdb.parse_and_eval returns or string.

AddressExpr ¤

AddressExpr(s: str) -> int

Parses an address expression. Returns an int.

HexOrAddressExpr ¤

HexOrAddressExpr(s: str) -> int

Parses string as hexadecimal int or an address expression. Returns an int. (e.g. '1234' will return 0x1234)

load_commands ¤

load_commands() -> None