{"id":5843,"date":"2020-06-05T20:09:45","date_gmt":"2020-06-06T03:09:45","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=5843"},"modified":"2025-08-05T20:26:33","modified_gmt":"2025-08-06T03:26:33","slug":"live-variables","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/documentation\/livevars\/","title":{"rendered":"Live Variables \/ Live Watch"},"content":{"rendered":"<p>The Live Watch feature (previously known as Live Variables) allows examining the state of global variables in your embedded program without stopping the program execution:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/overview.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6249\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/overview.png\" alt=\"\" width=\"884\" height=\"388\" \/><\/a><\/p>\n<h2>Overview<\/h2>\n<p>VisualGDB supports live variables for the following targets:<\/p>\n<ul>\n<li>ARM Cortex targets when using:\n<ul>\n<li>OpenOCD<\/li>\n<li>Segger J-Link Software<\/li>\n<li>LPC-Link GDB Server<\/li>\n<\/ul>\n<\/li>\n<li>RISC-V targets when using OpenOCD<\/li>\n<\/ul>\n<p>Live Watch supports 3 primary views (<a href=\"#globals\">Globals<\/a>, <a href=\"#watch\">Watch<\/a> and <a href=\"#plugin\">Plugin<\/a>) and includes a few additional tools that simplify the analysis of the captured data.<\/p>\n<h2><a id=\"globals\"><\/a>Globals View<\/h2>\n<p>This view shows all globals variables (including the static variables inside functions or classes). It operates independently from the gdb debugger, so you can explore the state of your program without ever having to stop it:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/globals.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6252\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/globals.png\" alt=\"\" width=\"891\" height=\"358\" \/><\/a><\/p>\n<h6>Advanced Data Types<\/h6>\n<p>The Live Watch window can automatically handle arrays, structures, strings, enums and pointers. To avoid flickering for rapidly changing pointers, it will not automatically replace the child nodes under a changed pointer, however it will mark them outdated. Clicking the &#8220;refresh&#8221; button near the pointer node will automatically update the children:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/invalidated.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6253\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/invalidated.png\" alt=\"\" width=\"891\" height=\"362\" \/><\/a><\/p>\n<h6>Filtering<\/h6>\n<p>You can quickly find specific global variables (or fields inside structures) by using the &#8220;filter&#8221; input:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/filter-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6255\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/filter-1.png\" alt=\"\" width=\"718\" height=\"176\" \/><\/a><\/p>\n<p>Filtering works very fast and will leave out the nodes containing the filter string in their name, or anywhere under their child nodes. This only involves analyzing the variable types and does not result in any extra memory reads. E.g. in the example above, <strong>s_pRootNode<\/strong> was shown because it contains a field called &#8220;Next&#8221;.<\/p>\n<p>You can press &#8220;Enter&#8221; in the filter box to automatically expand all parent nodes, showing the variables that actually matched the filter.<\/p>\n<h6>Favorites<\/h6>\n<p>You can tag specific nodes in the Globals view as favorite and then use the <strong>Favorite<\/strong> filter to quickly view them: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/fav.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6256\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/fav.png\" alt=\"\" width=\"719\" height=\"302\" \/><\/a>The favorite flag is preserved across debug sessions and is stored in the <strong>.vgdbsettings.user<\/strong> file.<\/p>\n<h6>Source Annotations<\/h6>\n<p>If you enable the Source Annotations mode in the Live Watch window (Globals view only), VisualGDB will show the live values of global variables directly in the code (requires using the Clang IntelliSense engine): <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/06\/annotations.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6269\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/06\/annotations.png\" alt=\"\" width=\"1003\" height=\"381\" \/><\/a>Clicking on the annotations will automatically go to the related variable in the Live Watch window, so you could change its type, or plot it.<\/p>\n<h2><a id=\"watch\"><\/a>Watch View<\/h2>\n<p>This view is every similar to the regular Visual Studio&#8217;s Watch windows. You can add new variables by entering arbitrary expressions in the list and VisualGDB will evaluate their address and create Live Variables based on them:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/watch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6251\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/watch.png\" alt=\"\" width=\"892\" height=\"263\" \/><\/a>Note that adding Live Variables in the Watch mode may temporarily stop the gdb session, so that VisualGDB could evaluate the address of the variable. If this is not intended, please use the <a href=\"#globals\">Globals view<\/a> instead.<\/p>\n<h2><a id=\"plugin\"><\/a>Plugin View<\/h2>\n<p>Live Watch supports plugins that can analyze the values of raw variables and present it in a more meaningful way (requires Custom edition or higher). VisualGDB is shipped with plugins for <a href=\"https:\/\/github.com\/sysprogs\/VisualGDBExtensibilityExamples\/tree\/master\/LiveWatchPlugins\/StackAndHeapLiveWatch\">analyzing the stack\/heap usage<\/a> and <a href=\"https:\/\/github.com\/sysprogs\/RTOSPlugins\/tree\/master\/PluginFreeRTOS\/LiveWatch\">visualizing FreeRTOS internals<\/a>. Both plugins are open-source, so you can extend VisualGDB to analyze and visualize domain-specific structures:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/plugin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6257\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/plugin.png\" alt=\"\" width=\"718\" height=\"425\" \/><\/a><\/p>\n<h2>Plotting<\/h2>\n<p>VisualGDB can plot the values of the selected variables, so that you can observe how they change over time:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/06\/live2-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8997\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/06\/live2-3.png\" alt=\"\" width=\"844\" height=\"448\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/06\/live2-3.png 844w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/06\/live2-3-300x159.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/06\/live2-3-768x408.png 768w\" sizes=\"(max-width: 844px) 100vw, 844px\" \/><\/a>You can turn the graph view on and off via the &#8220;Graph&#8221; button (1), customize the scaling and updating options (3), or export the data to a CSV file (4). If you need to quickly locate the plotted variables in the list, you can enable the &#8220;plotted variables only&#8221; filter (2). You can also switch between different scaling options (5) or enable\/disable the legend (6) via the options view.<\/p>\n<p>Pausing the graph view allows exploring the exact values of the variables captured at each time point:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/pause.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6260\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/pause.png\" alt=\"\" width=\"862\" height=\"422\" \/><\/a>You can use the mouse to select an arbitrary time period in the graph view, and see various statistical information about the variables (e.g. minimum, maximum, average, standard deviation), as well as the average growth rate:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/06\/range.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7403\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/06\/range.png\" alt=\"\" width=\"846\" height=\"453\" \/><\/a>The context menu on the graph area allows exporting the selected data into a CSV file, or zooming into it.<\/p>\n<p>You can also zoom the graph in our out via the mouse wheel, or pan it left and right by holding the <strong>Shift<\/strong> key and moving it with the mouse.<\/p>\n<h2>Breakpoints<\/h2>\n<p>You can set breakpoints on Live Variables by clicking in the <strong>Breakpoint<\/strong> column:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/bkpt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6261\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/bkpt.png\" alt=\"\" width=\"860\" height=\"427\" \/><\/a>As soon as VisualGDB spots a matching value while querying the live variable, it will immediately stop the program and display more information. This does not consume any hardware breakpoints, however it won&#8217;t catch the exact location in the code where the variable was changed.<\/p>\n<h2>Settings<\/h2>\n<p>You can tweak various aspects of Live Watch via <strong>Tools-&gt;Options-&gt;VisualGDB-&gt;Embedded-&gt;Live Variables<\/strong>. Simply search for &#8220;Live&#8221; on <a href=\"https:\/\/visualgdb.com\/settings\/\">this page<\/a> for a detailed list of settings. Below are the explanations for the most commonly used settings:<\/p>\n<h6>Default Colors<\/h6>\n<p>This setting allows overriding the default colors used by VisualGDB to plot Live Variables. Simply enter a comma-separated list of RGB values (e.g. ff0000;0000ff;00ff00) and VisualGDB will use them next time you start plotting a variable.<\/p>\n<h6>Expand NULL Pointers<\/h6>\n<p>If set, VisualGDB will treat NULL pointers as any other valid pointers, showing their children in the Live Watch window. If unset, VisualGDB will display a [Null Pointer] stub instead.<\/p>\n<h6>Maximum String Size<\/h6>\n<p>This setting allows tweaking the maximum size of the string variables queried by VisualGDB. This is done to minimize performance penalty for large buffers. E.g. if you add a live watch for a &#8220;<strong>char g_Buffer[1024]<\/strong>&#8221; variable in the string mode, the actual amount of bytes read from <strong>g_Buffer<\/strong> will never exceed the value of this setting.<\/p>\n<h6>Stack Border Watch Size<\/h6>\n<p>When using VisualGDB to dynamically monitor the used stack, it will initially fill the entire stack with a fixed pattern (<strong>Unused Stack Fill Pattern<\/strong>), and will monitor how much of that pattern was overwritten. VisualGDB will then monitor a fixed amount of bytes near the previous known stack border:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/stack-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6263\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/03\/stack-1.png\" alt=\"\" width=\"1149\" height=\"379\" \/><\/a><\/p>\n<p>This will work even if the stack usage grows by a large amount at once, but could skip a change, if the stack skipped a large area (e.g. reserved space for a large variable, but never used it). To get 100% accurate stack usage report at a much slower rate, increase the value of this setting (e.g. to 1M).<\/p>\n<h6>Value Scaling Anchors<\/h6>\n<p>Unless you are using the &#8220;Scale each variable independently&#8221; mode, VisualGDB will try to pick round numbers for the graph bounds (i.e. X \u00d7 10<sup>Y<\/sup>). This setting allows overriding the allowed values of <strong>X<\/strong>.<\/p>\n<h2>Read More<\/h2>\n<p>See <a href=\"https:\/\/visualgdb.com\/tutorials\/arm\/livevars\/\">this tutorial<\/a> for a detailed step-by-step example of using Live Variables.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Live Watch feature (previously known as Live Variables) allows examining the state of global variables in your embedded program<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[197],"tags":[],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/5843"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=5843"}],"version-history":[{"count":10,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/5843\/revisions"}],"predecessor-version":[{"id":8998,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/5843\/revisions\/8998"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=5843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=5843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=5843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}