when debugging ARMv7 binary with GDB, aside from looking the instruction length, is there a way to figure out which mode the CPU is currently in? (ARM, Thumb)
how can I tell if I am in ARM mode or Thumb mode in gdb?
I'm using this little gdb-script to determine the current state from the CPSR field, just put it inside your ~/.gdbinit file and call arm_isa when needed.
define arm_isa
if ($cpsr & 0x20)
printf "Using THUMB(2) ISA\n"
else
printf "Using ARM ISA\n"
end
end
It checks bit 5 in cpsr, which indicates the current state and outputs the used ISA.
Keep in mind that this answer is from 2014, referring to ARMv7, the document you linked to is for ARMv8. PSTATE was only introduced in ARMv8 and took some of the former CPSR bits. –
Ouzo
Yes, I understand. And this still works, which is great :-) –
Grim
© 2022 - 2024 — McMap. All rights reserved.
CPSR[5]
isres0
, and that you should readPSTATE.P
fromSPSR[5]
, and SPSR does not seem accessible from user mode. – Grim