系统堆栈在cpp中的增长点在哪里? [英] where does system stack grow in cpp?

查看:62
本文介绍了系统堆栈在cpp中的增长点在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们 -


是否有可能找到系统堆栈增长的方式?也许,我是
不够精确:当一个函数被调用时,

(被调用者)函数的返回地址被放在堆栈上。因此,问题是那个堆栈标题(地址增加或减少)的

方向。

你将如何在cpp中实现这个?


任何建议。

解决方案

puzzlecracker写道:

伙计们 -
<是否有可能找到系统堆栈增长的方式?也许,我不够精确:当调用一个函数时,
(被调用者)函数的返回地址被放在堆栈上。因此,问题是堆栈标题(地址增加或减少)的方向。
如何在cpp中实现这一点?

任何建议。




只需调用一个带参数的函数,取

参数的地址,然后调用另一个带参数的函数并取

该参数的地址。打印出地址,你会看到他们前往

的方向。


DW


David White写道:

puzzlecracker写道:

伙计们 -

是否有可能找到系统堆栈增长的方式?也许,我不够精确:当调用一个函数时,
(被调用者)函数的返回地址被放在堆栈上。因此,问题是堆栈标题(地址增加或
减少)的方向。你如何在cpp中实现这个?

任何建议。
只需调用一个带参数的函数,取
参数的地址,然后调用另一个函数



来自第一个函数

,它接受一个参数并获取该参数的地址。打印出地址,你会看到
朝向它们的方向。

DW





David White写道:

puzzlecracker写道:

伙计们 -

是否有可能找到系统堆栈增长的方式?也许,我不够精确:当调用一个函数时,
(被调用者)函数的返回地址被放在堆栈上。因此,问题是堆栈标题(地址增加或减少)的方向。
如何在cpp中实现这一点?

任何建议。



只需调用一个带参数的函数,获取
参数的地址,然后调用另一个带参数的函数并获取该参数的
地址。打印出地址,你会看到他们前进的方向。

DW




那不行。

你可以通过值或通过引用传递(在给定的上下文中,指针与

相同)。


如果通过值传递 - 获取地址将返回

当前帧中的地址,即使您将其传递给函数 - 并将值复制

到函数''框架。同样,通过参考传递它不会显示差异。


Guys -

Is it possible to find which way system stack grows? Perhaps, I am
not precise enough: When a function is called, the return address of
(callee) function is put on the stack. Thus, the question is the
direction where that stack heading (address increasing or decreasing).
How would you implement this in cpp?

any suggestion.

解决方案

puzzlecracker wrote:

Guys -

Is it possible to find which way system stack grows? Perhaps, I am
not precise enough: When a function is called, the return address of
(callee) function is put on the stack. Thus, the question is the
direction where that stack heading (address increasing or decreasing).
How would you implement this in cpp?

any suggestion.



Just call a function that takes a parameter, take the address of the
parameter, then call another function that takes a parameter and take the
address of that parameter. Print out the addresses and you''ll see in which
direction they are heading.

DW


David White wrote:

puzzlecracker wrote:

Guys -

Is it possible to find which way system stack grows? Perhaps, I am
not precise enough: When a function is called, the return address of
(callee) function is put on the stack. Thus, the question is the
direction where that stack heading (address increasing or
decreasing). How would you implement this in cpp?

any suggestion.
Just call a function that takes a parameter, take the address of the
parameter, then call another function



from within the first function
that takes a parameter and take
the address of that parameter. Print out the addresses and you''ll see
in which direction they are heading.

DW




David White wrote:

puzzlecracker wrote:

Guys -

Is it possible to find which way system stack grows? Perhaps, I am
not precise enough: When a function is called, the return address of
(callee) function is put on the stack. Thus, the question is the
direction where that stack heading (address increasing or decreasing).
How would you implement this in cpp?

any suggestion.



Just call a function that takes a parameter, take the address of the
parameter, then call another function that takes a parameter and take the
address of that parameter. Print out the addresses and you''ll see in which
direction they are heading.

DW



That will NOT work.
you can pass either by value or by reference (by pointer is the same in
the given context).

If pass by value - taking it address will return the address in the
current frame even if you pass it to function - and the value is copied
to the function''s frame. Likewise, passing it by referenfce will not
show the difference.


这篇关于系统堆栈在cpp中的增长点在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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