context ¤
Classes:
-
StdOutput–A context manager wrapper to give stdout
-
FileOutput–A context manager wrapper to reopen files on enter
-
CallOutput–A context manager which calls a function on write
-
CompactRegsOptions– -
RegisterContext–
Functions:
-
clear_screen–Clear the screen by moving the cursor to top-left corner and
-
reserve_lines_maybe–Scroll the terminal up a few lines to reduce shaking
-
validate_context_sections– -
output–Creates a context manager corresponding to configured context output
-
contextoutput– -
resetcontextoutput– -
history_size_changed– -
serve_context_history– -
history_handle_unchanged_contents– -
contextprev– -
contextnext– -
contextsearch– -
contextwatch– -
contextunwatch– -
context_expressions– -
context–Print out the current register, instruction, and stack context.
-
calculate_padding_to_align–Calculates the number of spaces to append to reach the next alignment.
-
compact_regs_hardcut–If the string of any register overflows its column_width, it will be hard cut to the column_width.
-
compact_regs_normal–Will try to group similar registers together, and may increase the number of rows (as opposed to compact_regs_very)
-
compact_regs_very–Will try to group similar registers together, but will sacrifice the grouping if it can be more compact.
-
compact_regs– -
context_regs– -
context_heap_tracker– -
regs–Print out all registers and enhance the information.
-
get_regs– -
try_emulate_if_bug_disable– -
context_disasm– -
get_highlight_source– -
get_filename_and_formatted_source–Returns formatted, lines limited and highlighted source as list
-
context_code– -
context_stack– -
context_backtrace– -
context_args– -
get_thread_status– -
context_threads– -
save_signal– -
context_last_signal–
Attributes:
-
log– -
T– -
P– -
c– -
config_reserve_lines– -
config_clear_screen– -
config_output– -
config_context_sections– -
config_max_threads_display– -
OutputType– -
outputs(dict[str, OutputType]) – -
output_settings(DefaultDict[str, dict[str, Any]]) – -
OutputWrapper– -
OutputTarget– -
banner_arg– -
context_history(DefaultDict[str, list[list[str]]]) – -
selected_history_index(int | None) – -
context_history_size– -
expressions– -
parser– -
disasm_lines– -
source_disasm_lines– -
should_decompile– -
stack_lines– -
backtrace_lines– -
backtrace_frame_label– -
last_signal(list[str]) – -
thread_status_messages– -
context_sections(dict[str, Callable[..., list[str]]]) –
c module-attribute ¤
c = ColorConfig(
"backtrace",
[
ColorParamSpec(
"prefix", "none", "color for prefix of current backtrace label"
),
ColorParamSpec("address", "none", "color for backtrace (address)"),
ColorParamSpec("symbol", "none", "color for backtrace (symbol)"),
ColorParamSpec(
"frame-label", "none", "color for backtrace (frame label)"
),
],
)
config_reserve_lines module-attribute ¤
config_reserve_lines = add_param(
"context-reserve-lines",
"if-ctx-fits",
"when to reserve lines after the prompt to reduce context shake",
help_docstring='\nThe "if-ctx-fits" setting only reserves lines if the whole context would still fit vertically in the current terminal window.\nIt doesn\'t take into account line-wrapping due to insufficient terminal width.\n',
param_class=PARAM_ENUM,
enum_sequence=["never", "if-ctx-fits", "always"],
)
config_clear_screen module-attribute ¤
config_clear_screen = add_param(
"context-clear-screen",
False,
"whether to clear the screen before printing the context",
)
config_output module-attribute ¤
config_output = add_param(
"context-output",
"stdout",
'where Pwndbg should output ("stdout" or file/tty)',
)
config_context_sections module-attribute ¤
config_context_sections = add_param(
"context-sections",
"regs disasm code stack backtrace expressions threads heap_tracker",
"which context sections are displayed (controls order)",
)
config_max_threads_display module-attribute ¤
config_max_threads_display = add_param(
"context-max-threads",
4,
"maximum number of threads displayed by the context command",
)
output_settings module-attribute ¤
banner_arg module-attribute ¤
banner_arg = add_argument(
"banner",
type=str,
nargs="?",
default="both",
help="Where a banner should be placed: both, top , bottom, none",
)
context_history module-attribute ¤
context_history_size module-attribute ¤
context_history_size = add_param(
"context-history-size", 50, "number of context history entries to store"
)
parser module-attribute ¤
disasm_lines module-attribute ¤
disasm_lines = add_param(
"context-disasm-lines",
10,
"number of additional lines to print in the disasm context",
)
source_disasm_lines module-attribute ¤
source_disasm_lines = add_param(
"context-code-lines",
14,
"number of source code lines to print by the context command",
)
should_decompile module-attribute ¤
should_decompile = add_param(
"context-integration-decompile",
True,
"whether context should fall back to decompilation with no source code",
)
stack_lines module-attribute ¤
stack_lines = add_param(
"context-stack-lines", 8, "number of lines to print in the stack context"
)
backtrace_lines module-attribute ¤
backtrace_lines = add_param(
"context-backtrace-lines",
8,
"number of lines to print in the backtrace context",
)
backtrace_frame_label module-attribute ¤
backtrace_frame_label = add_param(
"backtrace-frame-label", "", "frame number label for backtrace"
)
thread_status_messages module-attribute ¤
thread_status_messages = {
"running": light_green("running"),
"stopped": yellow("stopped"),
"exited": gray("exited "),
}
context_sections module-attribute ¤
context_sections: dict[str, Callable[..., list[str]]] = {
"a": context_args,
"r": context_regs,
"d": context_disasm,
"s": context_stack,
"b": context_backtrace,
"c": context_code,
}
StdOutput ¤
FileOutput ¤
A context manager wrapper to reopen files on enter
Methods:
Attributes:
CompactRegsOptions ¤
RegisterContext ¤
Bases: RegisterContextProtocol
Methods:
-
get_prefix– -
get_register_value– -
flag_register_context– -
segment_registers_context– -
addressing_register_context– -
register_context_default–
Attributes:
-
changed(list[str]) –
clear_screen ¤
Clear the screen by moving the cursor to top-left corner and clearing the content. Different terminals may act differently
reserve_lines_maybe ¤
Scroll the terminal up a few lines to reduce shaking when repeatedly printing the context.
Only do this if the context would still fit on the screen.
output ¤
output(section: str) -> OutputWrapper
Creates a context manager corresponding to configured context output
contextoutput ¤
contextoutput(
section: str,
path: OutputType,
clearing: bool,
banner: str = "both",
width: int | None = None,
height: int | None = None,
)
serve_context_history ¤
context_expressions ¤
context_expressions(
target: OutputTarget = stdout,
with_banner: bool = True,
width: int | None = None,
height: int | None = None,
) -> list[str]
context ¤
Print out the current register, instruction, and stack context.
Accepts subcommands 'reg', 'disasm', 'code', 'stack', 'backtrace', 'args', 'threads', 'heap_tracker', 'expressions', and/or 'last_signal'.
calculate_padding_to_align ¤
Calculates the number of spaces to append to reach the next alignment. The next alignment point is given by "x * align >= length".
compact_regs_hardcut ¤
compact_regs_hardcut(
regs: list[str],
terminal_width: int,
column_width: int,
columns: int,
separation: int,
) -> list[str]
If the string of any register overflows its column_width, it will be hard cut to the column_width.
Example
RAX 0xfffffffffffffdfe R8 0 R14 0 RBX 0 R9 0x7fffffffcbd0 —▸ 0x7fff... R15 0x7ffff7f83e60 (_rl_orig... RCX 0x7ffff7c90efa (__intern... R10 0 RBP 1 RDX 0 R11 0x202 RSP 0x7fffffffcb70 ◂— 0 RDI 1 R12 0x7fffffffccb0 ◂— 1 RIP 0x7ffff7c90efa (__intern... RSI 0x7fffffffccb0 ◂— 1 R13 0 EFLAGS 0x202 [ cf pf af zf sf...
compact_regs_normal ¤
compact_regs_normal(
regs: list[str],
terminal_width: int,
column_width: int,
columns: int,
separation: int,
) -> list[str]
Will try to group similar registers together, and may increase the number of rows (as opposed to compact_regs_very) in order to achieve this.
column_width does not include separation.
Example
RAX 0xfffffffffffffdfe R8 0 R14 0 RBX 0 R9 ⏎ R15 ⏎ RCX ⏎ R10 0 RBP 1 RDX 0 R11 0x202 RSP 0x7fffffffcb70 ◂— 0 RDI 1 R12 0x7fffffffccb0 ◂— 1 RIP ⏎ RSI 0x7fffffffccb0 ◂— 1 R13 0 EFLAGS ⏎
↪ R9 0x7fffffffcbd0 —▸ 0x7ffff7f83e60 (_rl_orig_sigset) ◂— 0 ↪ R15 0x7ffff7f83e60 (_rl_orig_sigset) ◂— 0 ↪ RCX 0x7ffff7c90efa (__internal_syscall_cancel+138) ◂— add rsp, 0x18 ↪ RIP 0x7ffff7c90efa (__internal_syscall_cancel+138) ◂— add rsp, 0x18 ↪ EFLAGS 0x202 [ cf pf af zf sf IF df of ac ]
compact_regs_very ¤
compact_regs_very(
regs: list[str],
terminal_width: int,
column_width: int,
columns: int,
separation: int,
) -> list[str]
Will try to group similar registers together, but will sacrifice the grouping if it can be more compact.
column_width does not include separation.
Example
RAX 0xfffffffffffffdfe R8 0 R14 0 RBX 0 R9 0x7fffffffcbd0 —▸ 0x7ffff7f83e60 (_rl_orig_sigset) ◂— 0 R15 0x7ffff7f83e60 (_rl_orig_sigset) ◂— 0 RCX 0x7ffff7c90efa (__internal_syscall_cancel+138) ◂— add rsp, 0x18 R10 0 RBP 1 RDX 0 R11 0x202 RSP 0x7fffffffcb70 ◂— 0 RDI 1 R12 0x7fffffffccb0 ◂— 1 RIP 0x7ffff7c90efa (__internal_syscall_cancel+138) ◂— add rsp, 0x18 RSI 0x7fffffffccb0 ◂— 1 R13 0 EFLAGS 0x202 [ cf pf af zf sf IF df of ac ]
compact_regs ¤
compact_regs(
regs: list[str], width: int | None = None, target: OutputTarget = stdout
) -> list[str]
context_regs ¤
context_regs(
target: OutputTarget = stdout,
with_banner: bool = True,
width: int | None = None,
height: int | None = None,
) -> list[str]
context_heap_tracker ¤
context_heap_tracker(
target: OutputTarget = stdout,
with_banner: bool = True,
width: int | None = None,
height: int | None = None,
) -> list[str]
regs ¤
regs(regs: list[str | VisitableRegister | None] | None = None) -> None
Print out all registers and enhance the information.
context_disasm ¤
context_disasm(
target: OutputTarget = stdout,
with_banner: bool = True,
width: int | None = None,
height: int | None = None,
) -> list[str]
get_filename_and_formatted_source ¤
Returns formatted, lines limited and highlighted source as list or if it isn't there - an empty list
context_code ¤
context_code(
target: OutputTarget = stdout,
with_banner: bool = True,
width: int | None = None,
height: int | None = None,
) -> list[str]
context_stack ¤
context_stack(
target: OutputTarget = stdout,
with_banner: bool = True,
width: int | None = None,
height: int | None = None,
) -> list[str]
context_backtrace ¤
context_backtrace(
with_banner: bool = True,
target: OutputTarget = stdout,
width: int | None = None,
height: int | None = None,
) -> list[str]
context_args ¤
context_args(
with_banner: bool = True,
target: OutputTarget = stdout,
width: int | None = None,
height: int | None = None,
) -> list[str]
context_threads ¤
context_threads(
with_banner: bool = True,
target: OutputTarget = stdout,
width: int | None = None,
height: int | None = None,
) -> list[str]
context_last_signal ¤
context_last_signal(
with_banner: bool = True,
target: OutputTarget = stdout,
width: int | None = None,
height: int | None = None,
) -> list[str]