How to determine values saved on the stack?

Posted by Brian on Stack Overflow See other posts from Stack Overflow or by Brian
Published on 2010-04-06T04:22:33Z Indexed on 2010/04/06 4:23 UTC
Read the original article Hit count: 271

Filed under:
|

I'm doing some experimenting and would like to be able to see what is saved on the stack during a system call (the saved state of the user land process). According to http://lxr.linux.no/#linux+v2.6.30.1/arch/x86/kernel/entry_32.S it shows that the various values of registers are saved at those particular offsets to the stack pointer. Here is the code I have been trying to use to examine what is saved on the stack (this is in a custom system call I have created):

asm("movl 0x1C(%esp), %ecx");
asm("movl %%ecx, %0" : "=r" (value));

where value is an unsigned long.

As of right now, this value is not what is expected (it is showing a 0 is saved for the user value of ds).

Am I correctly accessing the offset of the stack pointer?

Another possibility might be could I use a debugger such as GDB to examine the stack contents while in the kernel? I don't have much extensive use with debugging and am not sure of how to debug code inside the kernel. Any help is much appreciated.

© Stack Overflow or respective owner

Related posts about c

    Related posts about asm