识别地址是否属于堆或堆栈或寄存器 [英] Identifying if an address belongs to heap or stack or registers

查看:92
本文介绍了识别地址是否属于堆或堆栈或寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个指向C/C ++变量的指针.是否有可能准确地确定此变量属于内存的哪一部分?如果是,怎么办?

I have a pointer available with me to a C/C++ variable. Is it possible to exactly make out which segment of the memory this variable belongs to ? If yes, how ?

注意:我只知道这个变量的地址,如果该变量是本地/全局等,则没有进一步的信息.

Note: I just have the address of this variable, no further information if the variable is local/global etc.

推荐答案

找出您的体系结构是否具有指向堆或堆栈区域的指针.通常有一些堆栈指针或框架指针.

Find out whether your architecture has pointers to your heap or stack region. Usually there are some stackpointers or framepointers..

然后将您的实际地址与这些地址进行比较,并确定它们所属的位置.

Then compare your actual address to those addresses and decide where they belong.

这篇关于识别地址是否属于堆或堆栈或寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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