Ada Home
June 16, 1997

Article

Ada Makes Debugging Much Easier

by Marin David Condic
Senior Computer Engineer
Pratt & Whitney, GESP
condicma@pwfl.com

Where Ada language features made debugging our project much easier:

We were doing incremental builds of our Executive software for an embedded rocket engine control. The Executive supported seven threads of control, four of them synchronous loops. Initially, our system had the need to connect to only three of 16 interrupts and this was working just fine.

At some point we needed to utilize more interrupts and started adding the calls needed to get the runtime kernel to connect up procedures to the interrupts. For some reason, when we hooked up to interrupt 5, the software stopped running. Our embedded monitor was of no use because we hadn't finished initialization and the task hadn't started running yet. It was particularly frustrating because there was nothing "unusual" about interrupt 5 and we spent lots of time trying to figure out if we were somehow or other colliding with the RTK, spooging the interrupt vectors or what?

After much hair-pulling and work with a logic analyzer, we figured out that the software was running in a "branch to self" loop. Tracing back we discovered this was the unhandled exception trap.

At that point it was simple: We put an appropriate exception handler into the procedure connecting to the interrupts, included branches for all the standard Ada exceptions and each branch would set a variable to a unique number and - this is important - let the procedure return to the caller so that initialization could complete. From there, we could look with our monitor at the variable indicating which exception was hit - it was Storage_Error. It became obvious that we were running out of heap. We discovered that each ISR we hooked up was costing us a large chunk of heap. Reallocating the heap accordingly fixed the problem and we were back in business.

With languages that do not provide storage control or exception handlers, the software probably would have simply trashed memory for no apparent reason or not provided a clue as to why it was stopping. Or worse: it would have allocated the memory out of space it did not have and you'd only see the problem intermittently if/when the right interrupt occurred. Without exceptions and handlers this probably would have been much more difficult to detect and fix.


Do you have other stories to share about Ada and debugging?

Resources


What did you think of this article?

Very interesting
Interesting
Not interesting
Too long
Just right
Too short
Too detailed
Just right
Not detailed enough
Comments:

Page last modified: 1997-06-16