Tracing The Almost Perfect Program

Nov. 6, 2009
Debugger Services Framework (DSF) and other trace tools

Those of you who write perfect programs the first time around may leave the room. Now for the rest of us, what debug tools do you use?

The crude but effective printf (for C and C++) is probably at the top of everyone’s list. Variations include watch variables in debuggers and control panels for graphical environments like National Instruments’ LabVIEW, but the idea is the same—see what the program is doing and then figure out what’s going wrong.

Unfortunately, printf is often the only technique many programmers know about when it comes to debugging. The problem is that the technique is so easy, at least initially and for small projects, that other debugging tools are frequently overlooked. Some programmers take advantage of conditional compilation so debugging support can be maintained with the program. But the typical approach still adds and deletes printf statements.

Many debuggers provide sophisticated watch windows and macro support that are designed to expose the interior of a running application. These aids are invaluable. Like text editors and the integrated development environments (IDEs) of old, however, they’re distinctly unique.

This isn’t an issue in dealing with a particular debugger for a project, though it makes migration to a new debugger frustrating and tedious. The lack of consistency between debuggers often leads to the least common denominator, the GNU GDB debugger, at least for C/C++.

In the embedded world, collections of open-source tools from different vendors generally include the same compilers and linkers, but a proprietary package often replaces the debugger. This is frequently the case when vendors of development tools migrate to the Eclipse IDE, which is common these days. In this case, the original debugger comes along for the ride.

The printf approach to debugging is essentially the poor man’s version of a trace tool. Developers are usually aware of trace tools, but they typically target tracing system level interfaces. Likewise, hardware trace probes are well known to hardware developers but tend to be overlooked by software developers as useful application debugging tools.

HARDWARE PRINTF
Another overlooked tool, the hardware printf, takes advantage of unused hardware resources such as I/O ports that can be hooked to a logic analyzer to deliver a hardware trace facility. Alternatively, the outputs can drive LEDs or other user interface hardware. This approach gets more interesting in dealing with flexible hardware architectures such as FPGAs and Cypress Semiconductor’s PSoC 3 and 5 microcontrollers (see “Field Programmable I/O Augments 8-Bit Microcontroller”). In these cases, internal signals can be made available without software interaction. Likewise, the ability to add custom logic allows trace information to be massaged.

WORK IN PROGRESS
One interesting emerging option is the Eclipse project’s Debugger Services Framework (DSF). DSF-GDB is building the GDB debugger on DSF and adding new features for reverse debugging, multiprocess, and non-stop debugging support.

It will be the basis for the current GDB 7. DSF provides a modular approach to the debugger and should provide extensibility similar to the rest of the Eclipse framework. This should permit a more extensible debugger while enabling the kinds of extensions in proprietary debuggers.

So if you don’t initially spawn perfect programs, let me know what your debugging regimen is like and how your debugger and trace tools fare against the competition.

ECLIPSEwww.eclipse.org

About the Author

William G. Wong | Senior Content Director - Electronic Design and Microwaves & RF

I am Editor of Electronic Design focusing on embedded, software, and systems. As Senior Content Director, I also manage Microwaves & RF and I work with a great team of editors to provide engineers, programmers, developers and technical managers with interesting and useful articles and videos on a regular basis. Check out our free newsletters to see the latest content.

You can send press releases for new products for possible coverage on the website. I am also interested in receiving contributed articles for publishing on our website. Use our template and send to me along with a signed release form. 

Check out my blog, AltEmbedded on Electronic Design, as well as his latest articles on this site that are listed below. 

You can visit my social media via these links:

I earned a Bachelor of Electrical Engineering at the Georgia Institute of Technology and a Masters in Computer Science from Rutgers University. I still do a bit of programming using everything from C and C++ to Rust and Ada/SPARK. I do a bit of PHP programming for Drupal websites. I have posted a few Drupal modules.  

I still get a hand on software and electronic hardware. Some of this can be found on our Kit Close-Up video series. You can also see me on many of our TechXchange Talk videos. I am interested in a range of projects from robotics to artificial intelligence. 

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!