检测全局未初始化变量的读取 [英] Detecting Reads of Global Uninitialized Variables

查看:58
本文介绍了检测全局未初始化变量的读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检测未初始化的全局变量的读取(在一个文件中声明为
,在另一个文件中用作另一个文件)。


我知道ANSI C将所有全局变量初始化为0,但是,我确实不想依赖于此初始化。相反,我想

表达自己初始化所有变量。我看过像

Compuware BoundsChecker这样的工具,它在检测

未初始化变量方面做得非常出色,但是没有检测到GLOBAL的读取

未初始化的变量。


有没有可以做到这一点的工具?或者是否有特定的

技术可用于自动化这个?


James

I''m trying to detect reads of uninitialized global variables (that are
declared in one file, and used in another as an extern).

I know that ANSI C initializes all global variables to 0, however, I do
not want to rely on this for initialization. Instead, I want to
explicity initialize all variables myself. I''ve looked at tools like
Compuware BoundsChecker, which does an amazing job in detecting
uninitialized variables, but doesn''t detect reads of GLOBAL
uninitialized variables.

Is there a tool out there that can do this? Or is there a particular
technique that can be used to automate this?

James

推荐答案

< jy ******* @ gmail.com>在消息中写道

news:11 ********************** @ g47g2000cwa.googlegr oups.com ...
<jy*******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
我正在尝试检测未初始化的全局变量的读取(在一个文件中声明,在另一个文件中用作extern)。

我知道ANSI C将所有全局变量初始化为0,但是,我不想依赖于此进行初始化。


为什么不呢?语言保证它。

相反,我想明确地自己初始化所有变量。我已经看过像Compuware BoundsChecker这样的工具,它在检测未初始化的变量方面做得非常出色,但是没有检测到GLOBAL
未初始化变量的读取。


那是因为他们*被初始化了。

有没有可以做到这一点的工具?或者是否有一种特殊的技术可用于自动化?
I''m trying to detect reads of uninitialized global variables (that are
declared in one file, and used in another as an extern).

I know that ANSI C initializes all global variables to 0, however, I do
not want to rely on this for initialization.
Why not? The language guarantees it.
Instead, I want to
explicity initialize all variables myself. I''ve looked at tools like
Compuware BoundsChecker, which does an amazing job in detecting
uninitialized variables, but doesn''t detect reads of GLOBAL
uninitialized variables.
That''s because they *are* initialized.

Is there a tool out there that can do this? Or is there a particular
technique that can be used to automate this?




你需要某种C解析器。


-Mike



You''ll need some kind of C parser.

-Mike


" Mike Wahler" < MK ****** @ mkwahler.net>在消息中写道

新闻:jJ **************** @ newsread3.news.pas.earthli nk.net ...
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:jJ****************@newsread3.news.pas.earthli nk.net...
< jy ******* @ gmail.com>在消息中写道
新闻:11 ********************** @ g47g2000cwa.googlegr oups.com ...
<jy*******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
我正在尝试检测未初始化的全局变量的读取(在一个文件中声明,在另一个文件中用作extern)。
....有没有可以做到这一点的工具?或者是否有一种特殊的技术可用于自动化?
I''m trying to detect reads of uninitialized global variables (that are
declared in one file, and used in another as an extern). .... Is there a tool out there that can do this? Or is there a particular
technique that can be used to automate this?



你需要某种C解析器。



You''ll need some kind of C parser.




如果这些变量被分组到一个特殊的部分,那么可能可以在每次访问该部分所在的页面时捕获这些变量

。它可能不容易做到b $ b,或者如果你有很多变量,那么很难找到所有的东西,并且每次都需要停止...只是一个想法...


Alex



If these variables are grouped into a special section, it might be possible
to trap on each and every access to the pages in which the section lies. It
may not be easy to do, though, or not easy to find everything if you have
many variables in there and need to stop every time... Just an idea...

Alex


2005年9月30日星期五03:53:22 +0400,Alexei A .Frounze

< al ***** @ chat.ru>在comp.lang.c中写道:
On Fri, 30 Sep 2005 03:53:22 +0400, "Alexei A. Frounze"
<al*****@chat.ru> wrote in comp.lang.c:
" Mike Wahler" < MK ****** @ mkwahler.net>在消息中写道
新闻:jJ **************** @ newsread3.news.pas.earthli nk.net ...
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:jJ****************@newsread3.news.pas.earthli nk.net...
< jy*******@gmail.com>在消息中写道
新闻:11 ********************** @ g47g2000cwa.googlegr oups.com ...
<jy*******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
我正在尝试检测未初始化的全局变量的读取(在一个文件中声明,在另一个文件中用作extern)。 ......有没有可以做到这一点的工具?或者是否有一种特殊的技术可用于自动化?
你需要某种C解析器。
I''m trying to detect reads of uninitialized global variables (that are
declared in one file, and used in another as an extern). ... Is there a tool out there that can do this? Or is there a particular
technique that can be used to automate this?
You''ll need some kind of C parser.



如果这些变量是分组的进入一个特殊的部分,可能会陷入对每个部分所在页面的每次访问。它可能不容易做到,或者如果你有很多变量并且每次都需要停止而不容易找到所有的东西......只是一个想法......

Alex



If these variables are grouped into a special section, it might be possible
to trap on each and every access to the pages in which the section lies. It
may not be easy to do, though, or not easy to find everything if you have
many variables in there and need to stop every time... Just an idea...

Alex




引用Alexei A. Frounze <人***** @ chat.ru>在comp.lang.c中:

这是关于comp.lang.c的主题。
Alex



To quote "Alexei A. Frounze" <al*****@chat.ru> in comp.lang.c:
This is off topic for comp.lang.c.
Alex




我''我无法在8051上运行一个C程序实现你的建议




你的答案与标准C有什么关系? br />
没有''特殊部分''或''页''?


-

杰克克莱恩

主页: http://JK-Technology.Com

常见问题解答

comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html

comp.lang.c ++ http://www.parashift.com/c++-faq-lite/

alt.comp.lang.learn.c-c ++
http://www.contrib.an drew.cmu.edu/~a...FAQ-acllc.html



I''m having trouble implementing your suggestion on a C program running
on an 8051.

And what does your answer have to do with standard C, which knows
nothing of ''special sections'' or ''pages''?

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html


这篇关于检测全局未初始化变量的读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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