<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Coding Smackdown &#187; Debugger Commands</title>
	<atom:link href="http://codingsmackdown.tv/content/index.php/tag/debugger-commands/feed/" rel="self" type="application/rss+xml" />
	<link>http://codingsmackdown.tv/content</link>
	<description>Putting a head lock on the coding lifestyle!</description>
	<lastBuildDate>Mon, 07 Dec 2009 16:43:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<!-- podcast_generator="podPress/8.8" - maintenance_release="8.8.4" -->
		<copyright>2008-2009 </copyright>
		<managingEditor>jlavin@jimlavin.net (Jim Lavin)</managingEditor>
		<webMaster>jlavin@jimlavin.net (Jim Lavin)</webMaster>
		<category>Technology</category>
		<ttl>1440</ttl>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle>Putting a head lock on the coding lifestyle!</itunes:subtitle>
		<itunes:summary>Putting a head lock on the coding lifestyle!</itunes:summary>
		<itunes:author>Jim Lavin</itunes:author>
		<itunes:category text="Technology"/>
<itunes:category text="Technology">
	<itunes:category text="Software How-To"/>
</itunes:category>
		<itunes:owner>
			<itunes:name>Jim Lavin</itunes:name>
			<itunes:email>jlavin@jimlavin.net</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>yes</itunes:explicit>
		<itunes:image href="http://codingsmackdown.tv/content/wp-content/uploads/Images/CodingSmackdownLogoLarge.png" />
		<image>
			<url>http://codingsmackdown.tv/content/wp-content/uploads/Images/CodingSmackdownLogoSmall.png</url>
			<title>Coding Smackdown</title>
			<link>http://codingsmackdown.tv/content</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>Coding Smackdown Episode 009 &#8211; The Lost Art of Debugging</title>
		<link>http://codingsmackdown.tv/content/index.php/2009/08/coding-smackdown-episode-009-the-lost-art-of-debugging/</link>
		<comments>http://codingsmackdown.tv/content/index.php/2009/08/coding-smackdown-episode-009-the-lost-art-of-debugging/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 21:20:53 +0000</pubDate>
		<dc:creator>jim.lavin</dc:creator>
				<category><![CDATA[Netcast]]></category>
		<category><![CDATA[Application Developers]]></category>
		<category><![CDATA[Board Computer]]></category>
		<category><![CDATA[Brakes]]></category>
		<category><![CDATA[Debugger]]></category>
		<category><![CDATA[Debugger Commands]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Development Environment]]></category>
		<category><![CDATA[Electrical Engineer]]></category>
		<category><![CDATA[Global Virtual Team]]></category>
		<category><![CDATA[Guru]]></category>
		<category><![CDATA[Headlock]]></category>
		<category><![CDATA[Insightful Wisdom]]></category>
		<category><![CDATA[Lavin]]></category>
		<category><![CDATA[Mechanical Engineer]]></category>
		<category><![CDATA[Mechanical Systems]]></category>
		<category><![CDATA[Mountains]]></category>
		<category><![CDATA[Scope]]></category>
		<category><![CDATA[Single Step]]></category>
		<category><![CDATA[Software Engineer]]></category>
		<category><![CDATA[Steep Incline]]></category>
		<category><![CDATA[Training Tool]]></category>

		<guid isPermaLink="false">http://codingsmackdown.tv/content/?p=156</guid>
		<description><![CDATA[
			
				
			
		

Welcome, I&#8217;m Jim Lavin and this is Coding Smackdown, the netcast where we put a headlock on the coding lifestyle.
This episode is rated G for the insightful wisdom of the coding guru we are about to impart.
Once upon a time there was a mechanical engineer, an electrical engineer and a software engineer riding through the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcodingsmackdown.tv%2Fcontent%2Findex.php%2F2009%2F08%2Fcoding-smackdown-episode-009-the-lost-art-of-debugging%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcodingsmackdown.tv%2Fcontent%2Findex.php%2F2009%2F08%2Fcoding-smackdown-episode-009-the-lost-art-of-debugging%2F&amp;source=codingsmackdown&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://blip.tv/play/AYGYlnwC" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="300" src="http://blip.tv/play/AYGYlnwC" allowfullscreen="true"></embed></object></p>
<p>Welcome, I&#8217;m Jim Lavin and this is Coding Smackdown, the netcast where we put a headlock on the coding lifestyle.</p>
<p>This episode is rated G for the insightful wisdom of the coding guru we are about to impart.</p>
<p>Once upon a time there was a mechanical engineer, an electrical engineer and a software engineer riding through the mountains and as they started to go down a steep incline the brakes gave out and they careened down the incline and crashed into the guard rail.</p>
<p>The three engineers got out of the car scratched their heads and looked at the car.</p>
<p>The Mechanical engineer said &#8220;We should look at all of the mechanical systems, test each one separately and determine which one is malfunctioning and fix it.&#8221;</p>
<p>The Electrical Engineer said &#8220;I got a better idea, lets hook my diagnostic scope to the on-board computer and it can tell us which system failed and we can then fix it.&#8221;</p>
<p>Then the Software Engineer said &#8220;I got an even better idea, lets just push the car back up the mountain and get in and see if it happens again!&#8221;</p>
<p>Over the past couple of years I have been a technical lead on a large global virtual team and I have spent hundreds of hours mentoring developers and one of the most important skills I see lacking is the ability to debug an application.</p>
<p>Developers too often waste their time rerunning an application and guessing why an error is happening instead of using the debugger to step through code and find out what is really happening inside their code.</p>
<p>Not only does the debugger help you find out what is happening inside your code it can be used as a valuable training tool when you are trying to learn a new framework or understand how a pattern executes.</p>
<p>Most any Development Environment provides an integrated debugger that allows you to single step through your code to see what is happening and where things are going wrong.</p>
<p>There are five things you need to get familiar with, in order to use the debugger effectively:</p>
<p>The Debugger Commands<br />
Setting Breakpoints<br />
Viewing Local Data<br />
Setting Watches on Data<br />
Viewing the Callstack</p>
<p>There are several commands that are common to all debuggers.</p>
<p>Those to start the debugging process and those to navigate with while debugging an application.</p>
<p>Usually your development environment will include a command to start the debugger. In Visual Studio this is normally the F5 key or you can select Debug | Start Debugging from the main menu.</p>
<p>If you are trying to debug a process that is already running, development environments usually provide a way for you to attach to an existing process. In Visual Studio you can do this by selecting Debug | Attach To Process from the main menu.</p>
<p>Once you&#8217;ve started the debugger you need to be able to control how the computer executes the code. There are usually several commands that allows you to step through the code or jump to a location in the code.</p>
<p>The most common commands are;</p>
<p>Single Step which allows you to execute a single line of code and stop.<br />
Step Into which allows you to step into a function call and continue debugging.<br />
Step Out which allows you to continue execution but stop once a function completes executing and returns.<br />
Run To Cursor which allows you to set your cursor at a line of code and have the debugger run until it hits the line where the cursor is.</p>
<p>If you don&#8217;t want to walk through every line of code but stop when you reach a specific function or method within your code, then you want to use break points.</p>
<p>Breakpoints allow you to stop the execution of your code so you can step through it at a desired location.</p>
<p>There are several ways you can set a break point:</p>
<p>By Location &#8211; this is when execution reaches a specific function or line of code in a specific file.<br />
By Condition &#8211; when a break point location is reached, an expression is evaluated and the break point is hit only if the expression is true.<br />
By Hit count &#8211; when a break point location is reached and the hit counter has reached the number of hits to equal the expression. You can stop on a specific number of times, less than a specific number or when the hit counter is greater than a specific number.<br />
By Filter &#8211; This is a way to restrict break points from happening based on Machine Name, Process Id, Process Name, Thread Name or Thread Id. This can be really great if you are trying to debug a single thread within a multi-thread application.<br />
By setting a breakpoint you can run your application and every time the debugger hits the break point it will stop so you can single step through your code.</p>
<p>So now that you&#8217;ve set your break point and reach some code you want to debug what do you do next?</p>
<p>As you step through the code line by line, you&#8217;ll probably be interested in what the values of your variables are as you execute each line of code.</p>
<p>Most debuggers provide a Locals Window that allows you to inspect the values of the variables and object within your code as you step through it.</p>
<p>By using the Locals Window you can see exactly what affect each line of code has on your data. You can also inspect the variables passed into your methods to ensure the right data is getting to your code.</p>
<p>9 times out of 10 an application fails because of bad data. Using the Local Windows as you step through your code will help you catch those issues.</p>
<p>There might be times where you want to track the state of an object over time, the Watch Window provides a perfect place to do that.</p>
<p>The Watch Window allows you to keep track of the state objects as you execute your code that may be in different modules or objects.</p>
<p>The Watches Window allows you to inspect a global variable or object as you execute code. It works similar to the Locals Window but only shows those variables or objects you have set up watches for.</p>
<p>The nice thing about the Watches Window is that you can use it to filter out local variables that you are not interested in. This is really useful when you have a method or funtion with a lot of local variables.</p>
<p>So now, you are stepping through your code and you know how to inspect the data within your application as you step through it, next we&#8217;re going to show you how you got to your code by using the call stack.</p>
<p>The call stack is the best way to find out how your code got executed.</p>
<p>It gives you a list of each line of code that was called previously in order to get to where you are now.</p>
<p>If you want to see what line of code called your code, you can usually click on a line in the Call stack and you&#8217;ll be taken to the code.</p>
<p>Now you are armed with the enough knowledge to quickly find out what is going wrong in your application.</p>
<p>If you are new to a framework library or want to see how a piece of code works you can use the debugger if you have the source code.</p>
<p>Just set a couple of breakpoints in your code and step into the framework and walk the code step by step to get a good idea of what is going on under the covers.</p>
<p>For example if you want to step through the .Net Framework in Visual Studio select Tools | Options from the main menu and Go to the General Option under Debugging and select Enable .NET Framework source stepping. This will make changes to your debugging environment that will allow you to step into any .NET Framework code next time you are in the debugger.</p>
<p>One of the first things I do whenever I start using a new framework or library, is install the source code and step into the code in order to figure out how best to use the library.</p>
<p>Trust me this is one of the best uses of the debugger you&#8217;ll ever find and provides you with a quick and easy way to find out what other libraries are doing.</p>
<p>So there you have it, next time you need to figure out why your code is failing, instead of re-running the application and see if it happens again, set a couple of break points in the debugger and walk through your code step-by-step, you&#8217;ll find the reason your code is failing and be able to fix it faster.</p>
<p>If you have comments or questions leave us a comment on the show notes for this episode at <a href="http://codingsmackdown.tv">http://codingsmackdown.tv</a></p>
<p>I&#8217;m Jim Lavin and we&#8217;ll see you next time on the Coding Smackdown!</p>
]]></content:encoded>
			<wfw:commentRss>http://codingsmackdown.tv/content/index.php/2009/08/coding-smackdown-episode-009-the-lost-art-of-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<enclosure url="http://blip.tv/file/get/Lavinjj-TheLostArtOfDebugging845.mp4" length="410882809" type="audio/mpeg"/>
