<?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>James Finnigan : debugging</title><link>http://blogs.msdn.com/jamesfi/archive/tags/debugging/default.aspx</link><description>Tags: debugging</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How to stop WinDbg from going crazy and loading all the symbols</title><link>http://blogs.msdn.com/jamesfi/archive/2007/06/04/how-to-stop-windbg-from-going-crazy-and-loading-all-the-symbols.aspx</link><pubDate>Mon, 04 Jun 2007 17:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3036010</guid><dc:creator>jamesfinnigan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jamesfi/comments/3036010.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jamesfi/commentrss.aspx?PostID=3036010</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jamesfi/rsscomments.aspx?PostID=3036010</wfw:comment><description>&lt;P&gt;One of my favorite features of WinDbg is that it doesn't load all the symbols up-front.&amp;nbsp; That's a huge part of what makes it so much faster than Visual Studio.&amp;nbsp; However, every once in a while you can do things that cause WinDbg to go crazy and load all the symbols in a desperate attempt to resolve a symbol that it just isn't finding.&amp;nbsp; Oftentimes this is because of a typo, or because you forgot to scope the symbol to a module.&amp;nbsp; It's annoying - but it's not something that you have to live with.&lt;/P&gt;
&lt;P&gt;To tell WinDbg not to do it's whole-hog symbol search use this command:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;.symopt+ 100&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;If you find yourself in a situation where you don't want to wait for the debugger to finish resolving symbols before issuing the command, you can just start windbg with the -snul parameter.&amp;nbsp; In some cases, the reason this is happening is some goofy breakpoint you set, or something in your watch window - it's not going away.&amp;nbsp; If you don't want to take the time to track it down, you can bail on the workspace by starting windbg with the -WX parameter, and saving whatever you put into the first one.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Here's what the documentation has to say on the topic:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;SYMOPT_NO_UNQUALIFIED_LOADS&lt;/STRONG&gt;&lt;BR&gt;This symbol option disables the symbol handler's automatic loading of modules. When this option is set and the debugger attempts to match a symbol, it will only search modules&amp;nbsp;&lt;EM&gt;[whose symbols]&lt;/EM&gt; have already been loaded.&lt;BR&gt;This option can be used as a defense against mistyping a symbol name. Normally, a mistyped symbol will cause the debugger to pause while it searches all unloaded symbol files. When this option is active, a mistyped symbol will not be found in the loaded modules, and then the search will terminate.&lt;BR&gt;This option is off by default. It can be activated by using the&lt;STRONG&gt; -snul&lt;/STRONG&gt; command-line option. Once the debugger is running, it can be turned on or off by using &lt;STRONG&gt;.symopt+0x100&lt;/STRONG&gt; or &lt;STRONG&gt;.symopt-0x100&lt;/STRONG&gt;, respectively&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;HR&gt;
All postings are provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at &lt;A href="http://www.microsoft.com/info/cpyright.htm"&gt;&lt;FONT color=#006666&gt;http://www.microsoft.com/info/cpyright.htm&lt;/FONT&gt;&lt;/A&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3036010" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jamesfi/archive/tags/windbg/default.aspx">windbg</category><category domain="http://blogs.msdn.com/jamesfi/archive/tags/debugging/default.aspx">debugging</category></item><item><title>Breaking when the instruction pointer leaves the module</title><link>http://blogs.msdn.com/jamesfi/archive/2007/05/31/breaking-when-the-instruction-pointer-leaves-the-module.aspx</link><pubDate>Thu, 31 May 2007 19:00:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3001774</guid><dc:creator>jamesfinnigan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jamesfi/comments/3001774.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jamesfi/commentrss.aspx?PostID=3001774</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jamesfi/rsscomments.aspx?PostID=3001774</wfw:comment><description>&lt;p&gt;The problem is to skip out of a kernel driver that we don't have symbols for - what's the best way to break on calls out of that driver.&lt;/p&gt; &lt;p&gt;If you used pc (step until the next call instruction), you would hit calls that are inside that driver.&lt;/p&gt; &lt;p&gt;Here's another approach (using an example from Pavel Lebedynskiy) - step until the ip address moves outside that module:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;.while (@eip &amp;gt; fee50000 &amp;amp; @eip &amp;lt; feef1000) { t; reip }&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;If you want to skip the output, you can use setting the instruction pointer instead like we did in the &lt;a href="http://blogs.msdn.com/jamesfi/archive/2007/05/30/finding-where-a-bad-hresult-is-returned.aspx"&gt;last post using a .while trick&lt;/a&gt;.  &lt;hr&gt;  &lt;p&gt;All postings are provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at &lt;a href="http://www.microsoft.com/info/cpyright.htm"&gt;http://www.microsoft.com/info/cpyright.htm&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3001774" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jamesfi/archive/tags/windbg/default.aspx">windbg</category><category domain="http://blogs.msdn.com/jamesfi/archive/tags/debugging/default.aspx">debugging</category></item><item><title>Finding where a bad HRESULT is returned</title><link>http://blogs.msdn.com/jamesfi/archive/2007/05/30/finding-where-a-bad-hresult-is-returned.aspx</link><pubDate>Thu, 31 May 2007 08:38:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3001220</guid><dc:creator>jamesfinnigan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jamesfi/comments/3001220.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jamesfi/commentrss.aspx?PostID=3001220</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jamesfi/rsscomments.aspx?PostID=3001220</wfw:comment><description>&lt;p&gt;I've looked at this a &lt;a href="http://jamesfinnigan.spaces.live.com/blog/cns!9062539B2F0077D6!140.entry"&gt;couple&lt;/a&gt; &lt;a href="http://jamesfinnigan.spaces.live.com/blog/cns!9062539B2F0077D6!209.entry?_c=BlogPart"&gt;times&lt;/a&gt;, but here's another way to break when the error code you're looking at is being returned.&lt;/p&gt; &lt;p&gt;.while(@eax != 0xc0000005) { t ; reax } &lt;p&gt;If you want to avoid the output noise, you can do something like this: &lt;p&gt;.while(@eax != 0xc0000005) { t ; r @eip = @eip}; r eax &lt;hr&gt;  &lt;p&gt;All postings are provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at &lt;a href="http://www.microsoft.com/info/cpyright.htm"&gt;http://www.microsoft.com/info/cpyright.htm&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3001220" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jamesfi/archive/tags/windbg/default.aspx">windbg</category><category domain="http://blogs.msdn.com/jamesfi/archive/tags/debugging/default.aspx">debugging</category></item><item><title>How to only break on a jump when it will be taken</title><link>http://blogs.msdn.com/jamesfi/archive/2007/05/30/how-to-only-break-on-a-jump-when-it-will-be-taken.aspx</link><pubDate>Thu, 31 May 2007 08:22:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3000830</guid><dc:creator>jamesfinnigan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jamesfi/comments/3000830.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jamesfi/commentrss.aspx?PostID=3000830</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jamesfi/rsscomments.aspx?PostID=3000830</wfw:comment><description>&lt;p&gt;Here's a question that came up a work a little bit back - thought I would share the result around.&lt;/p&gt; &lt;p&gt;There is a coding pattern (that I don't ever really use so I may be messing it up) that works like this:&lt;/p&gt;&lt;code&gt; &lt;blockquote&gt;&lt;pre class="code"&gt;T1 res1;
T2 res2;
T3 res3;

