火星上的C语言 [英] The C language in the planet Mars

查看:159
本文介绍了火星上的C语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人类现在有两个机器人在火星上徘徊。不,

不是火星入侵地球,而是两年多前降落在火星上的地球




在精神机器人出现一些初始操作系统故障(Chris Torek可以评论那些可能的价格)后,软件从那以后顺利完成了




所有软件都是用C语言编写的,这是一个很好的决定

但也是一个坏的,C有它的疣和所有......


在过去两周内,软件升级从

地球发送到火星,升级计划在今天进行测试。软件升级需要花费大量时间

完成数百万公里

距离!


Mars Exploration Rover软件(MER)约为
650 000行C.Ames研究中心为该软件开发了一个

静态测试仪[2]并在30分钟内完成了

它发现了...


o未初始化的变量用法

o返回本地变量的地址(!!!!)

o在常量表达式中溢出。


我想知道VXWorks系统使用什么类型的编译器

,但几乎所有我知道的编译器都会尝试

诊断出这种错误...


在Space daily [1]发布的新闻中,Green Hills软件

吹嘘

<引用>

Green Hills软件工具对火星探测器任务至关重要


两者的机会和流浪者,7月7日发射,和精神流浪者,

于6月10日推出,由软件程序指导和控制

和使用Green Hills开发工具编写的系统。


<结束报价>


Green Hills没有发出返回

a本地变量地址的诊断信息?

参考文献:

[1]
http: //www.marsdaily.com/reports/Gre..._Missions.html

[2]
http://ic.arc.nasa.gov/researchinfus...S/SMC-IT03.pdf

Mankind has now two robots wandering about in the planet Mars. No,
it wasn''t Mars that invaded Earth, but Earth that landed in Mars
more than two years ago.

After some initial OS glitches (Chris Torek can comment
on those probably) in the Spirit robot, software has done
smoothly ever since.

All the software is written in C, what is a good decision
but also a bad one, C with its warts and all...

In the last two weeks, a software upgrade was sent from
earth to Mars, and the upgrade is scheduled to be
tested this days. Software upgrades take a lot of time
when they are done with several million kilometers
distance!

The Mars Exploration Rover software (MER) is around
650 000 lines of C. The Ames research center developed a
static tester for the software [2] and in 30 minutes
it discovered...

o Un-initialized variable usage
o Returning the address of a local variable (!!!!)
o Overflow in constant expression.

I wonder what kind of compilers does the VXWorks system
use, but almost all compilers I know of will try to
diagnose this kind of errors...

In a news item published in Space daily [1], Green Hills software
boasted that
< quote >
"Green Hills Software Tools Critical To Mars Rover Missions"

Both the "Opportunity" rover, launched July 7, and the "Spirit" rover,
launched June 10, are being directed and controlled by software programs
and systems written with the use of Green Hills development tools.

< end quote >

Green Hills doesn''t emit a diagnostic for returning the address of
a local variable?
References:
[1]
http://www.marsdaily.com/reports/Gre..._Missions.html
[2]
http://ic.arc.nasa.gov/researchinfus...S/SMC-IT03.pdf

推荐答案

文章< 44 ********************* @ news.orange.fr>,

jacob navia< ja *** @ jacob.remcomp.frwrote:
In article <44*********************@news.orange.fr>,
jacob navia <ja***@jacob.remcomp.frwrote:

> o返回局部变量的地址(!!!!)
>o Returning the address of a local variable (!!!!)


> Green Hills没有发出返回<的地址的诊断信息br />一个局部变量?
>Green Hills doesn''t emit a diagnostic for returning the address of
a local variable?



我不知道这个特殊情况的细节,但是假设

代码是这样的:


int * foo(无效)

{

int local;

int *指针;


指针=&本地;


返回指针;

}


有多少编译器会发出警告?


- Richard

I don''t know the details of this particular case, but suppose the
code was something like this:

int *foo(void)
{
int local;
int *pointer;

pointer = &local;

return pointer;
}

How many compilers produce a warning for that?

-- Richard


Richard Tobinaécrit:
Richard Tobin a écrit :

文章< 44 ********************* @ news.orange.fr>,

jacob navia< ja *** @ jacob.remcomp.frwrote:

In article <44*********************@news.orange.fr>,
jacob navia <ja***@jacob.remcomp.frwrote:


>> o返回局部变量的地址( !!!!)
>>o Returning the address of a local variable (!!!!)



>> Green Hills没有发出返回
一个局部变量?
>>Green Hills doesn''t emit a diagnostic for returning the address of
a local variable?




我不知道这个特例的细节,但是假设

代码是这样的:


int * foo(void)

{

int local;

int * pointer;


指针=&本地;


返回指针;

}


有多少编译器发出警告?


- Richard



I don''t know the details of this particular case, but suppose the
code was something like this:

int *foo(void)
{
int local;
int *pointer;

pointer = &local;

return pointer;
}

How many compilers produce a warning for that?

-- Richard



是的,你是对的。那将是更难以找到的b $ b。其他错误可能比较简单:
编译时可以检测到const溢出。

Yes, you are right. That would be much more
difficult to find. The other errors are maybe
easier: const overflow can be detected at
compile time.


2006-07-23,jacob navia< ja *** @ jacob.remcomp.frwrote:
On 2006-07-23, jacob navia <ja***@jacob.remcomp.frwrote:

Richard Tobinaécrit:
Richard Tobin a écrit :

>文章< 44 ********************* @ news.orange.fr>,
jacob navia< ja *** @ jacob.remcomp.frwrote:

>In article <44*********************@news.orange.fr>,
jacob navia <ja***@jacob.remcomp.frwrote:


>>> o返回局部变量的地址( !!!!)
>>>o Returning the address of a local variable (!!!!)



>>> Green Hills没有为返回<的地址发出诊断信息br />一个局部变量?
>>>Green Hills doesn''t emit a diagnostic for returning the address of
a local variable?



我不知道这个特例的细节,但是假设
代码是这样的:

int * foo(void)
{local int;
int *指针;

指针=& local;

返回指针;


有多少编译器会发出警告?

- Richard



I don''t know the details of this particular case, but suppose the
code was something like this:

int *foo(void)
{
int local;
int *pointer;

pointer = &local;

return pointer;
}

How many compilers produce a warning for that?

-- Richard



是的,你是对的。那将是更难以找到的b $ b。


Yes, you are right. That would be much more
difficult to find.



嗯,也许将此作为​​运行时错误是可行的。使用

典型的堆栈帧布局,编译器可以轻松检查

返回(非空)指针值是否指向帧,如果是''s

案例终止进程或调用用户定义的错误处理程序或

某些。


可能不值得花费一般,

开发/调试期间可以派上用场。


-

Nils R. Weller,不来梅(德国)

我真实的电子邮件地址是``nils< at> gnulinux< dot> nl''''

....但我不是在为软件自由发言基金会!

Hmm, maybe it would be feasible to make this a runtime error. With a
typical stack frame layout, the compiler can easily check whether
returned (non-null) pointer values point into the frame, and if that''s
the case terminate the process or call a user-defined error handler or
somesuch.

Probably not worth the cost in general, but could come in handy during
development/debugging.

--
Nils R. Weller, Bremen (Germany)
My real email address is ``nils<at>gnulinux<dot>nl''''
.... but I''m not speaking for the Software Libre Foundation!


这篇关于火星上的C语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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