1

I have a similar issue like in this question GDB corrupted stack frame - How to debug?, like this:

 (gdb) bt
 #0  0x76bd6978 in fputs () from /lib/libc.so.6
 #1  0x0000b080 in getfunction1 ()
 #2  0x0000b080 in getfunction1 ()
 Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Chris Dodd wrote an answer to point the top of the stack to the program counter (PC). In a 32bit machine it shall be

(gdb) set $pc = *(void **)$esp
(gdb) set $esp = $esp + 4

However, after run the first line I got invalid cast:

(gdb) set $pc = *(void **)$esp
Invalid cast.
(gdb) set $esp = $esp + 4
Argument to arithmetic operation not a number or boolean.

Why do I get this messages? and how can I make a workaround to figure out where the crash occurs? I work on a armv7 machine with Linux.

ywiyogo
  • 738
  • 2
  • 7
  • 21

1 Answers1

1

ESP does not exist in ARM. It's MSP (Main Stack Pointer) or PSP (Stack pointer).

ARM Registers

As ESP does not exists, that's why you get invalid cast. If you do the same command with another valid ARM register there is no error