{"id":2413,"date":"2013-10-14T08:00:00","date_gmt":"2013-10-14T08:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2013\/10\/14\/data-breakpoints\/"},"modified":"2022-07-18T23:49:08","modified_gmt":"2022-07-19T07:49:08","slug":"data-breakpoints","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/data-breakpoints\/","title":{"rendered":"Data Breakpoints"},"content":{"rendered":"<p>This blog post is part of a series on <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2013\/10\/07\/breakpoints-in-visual-studio-2013.aspx\">breakpoints<\/a> in the Visual Studio <span style=\"font-family: arial,helvetica,sans-serif;font-size: small\">debugger and has been updated to reflect the experience of using Visual Studio 2015. <\/span><span style=\"font-family: arial,helvetica,sans-serif;font-size: small\">If you are interested in details about setting data breakpoints <\/span><span style=\"font-family: arial,helvetica,sans-serif;font-size: small\">using earlier versions of Visual Studio please see the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/vstudio\/350dyxd0(v=vs.100).aspx\">MSDN Documentation<\/a>.<\/span><\/p>\n<p>Data breakpoints are a powerful feature that is currently available to C++ developers. Data breakpoints allow you to stop execution when a particular piece of memory has changed. This can be very useful for solving corruption issues.<\/p>\n<p>To demonstrate this feature, we will use\u00a0our\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/6\/2019\/02\/NativeBreakpointsSample.zip\">C++ example<\/a>.\u00a0 Looking at our code we\u2019ve noticed that the Result of PrintObject is not correct. It is giving us a result of 27, but we believe that the result should be 32.<\/p>\n<p><img decoding=\"async\" style=\"border: 0px\" title=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/10\/8562.image_thumb_623A55DE.png\" alt=\"image\" width=\"672\" height=\"266\" border=\"0\" \/><\/p>\n<p>To investigate this, we set a breakpoint in the PrintObject function and inspect the values that it is summing.<\/p>\n<p><img decoding=\"async\" style=\"border-width: 0px\" title=\"clip_image004\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/10\/4863.clip_image004_thumb_2BC9CE0B.jpg\" alt=\"clip_image004\" width=\"659\" height=\"285\" border=\"0\" \/><\/p>\n<p>When we inspect this we can see that the value of pObj1->getMyInt() is 5, but it was 10 when we created the object. When did this change? We can set a data breakpoint to find out.<\/p>\n<p>To do this, first we will set a breakpoint in the constructor of the object to get the location of m_myint.<\/p>\n<p><img decoding=\"async\" style=\"border-width: 0px\" title=\"clip_image005\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/10\/3480.clip_image005_thumb_606A2A46.png\" alt=\"clip_image005\" width=\"667\" height=\"305\" border=\"0\" \/><\/p>\n<p>At this point we can see that the value is still 10. We can also look at the address by entering &#8220;&amp;m_myint&#8221;. Next in the Breakpoints windows, we click on New-> Data Breakpoint\u2026<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/10\/6560.Menu_.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>Then in the resulting dialog, we enter the address of the m_myint that we see in the Watch window since it is the variable we want to watch. We\u00a0could also simply enter &#8220;&amp;m_myint&#8221; like we did in the Watch window to\u00a0input\u00a0that address here. We select the\u00a0Bytes to be 4 since we are looking at a 4-byte integer.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/10\/5282.New20Data20Breakpoint.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>Then you can see the new data breakpoint in the Breakpoints window.<\/p>\n<p><img decoding=\"async\" style=\"border-width: 0px\" title=\"clip_image008\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/10\/6866.clip_image008_thumb_06CC0D92.png\" alt=\"clip_image008\" width=\"724\" height=\"157\" border=\"0\" \/><\/p>\n<p>When I continue the execution of the program, I see the following dialog.<\/p>\n<p><img decoding=\"async\" style=\"border-width: 0px\" title=\"clip_image009\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/10\/2678.clip_image009_thumb_18A8A15F.png\" alt=\"clip_image009\" width=\"523\" height=\"205\" border=\"0\" \/><\/p>\n<p>And I am taken to the source code so that I can see where m_myint has changed.<\/p>\n<p><img decoding=\"async\" style=\"border-width: 0px\" title=\"clip_image010\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2013\/10\/6472.clip_image010_thumb_065FDA9D.png\" alt=\"clip_image010\" width=\"622\" height=\"161\" border=\"0\" \/><\/p>\n<p>\u00a0<\/p>\n<h3>Summary<\/h3>\n<p>Over the past week, we have posted about <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2013\/10\/07\/breakpoints-in-visual-studio-2013.aspx\">all the kinds of breakpoints<\/a> that you can use in Visual Studio and how they are helpful.<\/p>\n<p>We would love to hear your feedback about the breakpoints experience in Visual Studio. How else do you use breakpoints? What other breakpoint functionality would you like to see in the future?\u00a0 Please tell us more in the comments below, on our <a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/vstudio\/en-US\/home?forum=vsdebug\">MSDN forum<\/a>, on our <a href=\"http:\/\/visualstudio.uservoice.com\/\">User Voice Site<\/a>, or through <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/zzszcehe.aspx\">Visual Studio&#8217;s Send-a-Smile<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog post is part of a series on breakpoints in the Visual Studio debugger and has been updated to reflect the experience of using Visual Studio 2015. If you are interested in details about setting data breakpoints using earlier versions of Visual Studio please see the MSDN Documentation. Data breakpoints are a powerful feature [&hellip;]<\/p>\n","protected":false},"author":75,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,225],"tags":[],"class_list":["post-2413","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-git"],"acf":[],"blog_post_summary":"<p>This blog post is part of a series on breakpoints in the Visual Studio debugger and has been updated to reflect the experience of using Visual Studio 2015. If you are interested in details about setting data breakpoints using earlier versions of Visual Studio please see the MSDN Documentation. Data breakpoints are a powerful feature [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/2413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=2413"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/2413\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=2413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=2413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=2413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}