TruePERSPECTIVES_logo.png

Use DYNAMIC printf() during your debug sessions [be lazy and save time]

Posted by Magnus Unemyr on Sep 19, 2016 1:56:23 PM

printf()-style debugging has been around since the beginning of time (at least, since the beginning of the software industry). As popular as printf() debugging has been, and still is, it is very inconvenient and time-consuming.
 
Not only do you have to clutter your code with printf() instrumentation, you have to rebuild and relaunch the debug session every time you need to watch a new condition, and you lose the debug context every time you do so. But now, there is a better way: Dynamic printf().
dynprintfcollage.png
If you commonly find yourself changing your printf() instrumentation, you will love the new dynamic printf() functionality of the TrueSTUDIO debugger. You don’t need to add printf() statements to the code anymore to get the printf() output you want and need. Thus, there is no recompile, relink and debugger relaunch cycle that waste time and wipe out your debug context.
 
So what is this dynamic printf()? It is a temporary breakpoint that can emit printf() output once the code hits it. Thus, you can add or remove dynamic printf() output in the middle of a debug session, as need arise and change.
 
From a user point of view, right-click on the desired code line in the debugger, and “Add a Dynamic Printf”. Then define what output you want when execution hits the defined code line. The output string can even include variable values, using formatting keywords like "%i".
 
Now, you will get printf() output in the debugger console, even with live variable values, as soon as the execution path passes the relevant code line. Gone are the days when you need to clutter the code with printf() statements, and recompile, relink and relaunch a debug session to get your output instrumentation to see what happens when the code executes.
 
Do you want to learn more on ARM development tools and Atollic TrueSTUDIO? Read this whitepaper:
 
Read our ARM development  whitepaper!

 

Topics: Debugging, ECLIPSE, Atollic TrueSTUDIO