res1 = GetRes1();
&lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt; (!res1) &lt;span style="color: rgb(0,0,255)"&gt;goto&lt;/span&gt; Cleanup;

res2 = res1.GetRes2();
&lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt; (!res2) &lt;span style="color: rgb(0,0,255)"&gt;goto&lt;/span&gt; Cleanup;

res3 = res2.GetRes3();

Cleanup:
&lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt; (res3) CleanupRes3(res3);
&lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt; (res2) CleanupRes3(res2);
&lt;span style="color: rgb(0,0,255)"&gt;if&lt;/span&gt; (res1) CleanupRes3(res1);
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/code&gt;&lt;/blockquote&gt;
&lt;p&gt;So what if you wanted to break when you are at &lt;strong&gt;&lt;em&gt;Cleanup &lt;/em&gt;&lt;/strong&gt;because res2 was null?&amp;nbsp; You can set a breakpoint with a conditional that will only break when the jump to Cleanup from res2&amp;nbsp;is going to be taken.&amp;nbsp; You could base it on the symbols and do the comparison yourself. However, in optimized code the debuggers understanding of local variable information&amp;nbsp;is often incorrect (the compiler doesn't emit enough information in the pdb to make this possible).&amp;nbsp; In that case, it may be most convenient to make a conditional breakpoint using the x86 flags (described in detail in the help file that comes with windbg under the topic &lt;strong&gt;&lt;em&gt;x86 Architecture&lt;/em&gt;&lt;/strong&gt;).&lt;/p&gt;
&lt;p&gt;Here's an example:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="Consolas"&gt;ntdll!RtlUnlockModuleSection+0x23a:&lt;br&gt;77937c71 8b4590&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; eax,dword ptr [ebp-70h]&lt;br&gt;77937c74 6683785c01&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; word ptr [eax+5Ch],1&lt;br&gt;77937c79 7416&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; je&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ntdll!RtlUnlockModuleSection+0x25a (77937c91)&lt;/font&gt;
&lt;p&gt;&lt;font face="Consolas"&gt;0:000&amp;gt; bu ntdll!RtlEncodePointer+0x21a ".if (@ZF=1) { gc } "&lt;br&gt;0:000&amp;gt; g&lt;br&gt;ChildEBP RetAddr&lt;br&gt;WARNING: Stack unwind information not available. Following frames may be wrong.&lt;br&gt;0011f678 77945ad7 ntdll!RtlEncodePointer+0x21a&lt;br&gt;0011f6e4 7794a980 ntdll!RtlGetNtVersionNumbers+0x83&lt;br&gt;0011f6f4 00000000 ntdll!LdrInitializeThunk+0x10&lt;br&gt;eax=00000002 ebx=7ffde000 ecx=779a00dd edx=77970f34 esi=00000000 edi=779d5d14&lt;br&gt;eip=77944bef esp=0011f534 ebp=0011f678 iopl=0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nv up ei pl nz na po nc&lt;br&gt;cs=001b&amp;nbsp; ss=0023&amp;nbsp; ds=0023&amp;nbsp; es=0023&amp;nbsp; fs=003b&amp;nbsp; gs=0000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; efl=00000202&lt;br&gt;ntdll!RtlEncodePointer+0x21a:&lt;br&gt;77944bef 740d&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; je&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ntdll!RtlEncodePointer+0x229 (77944bfe) [br=0]&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font face="Consolas"&gt;ZF=1 is the flag for a comparison (which is a subtraction that sets flags) that was equal (so a subtraction would naturally result in 0 - setting the zero flag).&amp;nbsp; In this second example we're interested in breaking when it is not equal, so we used gc (to continue execution) when ZF=1.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Consolas"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;
&lt;p&gt;James&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3000830" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jamesfi/archive/tags/windbg/default.aspx">windbg</category><category domain="http://blogs.msdn.com/jamesfi/archive/tags/debugging/default.aspx">debugging</category></item><item><title>Locating the file that a function (not on the stack) was written in</title><link>http://blogs.msdn.com/jamesfi/archive/2006/11/11/locating-the-file-that-a-function-not-on-the-stack-was-written-in.aspx</link><pubDate>Sat, 11 Nov 2006 04:47:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1056827</guid><dc:creator>jamesfinnigan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jamesfi/comments/1056827.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jamesfi/commentrss.aspx?PostID=1056827</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jamesfi/rsscomments.aspx?PostID=1056827</wfw:comment><description>&lt;p&gt;This question came up in one of the internal aliases a couple days ago.&amp;nbsp; While debugging, how do I find the source for a particular function that is not on the stack?&amp;nbsp; There are a couple caveats to consider first: &lt;/p&gt; &lt;ol&gt; &lt;li&gt;You must have symbols that include source information (public symbols have this information stripped out of them)&lt;/li&gt; &lt;li&gt;You must have turned on loading source information.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;To satisfy #2, first run &lt;strong&gt;&lt;em&gt;.lines -e&lt;/em&gt;&lt;/strong&gt; and then you have several choices:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;use &lt;strong&gt;&lt;em&gt;ln &lt;/em&gt;&lt;/strong&gt;with name of the function&lt;/li&gt; &lt;ul&gt; &lt;li&gt;0:000&amp;gt; ln RuntimeTest!CUIElementName::CUIElementName&lt;br&gt;d:\dev\acw\enduser\nuiux\acw\activecontentwizard\unmanaged\property.cpp(1593)&lt;br&gt;(00857050) RuntimeTest!CUIElementName::CUIElementName | (008570e0) RuntimeTest!CUIElementName::AddRef&lt;br&gt;Exact matches:&lt;br&gt;RuntimeTest!CUIElementName::CUIElementName (void)&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;use &lt;strong&gt;&lt;em&gt;u&lt;/em&gt;&lt;/strong&gt; with the name of the function&lt;/li&gt; &lt;ul&gt; &lt;li&gt;0:000&amp;gt; u RuntimeTest!CUIElementName::CUIElementName&lt;br&gt;RuntimeTest!CUIElementName::CUIElementName [d:\dev\acw\enduser\nuiux\acw\activecontentwizard\unmanaged\property.cpp @ 1593]:&lt;br&gt;00857050 8bff mov edi,edi&lt;br&gt;00857052 55 push ebp&lt;br&gt;...&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;use &lt;strong&gt;&lt;em&gt;lsa&lt;/em&gt;&lt;/strong&gt; with the name of the function and then &lt;strong&gt;lsc&lt;/strong&gt;&lt;/li&gt; &lt;ul&gt; &lt;li&gt;0:000&amp;gt; lsa RuntimeTest!CUIElementName::CUIElementName&lt;br&gt;...&lt;br&gt;1590: }&lt;br&gt;1591: &lt;br&gt;1592: CUIElementName::CUIElementName()&lt;br&gt;&amp;gt; 1593: {&lt;br&gt;...&lt;br&gt;0:000&amp;gt; lsc&lt;br&gt;Current: dev\acw\enduser\nuiux\acw\activecontentwizard\unmanaged\property.cpp(1599)&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1056827" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jamesfi/archive/tags/windbg/default.aspx">windbg</category><category domain="http://blogs.msdn.com/jamesfi/archive/tags/debugging/default.aspx">debugging</category></item></channel></rss>