<itunes:duration>00:01:01</itunes:duration>
		<itunes:subtitle>Welcome, I'm Jim Lavin and this is Coding Smackdown, the netcast where we put a headlock on the coding lifestyle.

This episode is rated G for ...</itunes:subtitle>
		<itunes:summary>Welcome, I'm Jim Lavin and this is Coding Smackdown, the netcast where we put a headlock on the coding lifestyle.

This episode is rated G for the insightful wisdom of the coding guru we are about to impart.

Once upon a time there was a mechanical engineer, an electrical engineer and a software engineer riding through the mountains and as they started to go down a steep incline the brakes gave out and they careened down the incline and crashed into the guard rail.

The three engineers got out of the car scratched their heads and looked at the car.

The Mechanical engineer said "We should look at all of the mechanical systems, test each one separately and determine which one is malfunctioning and fix it."

The Electrical Engineer said "I got a better idea, lets hook my diagnostic scope to the on-board computer and it can tell us which system failed and we can then fix it."

Then the Software Engineer said "I got an even better idea, lets just push the car back up the mountain and get in and see if it happens again!"

Over the past couple of years I have been a technical lead on a large global virtual team and I have spent hundreds of hours mentoring developers and one of the most important skills I see lacking is the ability to debug an application.

Developers too often waste their time rerunning an application and guessing why an error is happening instead of using the debugger to step through code and find out what is really happening inside their code.

