12.07.2015 Views

Static Analysis of the Mars Exploration Rover Flight Software - NASA

Static Analysis of the Mars Exploration Rover Flight Software - NASA

Static Analysis of the Mars Exploration Rover Flight Software - NASA

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

sometimes as blocks <strong>of</strong> integers or sometimes as blocks <strong>of</strong>floats. Worse, sometimes block <strong>of</strong> integers hide addresses(that have been cast as integers). This coding practicemay be convenient for embedded systems, but it confusesstatic analyzers which cannot rely on a clean, consistenttype system.Finally, we would like to come back to one <strong>of</strong> <strong>the</strong>errors we found. Recall that a data structure had tw<strong>of</strong>ields, one holding data values and <strong>the</strong> o<strong>the</strong>r giving astatus on <strong>the</strong> availability, or validity, <strong>of</strong> <strong>the</strong> data. Theerror was that <strong>the</strong> data field was accessed without beingset. The proper use <strong>of</strong> this coding construct is that <strong>the</strong>status flag should always been set by <strong>the</strong> routines thatmay write in <strong>the</strong> data field, and <strong>the</strong> use <strong>of</strong> <strong>the</strong> data field ino<strong>the</strong>r routines should always be protected by a test on <strong>the</strong>flag as follows:can also be used as abstract debuggers in thisphase.• S<strong>of</strong>tware Unit Testing: This is <strong>the</strong> phase inwhich current analyzers will perform at <strong>the</strong>irbest. Units can be verified for a wide range <strong>of</strong>inputs for a low cost.• S<strong>of</strong>tware Integration: This is currently beyond<strong>the</strong> reach <strong>of</strong> commercial static analyzers. Theycannot scale to full size systems and deliverenough precision. However, <strong>the</strong>y can still beused as abstract debuggers in this phase.Syst. Reqs.SystemQualif. Testing...if (p->status == VALID) {data = p->data;...}...Syst. Arch.DesignS/W Req.<strong>Analysis</strong>S/W Qualif.TestingSystemIntegrationFrom a static analysis point <strong>of</strong> view, it is difficult totrack <strong>the</strong> value <strong>of</strong> <strong>the</strong> status flag. Therefore, <strong>the</strong> use <strong>of</strong> <strong>the</strong>data field will always be flagged as an orange eventhough <strong>the</strong> code is absolutely correct. This example istypical <strong>of</strong> cases where a static analyzer needs to be able torecognize safe coding patterns. Ano<strong>the</strong>r solution wouldconsist <strong>of</strong> providing annotations. However, we do notrecommend such solutions since potential users aregenerally averse to writing annotations, especially indevelopment environments with stringent timeconstraints.5.2. Using <strong>Static</strong> <strong>Analysis</strong>The final point we wish to address is when staticanalysis should be used. Does it belong in developmentphases or unit testing or system integration? Where is it<strong>the</strong> most effective? To answer this question, we will relyon <strong>the</strong> traditional V diagram representing s<strong>of</strong>twarelifecycle as shown in Figure 1.We recommend <strong>the</strong> use <strong>of</strong> static analysis from <strong>the</strong>S<strong>of</strong>tware Detailed Design phase to <strong>the</strong> S<strong>of</strong>twareIntegration phase if possible. Current static analysis toolscan be applied without any problem from S<strong>of</strong>twareCoding to S<strong>of</strong>tware Unit testing. Current scalabilityproblems prevent <strong>the</strong>ir full use in <strong>the</strong> S<strong>of</strong>tware Integrationphase.• S<strong>of</strong>tware Coding: <strong>Static</strong> analyzers can be usedas sophisticated compilers because <strong>the</strong>y performstricter checks with respect to <strong>the</strong> ISO standardand <strong>the</strong>y use advanced alias algorithms. TheyS/WArch.DesignS/W DetailedDesignKEYPhaseProductVerifyValidate<strong>Static</strong> <strong>Analysis</strong>S/W CodingS<strong>of</strong>twareIntegrationS/W UnitTestingFigure 1. Place <strong>of</strong> <strong>Static</strong> <strong>Analysis</strong> in S/W Lifecycle.The use <strong>of</strong> static analyzers as debuggers is interesting;it provides a new way to approach oranges (false alarms).Basically it works as follows. All red errors (unsafechecks) are <strong>of</strong> course corrected. Then, only some orangesare analyzed. Based on previous experiences, one mightdecide to look for certain types <strong>of</strong> oranges (e.g., NIVerrors). Ano<strong>the</strong>r approach is to look for isolated oranges.It is rare that analysis approximations lead to isolatedoranges. It usually leads to a cluster <strong>of</strong> orange checks. So,an isolated orange might be <strong>the</strong> sign <strong>of</strong> a deeper problem.Whatever selection criterion is used, <strong>the</strong> main point is thatnot all oranges are being checked manually. Only those

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!