如何确定保存在堆栈中值? [英] How to determine values saved on the stack?

查看:140
本文介绍了如何确定保存在堆栈中值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一些试验,并希望能够看到什么是一个系统调用(用户土地过程中所保存的状态)时保存在堆栈中。据 HTTP://lxr.linux。无/#LINUX + v2.6.30.1 /拱/ 86 /内核/ entry_32.S 的它表明寄存器的各个值保存在这些特定偏移到堆栈指针。这里是code我一直在试图用研究如何保存在栈​​上(这是我创建了一个自定义的系统调用):

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));

其中值是无符号长。

截至目前,该值不被期望的(它表示0被保存用于DS的用户值)。

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?

另一种可能性是,我可以用一个调试器,如GDB检查堆栈内容,同时在内核?我没有与调试更加广泛的使用,我不知道如何调试code中的内核中。任何帮助深表AP preciated。

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.

推荐答案

无需内嵌汇编。保存的状态 entry_32.S 压栈的系统调用是奠定了一个结构pt_regs ,你可以得到一个指向它像这样(你需要包括< ASM / ptrace.h> 和/或< ASM /处理器.H> 直接或间接):

No need for inline assembly. The saved state that entry_32.S pushes onto the stack for a syscall is laid out as a struct pt_regs, and you can get a pointer to it like this (you'll need to include <asm/ptrace.h> and/or <asm/processor.h> either directly or indirectly):

结构pt_regs *暂存器= task_pt_regs(电流);

这篇关于如何确定保存在堆栈中值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