Skip to content

Instantly share code, notes, and snippets.

@tralamazza
Last active August 29, 2015 14:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tralamazza/294e45475fce0b8e6c63 to your computer and use it in GitHub Desktop.
Save tralamazza/294e45475fce0b8e6c63 to your computer and use it in GitHub Desktop.
ARMv7 exception helper
define armex
if $lr & 0xd == 0xd
printf "Uses PSP 0x%x return.\n", $PSP
set $armex_base = $PSP
else
printf "Uses MSP 0x%x return.\n", $MSP
set $armex_base = $MSP
end
printf "xPSR 0x%x\n", *($armex_base+28)
printf "ReturnAddress 0x%x\n", *($armex_base+24)
printf "LR (R14) 0x%x\n", *($armex_base+20)
printf "R12 0x%x\n", *($armex_base+16)
printf "R3 0x%x\n", *($armex_base+12)
printf "R2 0x%x\n", *($armex_base+8)
printf "R1 0x%x\n", *($armex_base+4)
printf "R0 0x%x\n", *($armex_base)
printf "Return instruction:\n"
x/i *($armex_base+24)
end
document armex
ARMv7 Exception entry behavior.
xPSR, ReturnAddress, LR (R14), R12, R3, R2, R1, and R0
end
@tralamazza
Copy link
Author

(gdb) armex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment