堆栈使用情况 [英] Stack usage

查看:79
本文介绍了堆栈使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!


有没有人知道,如果有可能在整个执行过程中确保

a C程序的最大堆栈使用量?


-

Michael Birkmose

解决方案

Michael Sig Birkmose< ; MI ***** @ gisp.dk>写道:

有没有人知道,如果可以在整个执行期间确保C程序的最大堆栈使用量?




在标准C中没有办法做到这一点。但是,你的编译器

可能提供一种方法。编译器特定的问题在

comp.lang.c中是偏离主题的,所以请在专门针对您的编译器的小组中询问。


Martin

-

, - 。 Martin Dickopp,德国德累斯顿,=, - _-。 =。

/, - ) http://www.zero -based.org/ ((_ /)oo(\_))

\` - ''` - ''(。)` - ''

` - 。 Debian,GNU操作系统的一种变体。 \ _ /


-----开始PGP签名消息-----

哈希:SHA1


Michael Sig Birkmose写道:

|大家好!

|

|有谁知道,如果可以确定

|的最大堆栈使用量整个过程中的C程序是完整的执行吗?


它可能是,但这里无关紧要。就标准C而言,

不是堆栈。 C标准并没有规定动态

分配是如何在'封面'下管理的。

- -

Lew Pitcher


Master Code Code& JOAT-in-training |可根据要求提供GPG公钥

注册Linux用户#112576( http:/ /counter.li.org/

Slackware - 因为我知道我在做什么。

----- BEGIN PGP SIGNATURE-- ---

版本:GnuPG v1.2.4(GNU / Linux)

评论:使用GnuPG和Thunderbird - http://enigmail.mozdev.org

iD8DBQFAtS7nagVFX4UWr64RAm + XAJ4yqmD3ENetUagtv05GXo 09dTWcbgCgj / ey

KJxr + b8pf6f76e04Bcwp2FA =

= Nu8R

----- END PGP SIGNATURE -----


< blockquote> Michael Sig Birkmose< mi ***** @ gisp.dk>在消息新闻中写道:< 20 ******************* @ server.gisp.dk> ...

大家好!

有没有人知道,如果可以在整个执行期间确保C程序的最大堆栈使用量吗?




如果你的平台使用了一个堆栈,而且之前的海报已经提到了

,那么这样做是不可能的,那么它通常是可能的。


*在程序开始时,取一个自动的

变量的地址并存储它。

*找出堆栈在你的架构上的增长方式。

*在程序的任何一点,调用一个创建一个

自动变量的函数,取它的地址。将它与之前的

存储的地址进行比较。


这不能保证工作。要找到最好的方法,请在

上查询特定于体系结构的新闻组。


Hi everyone!

Does anyone know, if it is possible to meassure the maximum stack usage of
a C program throughout it''s entire execution?

--
Michael Birkmose

解决方案

Michael Sig Birkmose <mi*****@gisp.dk> writes:

Does anyone know, if it is possible to meassure the maximum stack
usage of a C program throughout it''s entire execution?



There is no way to do this in standard C. However, your compiler
might provide a way. Compiler-specific questions are off-topic in
comp.lang.c, so please ask in a group dedicated to your compiler.

Martin
--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-'' `-''(. .)`-''
`-. Debian, a variant of the GNU operating system. \_/


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Sig Birkmose wrote:
| Hi everyone!
|
| Does anyone know, if it is possible to meassure the maximum stack usage of
| a C program throughout it''s entire execution?

It may be, but it is irrelevant here. As far as standard C is concerned, there
is no such thing as a ''stack''. The C standards don''t dictate how dynamic
allocations are to be managed ''under the covers''.
- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I''m doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAtS7nagVFX4UWr64RAm+XAJ4yqmD3ENetUagtv05GXo 09dTWcbgCgj/ey
KJxr+b8pf6f76e04Bcwp2FA=
=Nu8R
-----END PGP SIGNATURE-----


Michael Sig Birkmose <mi*****@gisp.dk> wrote in message news:<20*******************@server.gisp.dk>...

Hi everyone!

Does anyone know, if it is possible to meassure the maximum stack usage of
a C program throughout it''s entire execution?



If your platform uses a stack, and as previous posters have mentioned
it is not gauranteed to do so, then it''s normally possible.

* At the beginning of the program take the address of a automatic
variable and store it.
* Find out which way the stack grows on your architecture.
* At any point in the program, call a function that creates an
automatic variable, take it''s address. Compare it to the previously
stored address.

This is not gauranteed to work. To find the best way to do it ask on
an architecture specific newsgroup.


这篇关于堆栈使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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