<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to Break Your Friend's Code</title><link>http://blogs.msdn.com/b/coolbeans/archive/2007/07/20/how-to-break-your-friend-s-code.aspx</link><description>If I could teach an Industry 101 class, debugging would be a big part of it. Mostly because I’ve found class teaches you how to code, but never how to interact with written code. 
 What I mean by that is how often have you had a problem in a lab partner</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Nightmare Invisible Repaint MouseMove Bug on Elms Street</title><link>http://blogs.msdn.com/b/coolbeans/archive/2007/07/20/how-to-break-your-friend-s-code.aspx#4569485</link><pubDate>Sun, 26 Aug 2007 07:44:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4569485</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;Over this last week I had to debug two issues. If you’re a college student and read this blog, you would&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4569485" width="1" height="1"&gt;</description></item><item><title>Nightmare Invisible Repaint MouseMove Bug on Elms Street</title><link>http://blogs.msdn.com/b/coolbeans/archive/2007/07/20/how-to-break-your-friend-s-code.aspx#4566529</link><pubDate>Sun, 26 Aug 2007 04:01:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4566529</guid><dc:creator>CoolBeans: From College to Industry</dc:creator><description>&lt;p&gt;Over this last week I had to debug two issues. If you’re a college student and read this blog, you would&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4566529" width="1" height="1"&gt;</description></item><item><title>How to be a Debugging Ninja!</title><link>http://blogs.msdn.com/b/coolbeans/archive/2007/07/20/how-to-break-your-friend-s-code.aspx#4144132</link><pubDate>Tue, 31 Jul 2007 10:39:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4144132</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;How many times have you had someone come up to you with a problem that they couldn’t describe? And if&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4144132" width="1" height="1"&gt;</description></item><item><title>How to be a Debugging Ninja!</title><link>http://blogs.msdn.com/b/coolbeans/archive/2007/07/20/how-to-break-your-friend-s-code.aspx#4144005</link><pubDate>Tue, 31 Jul 2007 10:22:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4144005</guid><dc:creator>CoolBeans: From College to Industry</dc:creator><description>&lt;p&gt;How many times have you had someone come up to you with a problem that they couldn’t describe? And if&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4144005" width="1" height="1"&gt;</description></item><item><title>re: How to Break Your Friend's Code</title><link>http://blogs.msdn.com/b/coolbeans/archive/2007/07/20/how-to-break-your-friend-s-code.aspx#3978855</link><pubDate>Fri, 20 Jul 2007 22:21:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3978855</guid><dc:creator>Chris Becker</dc:creator><description>&lt;p&gt;Hi Nektar,&lt;/p&gt;
