Skip to content

Commit

Permalink
Allow running cpsr command on aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
Gulshan Singh committed Dec 12, 2022
1 parent 0269050 commit 34a1642
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions pwndbg/commands/cpsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@
from pwndbg.color import message


@pwndbg.commands.ArgparsedCommand("Print out ARM CPSR or xPSR register")
@pwndbg.commands.ArgparsedCommand("Print out ARM CPSR or xPSR register", aliases=["xpsr"])
@pwndbg.commands.OnlyWhenRunning
def cpsr():
arm_print_psr()


@pwndbg.commands.ArgparsedCommand("Print out ARM xPSR or CPSR register")
@pwndbg.commands.OnlyWhenRunning
def xpsr():
arm_print_psr()


# Even though aarch64 doesn't have a CPSR register, GDB calls the PSTATE
# register CPSR instead
@pwndbg.commands.OnlyWithArch(["arm", "armcm", "aarch64"])
def arm_print_psr():
if pwndbg.gdblib.arch.current not in ("arm", "armcm"):
print(message.warn("This is only available on ARM"))
return

reg = "cpsr" if pwndbg.gdblib.arch.current == "arm" else "xpsr"
reg = "xpsr" if pwndbg.gdblib.arch.name == "armcm" else "cpsr"
print(
"%s %s"
% (
Expand Down

0 comments on commit 34a1642

Please sign in to comment.