Bloomu Prof
Bloomu Prof

Reputation: 51

gdb use of the frame pointer register in Aarch64 assembly?

I've run into a surprise while using the gdb debugger to trace execution of an Aarch64 assembly-language program.

A lot of documentation equates the x29 "architectural register" with the frame pointer,as "fp". But gdb seems to set fp equal to the stack pointer "sp".

I'm using the command

info registers x29 fp sp  x0 x1  lr pc

to display register usage during an executable's function call. To my surprise, the "fp" value is always equal to the "sp" value, NOT the "x29" value. But when running the executable, the instruction stp fp, lr, [sp, -16] ! works with the "x29" register as expected.

Is this a deliberate choice on the part of gdb? If so, it's very confusing.

Display x29, "fp", and "sp" registers with info registers x29 fp sp.

Expected "fp" to be an alias for x29, and show the same value as x29.

Got this output:

(gdb) info registers  x29 fp sp 
x29            0x0                 0
fp             0x7ffffffa50        0x7ffffffa50
sp             0x7ffffffa50        0x7ffffffa50
(gdb) 

Upvotes: 5

Views: 475

Answers (0)

Related Questions