Add option to enable register aliases in disassembly (#3257)

* add option to enable register aliases in disassembly

* drive-by comment fix
pull/3268/head
k4lizen 4 months ago committed by GitHub
parent da41ee6408
commit a3929d578b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -443,6 +443,20 @@ Replacing constant operands with their symbol in the disassembly.
----------
## **disasm-reg-alias**
Force the disassembly to use register aliases (e.g. aarch64 x29 -> fp).
The register aliasing is done by capstone, see:
https://github.com/capstone-engine/capstone/blob/next/docs/cs_v6_release_guide.md#:~:text=None.-,Register%20alias,-Register%20alias%20
Enabling this may make disassembly slower.
**Default:** off
----------
## **disasm-telescope-depth**

@ -46,6 +46,18 @@ CapstoneEndian = {
CapstoneSyntax = {"intel": CS_OPT_SYNTAX_INTEL, "att": CS_OPT_SYNTAX_ATT}
force_register_alias = pwndbg.config.add_param(
"disasm-reg-alias",
False,
"force the disassembly to use register aliases (e.g. aarch64 x29 -> fp)",
param_class=pwndbg.lib.config.PARAM_BOOLEAN,
help_docstring="""\
The register aliasing is done by capstone, see:
https://github.com/capstone-engine/capstone/blob/next/docs/cs_v6_release_guide.md#:~:text=None.-,Register%20alias,-Register%20alias%20
Enabling this may make disassembly slower.
""",
)
# Caching strategy:
# To ensure we don't have stale register/memory information in our cached PwndbgInstruction,
@ -109,6 +121,8 @@ def get_disassembler(cs_info: Tuple[int, int]):
flavor = pwndbg.dbg.x86_disassembly_flavor()
try:
cs.syntax = CapstoneSyntax[flavor]
if force_register_alias:
cs.syntax |= CS_OPT_SYNTAX_CS_REG_ALIAS
except CsError:
pass
cs.detail = True
@ -310,7 +324,9 @@ def near(
Disasms instructions near given `address`. Passing `emulate` makes use of
unicorn engine to emulate instructions to predict branches that will be taken.
`show_prev_insns` makes this show previously cached instructions
(this is mostly used by context's disasm display, so user see what was previously)
This allows us to maintain a context of surrounding instructions while
single-stepping instructions.
"""
pc = pwndbg.aglib.regs.pc

Loading…
Cancel
Save