Global Sources
EE Times-India
Stay in touch with EE Times India
 
EE Times-India > Embedded
 
 
Embedded  

Using static analysis to debug embedded software

Posted: 25 Jul 2014     Print Version  Bookmark and Share

Keywords:software  embedded systems  bugs  code coverage  static source code analysis 

About 30 years ago, I had my first real job in embedded systems. I was head of a team developing software for a first-generation medical intensive care monitor. (The device was roughly a cubic meter in size, not the smaller-than-a-toaster medical monitors we see today.)

One day I got called into the company President's office. After he shut the door behind me, he asked, "Hey David, please tell me why you can't get your software right the first time." He appeared to be getting more and more angry as he continued, "You report that you finished writing the software; and then you go on for months and months after that working on getting so-called 'bugs' out of the software before the software's 'ready' to try out in a real medical environment." "Why can't you guys just write the software correctly the first time, and save yourselves a lot of frustration, and save me a lot of money??" Back then in the 1970's, I couldn't answer those questions. I thought I was about to be fired, and that my embedded systems career would be over right then and there.

Now let's fast-forward to the present. Thirty years have gone by, and the embedded community has learned a lot about the economics and management of software development [1]. But still today more than half of all software development time continues to be spent finding and repairing defects in code.

Recently a new glimmer of hope has appeared on the software development horizon, in the form of a new generation of static source code analysis tools. These are tools that analyse software code bases for bugs and other defects without actually running the programs that are built from the software. They're based on algorithms that go over source code with the finest of fine-toothed combs searching for software faults. Faults can be found early in the development process, so as to improve software quality as well as save developers time. Such tools can cover the execution paths through a code base in a fully automated way, and identify complex defects including bugs involving interactions among multiple procedures.

Code coverage criteria
A basic issue in efforts to identify and rid software of defects is the question of code coverage, which asks what portion of a code base is to be examined, and at what level of depth is it to be examined. The spectrum of possible code coverage options includes line coverage and path coverage.

Line coverage measures the fraction or percentage of the total number of lines of code that are to be examined for defects. Many embedded projects strive for 100% line coverage, although some fall short of this goal since technical difficulties may be encountered. For example it is often quite difficult, if not impossible, to create black-box test cases that will exercise every last line of code in a large code base. So very often only partial line coverage is achieved.

But on the other hand, even when 100% line coverage is achieved, it is far from certain that all defects in the code have been identified. Here's an example:

In this example, a single test case that calls npd_switcher(1); is sufficient to cause every line of code in the function to execute. So 100% line coverage is achieved. But, there's still a very serious bug in this code: When input variable cond has value 0, the last assignment statement in the function will attempt to write to address #0. Such a "null pointer de-reference" is never a good thing. So we've seen a very basic bug go undiscovered despite 100% line coverage.

1 • 2 • 3 • 4 Next Page Last Page



Comment on "Using static analysis to debug embed..."
Comments:  
*  You can enter [0] more charecters.
*Verify code:
 
 
Webinars

Seminars

Visit Asia Webinars to learn about the latest in technology and get practical design tips.

 

Go to top             Connect on Facebook      Follow us on Twitter      Follow us on Orkut

 
Back to Top