<?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/"
	>

<channel>
	<title>Jeffrey Magder - Developer Extraordinaire ;-) &#187; Debugging</title>
	<atom:link href="http://jeffmagder.com/tag/debugging/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeffmagder.com</link>
	<description>Software Development, Linux, Mobile Computing and More!</description>
	<lastBuildDate>Thu, 10 Jun 2010 02:01:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Fixing Firebugs JavaScript Line Limits</title>
		<link>http://jeffmagder.com/2010/03/21/fixing-firebugs-javascript-line-limits/</link>
		<comments>http://jeffmagder.com/2010/03/21/fixing-firebugs-javascript-line-limits/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 19:36:25 +0000</pubDate>
		<dc:creator>Jeffrey Magder</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://jeffmagder.com/blog/?p=216</guid>
		<description><![CDATA[Fixing Firebugs randomly occurring JavaScript truncation, missed breakpoints, and undefined breakpoint locations.  ]]></description>
			<content:encoded><![CDATA[<p><a href="http://jeffmagder.com/blog/wp-content/uploads/2010/03/firebug-transparent-background.png"><img src="http://jeffmagder.com/blog/wp-content/uploads/2010/03/firebug-transparent-background.png" alt="" title="firebug-transparent-background" width="128" height="128" class="alignleft size-full wp-image-277" style="margin-top: 18px;" /></a>All professionals have their tools of their trade that are essential to their productivity and efficiency.  Electricians have their multimeter, Biologists have their microscope. We the humble Software Developers, have the <strong>Debugger</strong>.</p>
<p>As the web continues its trend from static pages to rich interactive content and applications, the role of a software developer only grows.   As this movement continues, our need for becoming fluent with web-based debuggers is undoubtedly of the utmost importance.</p>
<p><span id="more-216"></span></p>
<p>For those of you unfortunate enough to work in the world of Internet Explorer, MS Script Editor or MS Visual Studio is probably your only tool of (mis)choice.  To me it has been more like a blunt instrument than a precision tool.   It offers basic functionality but trying to use it beyond that it causes constant frustrations. Basic conditional breakpoints often crash Visual Studio, and more advanced conditional breakpoints refuse to be set. Stepping through code too fast occasionally freezes up Visual Studio 2005 through 2008 to the point only a task kill can shut it down.  In short, it has been a constant struggle for me to work with these MS based tools.</p>
<p>Which brings us to Firebug, the best JavaScript debugger that I know of.  I’ve found Firebug to be a much a more powerful debugger than MS Visual Studio for a long time.  I could write dozens of blog entries about this ever-evolving debugger of choice (and I plan to), but this article is meant to describe how to patch a randomly occurring <a href="http://code.google.com/p/fbug/issues/detail?id=2788" target="_blank">bug</a> in the current 1.5 release (at time of writing), using a fix recently provided in the upcoming 1.6 release.</p>
<h2>The Bug</h2>
<p>I have used firebug for a long time, but I never came across this bug until I started work at NexJ. Their software applications offer amazingly advanced functionality, which of course requires more advanced coding.  And with this advanced coding comes:</p>
<ol>
<li>More JavaScript Files</li>
<li>Larger JavaScript Files</li>
</ol>
<p>With these two ingredients, the debugger script view will randomly:</p>
<ol>
<li>Cut off the display of certain JavaScript  files at random line numbers.</li>
<li>Make certain breakpoints no longer fire after random line numbers</li>
<li>Make breakpoints repeat themselves on refresh, while referring to &#8220;undefined&#8221; functions.</li>
</ol>
<p>I’ve kept in contact with some of the developers on the IRC and have been tracking the bug. Thankfully it appears a fix was committed to the upcoming 1.6 branch.  I&#8217;ve modified the patch slightly to apply to the 1.5 branch, and it has solved all of the above beautifully.</p>
<h2>The Fix</h2>
<p>The patch is very simple.</p>
<p><strong>Step 1</strong>) Open up firebugs tabPanel.js file.</p>
<div class="indent">
<p>In XP the path will be:</p>
<pre class="code codeBackground">C:\Documents and Settings\YOUR.PROFILE.NAME\ApplicationData\Mozilla\Firefox\
      Profiles\RANDOMSTUFF.default\extensions\firebug@software.joehewitt.com\
      content\firebug\tabCache.js</pre>
<p>In Vista the path will be:</p>
<pre class="code codeBackground">C:\Users\PROFILE.NAME\AppData\Roaming\Mozilla\Firefox\Profiles\
      RANDOMSTUFF.default\extensions\firebug@software.joehewitt.com\
      content\firebug\tabCache.js</pre>
<p>In Linux the path will be:</p>
<pre class="code codeBackground">/home/LOGIN_NAME/.mozilla/firefox/RANDOMSTUFF.default/extensions/
      firebug@software.joehewitt.com/content/firebug/tabCache.js</pre>
</div>
<p><strong>Step 2)</strong> Find the line similar to:</p>
<div class="indent">
<pre class="code codeBackground">sink.init(true, true, 0, 0, null);</pre>
<p>and replace with:</p>
<pre class="code codeBackground">sink.init(false, false, 0x20000, 0x4000, null);</pre>
</div>
<p><strong>Step 3)</strong> Directly after this line add:</p>
<pre class="indent code codeBackground">newListener.wrappedJSObject.inputStream = sink.inputStream;</pre>
<p><strong>Step 4) </strong>Save the file, kill all instances of Firefox, and restart Firefox. All fixed!</p>
<p>The original patch can be found <a href="http://code.google.com/p/fbug/source/diff?spec=svn6323&amp;r=6323&amp;format=side&amp;path=/branches/firebug1.6/content/firebug/tabCache.js&amp;old_path=/branches/firebug1.6/content/firebug/tabCache.js&amp;old=6076" target="_blank">here</a>,  but is based on the 1.6 branch which is likely different than what you are running at the time of this post.</p>
<h2>Explanation:</h2>
<p>The problem was that the reference to the input stream was lost and was randomly collected by the JS garbage collector. This is why the bug is random and more prevalent on some machines (probably with lower memory conditions at the time), and why it was more likely to occur with more and larger files (allowing greater opportunity for the garbage collector to get in the way).</p>
<p>The good news is this problem will no longer require a manual patch once the 1.6 branch becomes an official release.</p>
<p>Let me know how this works for all of you, and happy debugging!</p>
<div class="tweetthis" style="text-align:center;"><p> <a class="tt" href="http://twitter.com/home/?status=Fixing+Firebugs+JavaScript+Line+Limits+http%3A%2F%2Fjeffmagder.com%2F%3Fp%3D216" title="Post to Twitter"><img class="nothumb" src="http://jeffmagder.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a class="tt" href="http://delicious.com/post?url=http://jeffmagder.com/2010/03/21/fixing-firebugs-javascript-line-limits/&amp;title=Fixing+Firebugs+JavaScript+Line+Limits" title="Post to Delicious"><img class="nothumb" src="http://jeffmagder.com/blog/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious-micro3.png" alt="Post to Delicious" /></a> <a class="tt" href="http://digg.com/submit?url=http://jeffmagder.com/2010/03/21/fixing-firebugs-javascript-line-limits/&amp;title=Fixing+Firebugs+JavaScript+Line+Limits" title="Post to Digg"><img class="nothumb" src="http://jeffmagder.com/blog/wp-content/plugins/tweet-this/icons/en/digg/tt-digg-micro3.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://jeffmagder.com/2010/03/21/fixing-firebugs-javascript-line-limits/&amp;t=Fixing+Firebugs+JavaScript+Line+Limits" title="Post to Facebook"><img class="nothumb" src="http://jeffmagder.com/blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://jeffmagder.com/2010/03/21/fixing-firebugs-javascript-line-limits/&amp;title=Fixing+Firebugs+JavaScript+Line+Limits" title="Post to Reddit"><img class="nothumb" src="http://jeffmagder.com/blog/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit-micro3.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://jeffmagder.com/2010/03/21/fixing-firebugs-javascript-line-limits/&amp;title=Fixing+Firebugs+JavaScript+Line+Limits" title="Post to StumbleUpon"><img class="nothumb" src="http://jeffmagder.com/blog/wp-content/plugins/tweet-this/icons/en/su/tt-su-micro3.png" alt="Post to StumbleUpon" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://jeffmagder.com/2010/03/21/fixing-firebugs-javascript-line-limits/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

