I am debugging a program crash of a released build, that is, no debug info is available in GDB, all I can get is a callstack of the crash point. Due to some restrictions, using a debug build is not on the table.
However, I was wondering whether I can still get the funtion args in the callframe? say, by p $rdi
in GDB, can I still get the first arg of the real scene of current function frame?
I am debugging a program crash of a released build, that is, no debug info is available in GDB, all I can get is a callstack of the crash point. Due to some restrictions, using a debug build is not on the table.
However, I was wondering whether I can still get the funtion args in the callframe? say, by p $rdi
in GDB, can I still get the first arg of the real scene of current function frame?
1 Answer
Reset to default 1In short, no. RDI
is call-clobbered in the SYSV ABI, and GCC can dynamically reassign registers based as needed. If the argument that was in RDI
is already consumed, GCC knows it can freely reuse RDI
for other purposes. And under register pressure, GCC may push RDI
to the stack.
When the function at hand is not a leaf function, there's an additional observation. GCC will not blindly try to restore RDI
to its old value after calling another function. That's just a special case of "freely reuse RDI".
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744204913a4563054.html
-O
,-g
just means debug symbols. Under optimizations, the thing that affects registers is that there might not be a function call at all if it is inlined. The function call convention is otherwise guaranteed to obey the same ABI. – Passer By Commented Mar 25 at 10:12-g
)? That would make your life a little easier. – Jesper Juhl Commented Mar 25 at 11:50