Live View for Variables and Memory

Debugging is usually a ‘stop-inspect-continue’ process. That does not work very well for watching a system which continuously changes its state. For this usually I toggle an LED, or write things to the console to watch with a human eye what is going on. But there is something very powerful in the CodeWarrior debugger too: to display variables and memory content while the target is running.

Variable Live View

Variable Live View

Global Variables

The feature works with memory and (global) variables. For example I have a global ‘cnt’ counter variable which counts up and down depending on my system state:

Global Counter Variable

Global Counter Variable

Eclipse only shows me that variable while I’m in its implementation module. In order to have it visible all the time, I add it to the Global Variables:

Add Global Variables

Add Global Variables

Next I select the variable and press OK:

Add Globals

Add Globals

Now if I run my application, that variable is always visible:

Running with Variable shown

Running with Variable shown

Enable Live View

But: the variable value is ‘frozen’ while the debugger is running. I need to stop it to see the new value. To enable the ‘Live View’ to have it updated regularly while the debugger is running, I need to enable the ‘Refresh While Running’ option:

Refresh While Running Enabled

Refresh While Running Enabled

Now the variable content is constantly refreshed while running:

Variable Constantly Refreshed

Variable Constantly Refreshed

❗ What happens is: the debugger reads periodically from the target. While this is using ‘free’ cycles (e.g. on BDM), and does not stop the target, this still might be somewhat intrusive. This means: it will impact the execution speed on the target. So be careful about adding too much to watch this way. The other thing is: the feature depends heavily on the speed of the debug connection: While it works with OSBM/OSJAG/OpenSDA, it is really slow. It works better with a faster connection like Segger or P&E USB Multilink.

Live View for Memory

The same thing works for the Memory View where I can enable the ‘Live View’ or ‘Refresh While Running’ mode:

Refresh While Running for Memory

Refresh While Running for Memory

❗ Be aware that for the memory the debugger has to read data, so here you need a fast debug connection. Additionally it seems that the debugger needs to read a whole bunch of memory as I cannot just read a single or set of memory address (I could use a constant pointer instead in the Variables view). As such, Live View in the memory view is really slow, at least with OSBDM/OSJTAG/OpenSDA. Up to the point it is not really useful at all for Memory.

Now the question is: how to configure the refresh period? There is a setting or this in the debug/launch configuration:

Refresh while Running Setting

Refresh while Running Setting

Summary

That feature helps me to watch directly with the debugger variables. It is understood that things are intrusive, and depends on the connection speed (another good reason to invest a few $ into a good BDM/JTAG wiggler and not rely on OpenSDA/OSBDM/OSJTAG only).

If used wisely (few variables, reasonable refresh time), this feature is very useful for me.

Happy Viewing 🙂

22 thoughts on “Live View for Variables and Memory

  1. That is very helpful to see the running variables. This also seems to help with large structures. Normally when a structure is expanded at a breakpoint it is then collapsed when the debugger leaves the scope of the variable. This is time consuming because the structure then has to be expanded again to see an element when the breakpoint is hit, but with the ‘live view’ the structure stays expanded while running. (this works most of the time, sometimes it will collapse while running but even sometimes is a help on a union of structures and structures with structures and so on…), thank you. Robert

    Like

  2. Pingback: Tutorial: ADC with the Freedom Board | MCU on Eclipse

  3. Pingback: Tutorial: FreeMASTER Visualization and Run-Time Debugging | MCU on Eclipse

  4. Wow, your Blog helped me so much with using CW 10.5 for Coldfire! All the tricks you show make my life so much easyer. It’s a pitty the freescale support doesn’t know as much as you do about using CW 10.5.

    I was askin myself if it’s also possible to ad public class members to the global view (and refresh them automatically), but I wasn’t able to add them…
    is there some trick or does it not work?

    Like

    • Hi Moritz,
      thanks for that feedback, appreciated. I think the difference between is that I actually use their products for real stuff and projects, and not just for demos 😉

      As for your question: make sure that the variable is really global and not static (make have it with ‘external’ linkage). Otherwise you might not be able to add it the global variables view. I just verified it again with my MCF52259 board/project, and that works for me.

      Good luck!

      Like

  5. Pingback: Comparing CodeWarrior with Kinetis Design Studio | MCU on Eclipse

  6. Pingback: Automatic Variable, Expression and Memory Display with GDB and Eclipse | MCU on Eclipse

  7. Hello! Thank you very much!
    I have a question, how can I do the same thing with eclipse?
    My system consists of STM32 – OpenOCD – gdb – Eclipse.

    Many thanks in advance.

    Giulio

    Like

  8. when I right click to add global variables, the global variables option is not available. it is a light grey and doesn’t let me click it. any suggestions?

    Thanks
    -Chris

    Like

  9. Pingback: P&E ARM Cortex-M Debugging with FreeRTOS Thread Awareness and Real Time Expressions for GDB and Eclipse | MCU on Eclipse

  10. I don’t have any of the options you mentioned above like adding global, toggling live view buttons and such, why?

    Like

  11. Pingback: Visualizing Global Variables while Target is Running with Eclipse and MCUXpresso IDE | MCU on Eclipse

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.