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
-
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_ghidra
–Print out the source of the current function decompiled by ghidra.
-
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
– -
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
– -
outputs
(dict[str, str]
) – -
output_settings
(DefaultDict[str, dict[str, Any]]
) – -
banner_arg
– -
context_history
(DefaultDict[str, list[list[str]]]
) – -
selected_history_index
(int | None
) – -
context_history_size
– -
expressions
– -
config_context_ghidra
– -
parser
– -
disasm_lines
– -
source_disasm_lines
– -
should_decompile
– -
stack_lines
– -
backtrace_lines
– -
backtrace_frame_label
– -
last_signal
(list[str]
) – -
thread_status_messages
– -
context_sections
–
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 ghidra 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"
)
config_context_ghidra module-attribute
¤
config_context_ghidra = add_param(
"context-ghidra",
"never",
"when to try to decompile the current function with ghidra",
help_docstring="Doing this is slow and requires radare2/r2pipe or rizin/rzpipe.",
param_class=PARAM_ENUM,
enum_sequence=["always", "never", "if-no-source"],
)
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",
10,
"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 = {
"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:
RegisterContext ¤
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.
serve_context_history ¤
context_ghidra ¤
Print out the source of the current function decompiled by ghidra.
The context-ghidra config parameter is used to configure whether to always, never or only show the context if no source is available.
context ¤
Print out the current register, instruction, and stack context.
Accepts subcommands 'reg', 'disasm', 'code', 'stack', 'backtrace', 'ghidra', '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".
get_filename_and_formatted_source ¤
Returns formatted, lines limited and highlighted source as list or if it isn't there - an empty list