Not only does the debugger help you find out what is happening inside your code it can be used as a valuable training tool when you are trying to learn a new framework or understand how a pattern executes.

Most any Development Environment provides an integrated debugger that allows you to single step through your code to see what is happening and where things are going wrong.

There are five things you need to get familiar with, in order to use the debugger effectively:

The Debugger Commands
Setting Breakpoints
Viewing Local Data
Setting Watches on Data
Viewing the Callstack

There are several commands that are common to all debuggers.

Those to start the debugging process and those to navigate with while debugging an application.

Usually your development environment will include a command to start the debugger. In Visual Studio this is normally the F5 key or you can select Debug #124; Start Debugging from the main menu.

If you are trying to debug a process that is already running, development environments usually provide a way for you to attach to an existing process. In Visual Studio you can do this by selecting Debug #124; Attach To Process from the main menu.

Once you've started the debugger you need to be able to control how the computer executes the code. There are usually several commands that allows you to step through the code or jump to a location in the code.

The most common commands are;

Single Step which allows you to execute a single line of code and stop.
Step Into which allows you to step into a function call and continue debugging.
Step Out which allows you to continue execution but stop once a function completes executing and returns.
Run To Cursor which allows you to set your cursor at a line of code and have the debugger run until it hits the line where the cursor is.

If you don't want to walk through every line of code but stop when you reach a specific function or method within your code, then you want to use break points.

Breakpoints allow you to stop the execution of your code so you can step through it at a desired location.

There are several ways you can set a break point:

By Location - this is when execution reaches a specific function or line of code in a specific file.
By Condition - when a break point location is reached, an expression is evaluated and the break point is hit only if the expression is true.
By Hit count - when a break point location is reached and the hit counte</itunes:summary>
		<itunes:keywords>Netcast</itunes:keywords>
		<itunes:author>Jim Lavin</itunes:author>
		<itunes:explicit>no</itunes:explicit>
		<itunes:block>No</itunes:block>
	</item>
	</channel>
</rss>
