{"id":14465,"date":"2017-10-12T09:00:30","date_gmt":"2017-10-12T16:00:30","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudio\/?p=14465"},"modified":"2019-03-18T23:20:45","modified_gmt":"2019-03-19T06:20:45","slug":"step-back-while-debugging-with-intellitrace","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/step-back-while-debugging-with-intellitrace\/","title":{"rendered":"Step-back while debugging with IntelliTrace"},"content":{"rendered":"<p>Have you ever stepped while debugging, realized that you\u2019ve taken one step too far, and wished you could step back? Or, while stepping, saw a variable change in an unexpected way, and wish you could go back a step and see what its value was before? Now you can, all without having to restart debugging to recreate the state again!<\/p>\n<p>In <a href=\"https:\/\/www.visualstudio.com\/vs\/preview\/\">Visual Studio Enterprise 2017 version 15.5 Preview<\/a>, we are introducing IntelliTrace\u2019s new \u201cstep-back\u201d feature. IntelliTrace now automatically takes a snapshot of your application on each breakpoint and debugger step you take. This enables you to go back to previous breakpoints or steps and view the state of the application as it was in the past.<\/p>\n<p>Let\u2019s see it in action.<\/p>\n<h2>Debugging with step-back<\/h2>\n<p>First, to enable the feature, go to <b>Tools<\/b>, <b>Options<\/b>, <b>IntelliTrace<\/b> settings, and select the option \u201cIntelliTrace events and snapshots.\u201d<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/Turn-it-on-in-Tools-Options-IntelliTrace-General.png\" rel=\"noopener noreferrer\"><img decoding=\"async\" title=\"Turn it on in Tools Options IntelliTrace General\" alt=\"Turn it on in Tools Options IntelliTrace General\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/Turn-it-on-in-Tools-Options-IntelliTrace-General.png\" \/><\/a><\/p>\n<p>IntelliTrace step-back is designed to integrate into your everyday debugging experience.<\/p>\n<p>As you\u2019re debugging, IntelliTrace records your steps and breakpoint events in the <b>Events<\/b> tab in the <b>Diagnostic Tools<\/b> window. When the step-back feature is enabled, it will also take a snapshot of your application on each debugger step and breakpoint that is hit. A camera icon will appear next to the events for which a snapshot is available.<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/StepBackEventsTabWithSnapshots.png\" rel=\"noopener noreferrer\"><img decoding=\"async\" title=\"Camera icon next to events for which a snapshot is available\" alt=\"Turn it on in Tools Options IntelliTrace General\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/StepBackEventsTabWithSnapshots.png\" width=\"356\" height=\"313\" class=\"\" \/><\/a><\/p>\n<p><i>Note: For performance reasons, snapshots are not taken when you step very quickly. If no camera icon appears next to the step, try varying your stepping speed. <\/i><\/p>\n<h2>Using the new Step Backward and Forward buttons<\/h2>\n<p>You can use step-back via the new Step Backward and Step Forward icons in the Debug toolbar. These icons navigate the events in the Events Tab.\u00a0So, if you\u2019ve just taken a step in live debugging (F10 or F11), you can use the Step Backward button to quickly navigate to the previous step. This will automatically put Visual Studio in Historical debugging mode, at the line of code you\u2019ve stepped back to. Historical debugging is what we call the view of the application in the past.<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/Step-Back-Forward-Buttons.gif\" rel=\"noopener noreferrer\"><img decoding=\"async\" title=\"Step Back Forward Buttons\" alt=\"Step Back Forward Buttons\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/Step-Back-Forward-Buttons.gif\" \/><\/a><\/p>\n<p>In this mode, you\u2019ll be able to see the values of your Call Stack, Locals, and Watches, just as you would in regular, live debugging. You can also evaluate expressions in the Watch Window and hover over variables to see data tips. All these values are populated using the data from the snapshot.<\/p>\n<p>The data IntelliTrace previously recorded for debugger events only captured the variables you\u2019d already expanded in the Locals window at that point in time. However, the data associated with a snapshot contains a view of the entire heap, including any complex objects.<\/p>\n<p><i>Note: Unlike using Set Next Statement and re-running your code, viewing a snapshot doesn\u2019t re-run your code; it gives you a static view of the state of the application at a point in time that has occurred in the past. <\/i><\/p>\n<p>You can then use the Step Forward and Step Backward buttons to navigate between these events in the past. To return to live debugging, you can hit Continue (F5) or the Return to Live Debugging link in the gold bar.<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/Return-to-Live-Debugging.png\" rel=\"noopener noreferrer\"><img decoding=\"async\" title=\"Return to Live Debugging\" alt=\"Return to Live Debugging\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/Return-to-Live-Debugging.png\" width=\"648\" height=\"96\" class=\"\" \/><\/a><\/p>\n<h2>Viewing snapshots via the Diagnostic Tools window<\/h2>\n<p>Snapshots can also be viewed from the Events tab in the Diagnostic Tools window.\u00a0To view a snapshot, first select the event you\u2019re interested in. Then, either click directly on the camera icon, or click the \u201cActivating historical debugging\u201d link on the event. Once you\u2019ve done either of these actions, Visual Studio will be put in <b>Historical Debugging<\/b> mode at the line of code related to the event you\u2019ve selected.<\/p>\n<p>From here, you\u2019ll be able to see the values of your Call Stack, Locals, and Watches, just as you would in regular, live debugging. You can also evaluate expressions in the Watch Window and hover over variables to see data tips.<\/p>\n<p><iframe width=\"750\" height=\"450\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/10\/StepBack_Entire_video.mp4\" allowfullscreen=\"allowfullscreen\" frameborder=\"0\"><\/iframe><\/p>\n<p>With the new IntelliTrace step-back feature, you\u2019ll be able to quickly step-back to previous debugger steps and breakpoints and view the state of your application in the past \u2013 all without having to restart debugging to reproduce the application state.<\/p>\n<h2>Try it out<\/h2>\n<p>The IntelliTrace step-back feature is available in <a href=\"https:\/\/www.visualstudio.com\/vs\/preview\/\">Visual Studio Enterprise 2017 version 15.5 Preview<\/a>, and requires Windows 10 Anniversary Update or above. The feature is currently supported for WinForms, WPF, Managed Console apps, and Managed Class Libraries. Support for debugging ASP.NET applications with IIS Express will be available in an upcoming release of Visual Studio. <b><\/b><\/p>\n<p><a target=\"_blank\" href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/Viewing-Snapshots-via-Diagnostics-Tool-Window.png\" rel=\"noopener noreferrer\"><img decoding=\"async\" title=\"Viewing Snapshots via Diagnostics Tool Window\" alt=\"Viewing Snapshots via Diagnostics Tool Window\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/Viewing-Snapshots-via-Diagnostics-Tool-Window.png\" \/><\/a><\/p>\n<p>We\u2019d love to hear your feedback. To report issues, use the <a href=\"https:\/\/aka.ms\/vs-rap\">Report a Problem<\/a> tool in Visual Studio. You\u2019ll be able to track your issues in the <a href=\"https:\/\/developercommunity.visualstudio.com\/\">Visual Studio Developer Community<\/a> where you can ask questions and find answers. You can also make a product suggestion through <a href=\"https:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio-ide\/category\/31799-debugging-and-diagnostics\">UserVoice<\/a>, or email the team directly at <a>stepback@microsoft.com<\/a>.<\/p>\n<table cellspacing=\"0\" cellpadding=\"2\" width=\"600\" border=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"150\"><img decoding=\"async\" width=\"150\" height=\"410\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/Deborah-Chen.jpg\" \/><\/td>\n<td valign=\"top\" width=\"450\"><strong>Deborah Chen<\/strong>, Program Manager, Visual Studio Diagnostics\n<a href=\"https:\/\/twitter.com\/chendeborah\">@ChenDeborah<\/a><\/p>\n<p>Deborah is a program manager on the Visual Studio Diagnostics team, working on IntelliTrace.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever stepped while debugging, realized that you\u2019ve taken one step too far, and wished you could step back? Or, while stepping, saw a variable change in an unexpected way, and wish you could go back a step and see what its value was before? Now you can, all without having to restart debugging [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[472,155,1029],"tags":[237,85,9,321,182,156],"class_list":["post-14465","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gaming","category-visual-studio","category-web","tag-net","tag-asp-net","tag-debug","tag-intellitrace","tag-unity","tag-visual-studio-2017"],"acf":[],"blog_post_summary":"<p>Have you ever stepped while debugging, realized that you\u2019ve taken one step too far, and wished you could step back? Or, while stepping, saw a variable change in an unexpected way, and wish you could go back a step and see what its value was before? Now you can, all without having to restart debugging [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/14465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=14465"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/14465\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=14465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=14465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=14465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}