How can I find out if ARM mode or Thumb mode is enabled in gdb?

when debugging ARMv7 binary with GDB, besides viewing the length of the instruction, is there any way to find out what mode the processor is in? (ARM, Thumb)

+4
source share
1 answer

I use this little gdb-script to determine the current state from the CPSR field, just put it in your ~ / .gdbinit file and call arm_isa if necessary.

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 displays the used ISA.

+7
source

Source: https://habr.com/ru/post/1533515/


All Articles