&lt;p&gt;Great question! This is something I'd like to cover further in a another post, but somethings that you can do if you know the location of a problem, but not specifically what is happening you can &amp;quot;step through&amp;quot; the code.&lt;/p&gt;
&lt;p&gt;In Visual Studio, place a break point at the beginning of the offending function. Then hit &amp;quot;F10&amp;quot; to run only the next line. You can also use the Watch window to watch as variables change value as you step over lines. Stepping through is instrumental in finding either code flow problems (an if statement is or is not getting hit correctly).&lt;/p&gt;
&lt;p&gt;You can do a bit of &amp;quot;reversing time&amp;quot; by dragging the program counter to a previous point in a function. This doesn't reverse variable states, but it does let you execute the same piece of code again (or skip a piece of code later on). Click on the yellow arrow and drag it around while debugging in VS.&lt;/p&gt;
&lt;p&gt;Visual Studio also has a &amp;quot;who calls me&amp;quot; functionality. Right click in a function &amp;quot;Call Browser -&amp;gt; Show Graph&amp;quot;. This will help you determine who is calling your function. &lt;/p&gt;
&lt;p&gt;You can take snapshots in a way using &amp;quot;When Hit&amp;quot;. At runtime, you can &amp;nbsp;print out a callstack as well to see where calls are coming from without breaking execution and print out important variables. Then look through the output at what's happening.&lt;/p&gt;
&lt;p&gt;Though I'm sure there are special tools people have written here at Microsoft, in general I use Visual Studio.&lt;/p&gt;
&lt;p&gt;We do have ways of setting up automation, whether it's through the object model of the application or by simulating user input. If we have a difficult problem we need to repro (like a threading issue) we can setup a scenario that we know the problem occurs in and run it a 1000 times until it hits. Then attach a debugger and see the state of the program.&lt;/p&gt;
&lt;p&gt;We also get crash dumps from user's machines (any time you hit &amp;quot;Send Error Report&amp;quot;) and this gives us the state of a machine at the time it crashed. Here there is no history and no way to step backward or forward, we just have a picture. Determine the problem here can be very tricky and it helps to have many dumps of the same problem. However, we are able to determine the highest hitting crashes and fix those with a hotfix or a service pack.&lt;/p&gt;
&lt;p&gt;Hopefully that answers your questions, I will try and post more on good debugging skills.&lt;/p&gt;
&lt;p&gt;-Chris&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3978855" width="1" height="1"&gt;</description></item><item><title>re: How to Break Your Friend's Code</title><link>http://blogs.msdn.com/b/coolbeans/archive/2007/07/20/how-to-break-your-friend-s-code.aspx#3975039</link><pubDate>Fri, 20 Jul 2007 16:14:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3975039</guid><dc:creator>Nektar</dc:creator><description>&lt;p&gt;This is all well, but what if you don't know what causes a bug but only the location where it manifests itself. This means that even if you set a break-point at the position that the bug is apparent or around it, you still need to go backwards and try to figure out what might have caused it. This means that you will need to place break-points in various places guessing on the possible route that the program took to reach the point where the bug manifested itself. If the code paths leading to this point are a few then all is well but if the code paths are dynamic, multiple and data dependent then tough luck. You don't know where to break. And if the program exhibits the bug only under very rare or difficult to reproduce senarios then double tough luck. How better it would have been if Visual Studio provided a way to go back in time and check what the application has executed before hitting a break-point, including function call history (not only the current stack), global variable changes, etc. With a trace-point I need to guess where and what to look for, if VS could go back in time, like the ability to take snap-shots then it would have been better.&lt;/p&gt;
&lt;p&gt;Questions for you:&lt;/p&gt;
&lt;p&gt;1. How do you handle this situation at Microsoft? Do you have special tools?&lt;/p&gt;
&lt;p&gt;2. How do you repro difficult senarios, like run an application to a specific point of execution in an automated manner? For command-line applications that might be easy but what about gui or other applications requiring user interaction?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3975039" width="1" height="1"&gt;</description></item><item><title>re: How to Break Your Friend's Code</title><link>http://blogs.msdn.com/b/coolbeans/archive/2007/07/20/how-to-break-your-friend-s-code.aspx#3970414</link><pubDate>Fri, 20 Jul 2007 09:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3970414</guid><dc:creator>Chris Becker</dc:creator><description>&lt;p&gt;Yes, but speed is arguably a low concern while debugging. The idea is to identify a problem, not demonstrate your applications performance.&lt;/p&gt;
&lt;p&gt;That said I once placed a break point in a &amp;quot;new&amp;quot; override looking for a specific address allocation. Sloth city.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3970414" width="1" height="1"&gt;</description></item><item><title>re: How to Break Your Friend's Code</title><link>http://blogs.msdn.com/b/coolbeans/archive/2007/07/20/how-to-break-your-friend-s-code.aspx#3970334</link><pubDate>Fri, 20 Jul 2007 09:45:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3970334</guid><dc:creator>hack_tick</dc:creator><description>&lt;p&gt;I remember having a conditional break point always reduced speed of execution for my Win32/C application.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3970334" width="1" height="1"&gt;</description></item></channel></rss>