<?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>visophyte: shiny? shiny. &#187; gaudy</title>
	<atom:link href="http://www.visophyte.org/blog/tag/gaudy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.visophyte.org/blog</link>
	<description>Andrew Sutherland writes things but (almost) always includes pictures to look at.</description>
	<lastBuildDate>Thu, 29 Sep 2011 02:22:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>unified JS/C++ backtraces, colorized backtraces, colorized source listing for gdb 7.3/archer-trunk updated</title>
		<link>http://www.visophyte.org/blog/2011/03/30/unified-jsc-backtraces-colorized-backtraces-colorized-source-listing-for-gdb-7-3archer-trunk-updated/</link>
		<comments>http://www.visophyte.org/blog/2011/03/30/unified-jsc-backtraces-colorized-backtraces-colorized-source-listing-for-gdb-7-3archer-trunk-updated/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 06:20:22 +0000</pubDate>
		<dc:creator>Andrew Sutherland</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[colors!]]></category>
		<category><![CDATA[gaudy]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[Shiny]]></category>

		<guid isPermaLink="false">http://www.visophyte.org/blog/?p=760</guid>
		<description><![CDATA[gdb has had integrated python support for some time and it is truly awesome.  The innards have changed here and there, so my previous efforts to show colorized/fancy backtraces, show colorized source listings, and provide unified JS/C++ mozilla backtraces (with colors still) have experienced some bit-rot over time. I have de-bitrotted the changes, hard.  Hard [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_762" class="wp-caption alignnone" style="width: 686px"><img class="size-full wp-image-762" title="mbt-indexed" src="http://www.visophyte.org/blog/wp-content/uploads/2011/03/mbt-indexed.png" alt="" width="676" height="333" /><p class="wp-caption-text">type &quot;mbt&quot;, see this.</p></div>
<p>gdb has had <a href="http://sourceware.org/gdb/wiki/PythonGdb">integrated python support</a> for some time and it is truly awesome.  The innards have changed here and there, so my previous efforts to <a href="http://www.visophyte.org/blog/2009/03/04/gaudily-colorized-gdb-backtraces-woo/">show colorized/fancy backtraces</a>, <a href="http://www.visophyte.org/blog/2009/04/25/gaudily-syntax-highlighted-code-listings-in-archer-gdb/">show colorized source listings</a>, and <a href="http://www.visophyte.org/blog/2009/09/12/prototype-unified-javascriptc-back-traces-for-mozilla-in-archer-gdb/">provide unified JS/C++ mozilla backtraces</a> (with colors still) have experienced some bit-rot over time.</p>
<div id="attachment_763" class="wp-caption alignnone" style="width: 479px"><img class="size-full wp-image-763" title="cbt" src="http://www.visophyte.org/blog/wp-content/uploads/2011/03/cbt.png" alt="" width="469" height="335" /><p class="wp-caption-text">type &quot;cbt&quot;, see this</p></div>
<p>I have de-bitrotted the changes, hard.  Hard in this case means that the changes depend on gdb 7.3 which only exists in the future or <a href="http://sourceware.org/gdb/wiki/PythonGdb">in the archer repo you can find on this wiki page</a>, or maybe in gdb upstream but I already had the archer repo checked out&#8230;</p>
<div id="attachment_764" class="wp-caption alignnone" style="width: 622px"><img class="size-full wp-image-764" title="sl" src="http://www.visophyte.org/blog/wp-content/uploads/2011/03/sl.png" alt="" width="612" height="319" /><p class="wp-caption-text">type &quot;sl&quot;, see this.</p></div>
<p>In any event, if you like gdb and work with mozilla, you will not only want these things, but also <a href="http://hg.mozilla.org/users/jblandy_mozilla.com/archer-mozilla/">Jim Blandy&#8217;s mozilla-archer repo</a> which has magic SpiderMonkey JS helpers (one of which mozbt depends on; those JSStrings are crazy, yo!).  Coincidentally, he also depends on the future, and his README tells you how to check out the archer branch in greater detail.</p>
<p>You can get your own copy of these very exciting gdb python things from my github <a href="https://github.com/asutherland/pythongdb-gaudy">pythongdb-gaudy repo</a>.</p>
<p>The important notes for the unified backtrace are:</p>
<ul>
<li>It does&#8217;t work with the tracing JIT; the trace JIT doesn&#8217;t produce the required frames during its normal operation.</li>
<li>It might work with the method JIT if gdb could unwind method JIT frames, but it doesn&#8217;t seem to do that yet.  (Or I didn&#8217;t build with the right flag to tell it to use a frame pointer/etc., or I am using the wrong gdb branch/etc.)  Once the Method JIT starts telling gdb about its generated code with debug symbols and the performance issues in gdb&#8217;s JIT interface are dealt with, you can just use the colorizing backtrace because no special logic is required to interleave frames at that point and Jim Blandy&#8217;s magic JS pretty printers should &#8216;just work&#8217;.</li>
<li>Don&#8217;t forget that if you just want a pure JS backtrace (and with all kinds of fanciness) and have a debug build, you can just do &#8220;call DumpJSStack()&#8221; in gdb and it will call back into XPConnect and invoke the C++ code that authoritatively knows how to walk this stuff.</li>
<li>If you&#8217;re cool and using generators, then you&#8217;re stuck with the interpreter, so it will totally work.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.visophyte.org/blog/2011/03/30/unified-jsc-backtraces-colorized-backtraces-colorized-source-listing-for-gdb-7-3archer-trunk-updated/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>prototype unified JavaScript/C++ back-traces for Mozilla in (archer) gdb</title>
		<link>http://www.visophyte.org/blog/2009/09/12/prototype-unified-javascriptc-back-traces-for-mozilla-in-archer-gdb/</link>
		<comments>http://www.visophyte.org/blog/2009/09/12/prototype-unified-javascriptc-back-traces-for-mozilla-in-archer-gdb/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 13:36:52 +0000</pubDate>
		<dc:creator>Andrew Sutherland</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[gaudy]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[pyflam]]></category>

		<guid isPermaLink="false">http://www.visophyte.org/blog/?p=392</guid>
		<description><![CDATA[As far as I know (and ignoring my previous efforts on chroniquery along these lines), up until now you had your C/C++ Mozilla backtraces via gdb (chocolate) and your JS backtraces via &#8220;call DumpJSStack()&#8221; or the debugger keyword from within JS (peanut butter), but these two great flavors had never come together to make a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-393" title="fused-js-cpp-backtrace-2-upper-half" src="http://www.visophyte.org/blog/wp-content/uploads/2009/09/fused-js-cpp-backtrace-2-upper-half.png" alt="fused-js-cpp-backtrace-2-upper-half" width="704" height="360" /></p>
<p>As far as I know (and ignoring my previous efforts on <a href="http://www.visophyte.org/blog/2008/09/17/chroniquery-does-useful-things/">chroniquery</a> along these lines), up until now you had your C/C++ Mozilla backtraces via gdb (chocolate) and your JS backtraces via &#8220;call DumpJSStack()&#8221; or the debugger keyword from within JS (peanut butter), but these two great flavors had never come together to make a lot of money for dentists.</p>
<p>The screenshots (which is actually just one screenshot split in two) show invocation of a custom python gdb command building on my <a href="http://www.visophyte.org/blog/2008/09/17/chroniquery-does-useful-things/">previous exciting pretty gdb commands</a>.  The command has filtered out boring JS interpreter / XPConnect code and interleaved exciting interesting JS stack frames.</p>
<p>The implementation is reasonably simple and intended to be able to be implemented using VProbes to support my<a href="http://www.visophyte.org/blog/2009/08/03/using-vmware-recordreplay-and-vprobes-for-low-time-distortion-performance-profiling/"> recent performance work along those lines</a>.  We walk stack frames the usual way.  Ahead of time, we have marked out the PC ranges of interesting JS interpreter functions (js_Interpret and js_Execute).  If the stack frame&#8217;s instruction pointer is in one of those functions we grab the JSContext argument.  We pop frames until we reach the native frame those functions allocate from their own stack space (whose boundaries we know from the stack walking).</p>
<p>There is one trick we have to do involving dormantFrameChain.  While js_Execute has a consistent and straightforward usage of JS_SaveFrameChain, XPConnect and its quickstub friends are more complex.  Right now we use a dumb heuristic that just looks if our frame pointer is 0 and there is a dormantFrameChain, and in that case we restore it.  (Thankfully the garbage collector needs to know about the shelved frames, otherwise we might have to chase frames down.)  I haven&#8217;t put much effort into thinking about it, but the heurstic seems a bit reckless.  We could likely just concurrently walk the XPConnect context stack to figure out when to restore dormant frame chains.  The existing VProbe JS stack (only) code already goes to the horrible effort to get at the thread-local stack, so it wouldn&#8217;t be too much more work.  Things probably also fall down during garbage collection right now.</p>
<p>Hg repository is <a href="http://hg.mozilla.org/users/bugmail_asutherland.org/pythongdb-gaudy/">here</a>.  Under no circumstances try to use this with jblandy&#8217;s excellent archer-mozilla JS magic right now.  The current code is very distrustful of gdb.Value in a dumb way and does exceedingly dangerous things wherein pointers are bounced to strings and back to integers because direct integer coercion is forbidden.  With pretty printers installed this is likely to break.  Also, this is all only tested on 1.9.1.</p>
<p><img class="alignnone size-full wp-image-394" title="fused-js-cpp-backtrace-2-lower-half" src="http://www.visophyte.org/blog/wp-content/uploads/2009/09/fused-js-cpp-backtrace-2-lower-half.png" alt="fused-js-cpp-backtrace-2-lower-half" width="705" height="325" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.visophyte.org/blog/2009/09/12/prototype-unified-javascriptc-back-traces-for-mozilla-in-archer-gdb/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Better error reporting for the mozilla platform</title>
		<link>http://www.visophyte.org/blog/2009/05/16/better-error-reporting-for-the-mozilla-platform/</link>
		<comments>http://www.visophyte.org/blog/2009/05/16/better-error-reporting-for-the-mozilla-platform/#comments</comments>
		<pubDate>Sun, 17 May 2009 00:07:22 +0000</pubDate>
		<dc:creator>Andrew Sutherland</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[colors!]]></category>
		<category><![CDATA[gaudy]]></category>

		<guid isPermaLink="false">http://www.visophyte.org/blog/?p=307</guid>
		<description><![CDATA[If you develop for the mozilla platform, you might be used to error messages like the above.  (Or you might wish you got error messages like the above&#8230;)  An uncaught javascript exception has resulted in a message in the error console as well as some equivalent stdout spew because it&#8217;s a debug build.  While any [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.visophyte.org/blog/wp-content/uploads/2009/05/old-and-busted-error-reporting.png"><img class="alignnone size-full wp-image-305" title="old-and-busted-error-reporting" src="http://www.visophyte.org/blog/wp-content/uploads/2009/05/old-and-busted-error-reporting.png" alt="old-and-busted-error-reporting" width="806" height="76" /></a></p>
<p>If you develop for the mozilla platform, you might be used to error messages like the above.  (Or you might wish you got error messages like the above&#8230;)  An uncaught javascript exception has resulted in a message in the error console as well as some equivalent stdout spew because it&#8217;s a debug build.  While any error is better than no error, it doesn&#8217;t exactly narrow down how we got there.</p>
<p>Wouldn&#8217;t it be nice if we got back-traces for these errors?</p>
<p><a href="http://www.visophyte.org/blog/wp-content/uploads/2009/05/new-error-reporting-hotness.png"><img class="alignnone size-full wp-image-306" title="new-error-reporting-hotness" src="http://www.visophyte.org/blog/wp-content/uploads/2009/05/new-error-reporting-hotness.png" alt="new-error-reporting-hotness" width="749" height="138" /></a></p>
<p>The future is now, people!  And it comes in the convenient form of a patch against the 1.9.1 branch, just like you always dreamed!  Also, an extension.</p>
<p>Currently (pre-patch), there are basically 3 ways scripting errors can show up in the platform:</p>
<ol>
<li><a href="http://mxr.mozilla.org/comm-central/source/mozilla/js/src/xpconnect/idl/nsIScriptError.idl#47">nsIScriptError</a> instances.  These are what show up on the error console.  These have information equivalent to a single stack frame.</li>
<li><a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIException.idl#67">nsIException</a> instances.  These can provide a stack in the form of an <a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIException.idl#51">nsIStackFrame</a> chain (the same thing <a href="https://developer.mozilla.org/En/Components.stack">Components.stack</a> gives you).  These get converted into nsIScriptError instances when it comes time to report them to the error console.  From a stack perspective, only XPConnect produces nsIException instances with stack traces, although you can make your own via <a href="https://developer.mozilla.org/En/Components.Exception">Components.Exception</a>.  A fundamental limitation of these stack traces is that they are only constructed from live JS call stacks, so if a JS exception has unwrapped its way to the top-level you are out of luck.</li>
<li>JavaScript <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Error">Error</a> instances.  These have a private super-rich (it even knows arguments!) call-stack that can only be exposed as a string via the non-standard <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Error/stack">stack</a> attribute.  XPConnect understands JS error reports (the &#8216;flat&#8217; mechanism by which SpiderMonkey reports errors/exceptions to C++ code), but it has no clue about exceptions and their Error form of existence.  The exceptions in their error report guise are converted into nsIScriptError instances.</li>
</ol>
<p>What the <a href="https://bug493414.bugzilla.mozilla.org/attachment.cgi?id=377884">patch</a> (on <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=493414">bug 493414</a>) does is:</p>
<ul>
<li>Introduce an nsIScriptErrorEx interface that extends nsIScriptError to provide a &#8216;location&#8217; attribute like nsIException which is an nsIStackFrame.</li>
<li>Modify nsScriptError to implement the extended nsIScriptErrorEx.  Alternatively, I could have made XPConnect&#8217;s nsXPCException class implement nsIScriptError or nsScriptError also implement nsIException or something like that and not introduced nsIScriptErrorEx at all.</li>
<li>Modify all nsIScriptError-creation sites that I care about (I&#8217;m not looking at you, DOM workers) to try and provide or propagate existing nsIStackFrame information.</li>
<li>If a JS stack frame is not available, but an exception is in the form of a JS error, suck the call stack out of it.  Theoretically, this should not be a fallback but rather the default case, but it depends on some JS/XPConnect implementation details I am trying to avoid finding out about for now.</li>
<li>Modify the JS API to provide call stack sucking functionality.</li>
<li>Does various sketchy things to expose XPCJSStack::CreateStack from XPConnect to the error reporters in other modules.  If you thought the choice of creating nsIScriptErrorEx was sketchy, welcome to the <a href="http://ascher.ca/blog/2009/03/27/downtown-east-side-one-week-in/">Downtown East Side</a> of dubious patches.  I expect there is no chance of it working on Windows because of this, and you may be out of luck on OS X.  Behold your comeuppance, popular platforms!</li>
</ul>
<p>What the extension (<a href="http://hg.mozilla.org/users/bugmail_asutherland.org/exmmad/">repo</a>) does is:</p>
<ul>
<li>Add an nsIConsoleListener at app-startup that is aware of nsIScriptErrorEx and knows how to generate totally wicked 256-color ANSI escape sequences.</li>
<li>Not expose the stack traces in the error console.  The error console is for suckers who don&#8217;t have impossibly fast reflexes and a love of XON/XOFF flow control.</li>
<li>Only target Thunderbird.  Behold your comeuppance, all other mozilla applications!  (The extension wizard didn&#8217;t know how to do the thing that makes it work on all xulrunner-based things&#8230;  feel free to push a fixed install.rdf to my repo.)</li>
</ul>
<p>I have logged <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=493414">bug 493414</a> to hold the patch and hopefully track the effort moving forward.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.visophyte.org/blog/2009/05/16/better-error-reporting-for-the-mozilla-platform/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>gaudily syntax-highlighted code listings in (archer) gdb</title>
		<link>http://www.visophyte.org/blog/2009/04/25/gaudily-syntax-highlighted-code-listings-in-archer-gdb/</link>
		<comments>http://www.visophyte.org/blog/2009/04/25/gaudily-syntax-highlighted-code-listings-in-archer-gdb/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 06:36:39 +0000</pubDate>
		<dc:creator>Andrew Sutherland</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[colors!]]></category>
		<category><![CDATA[gaudy]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[pyflam]]></category>
		<category><![CDATA[Shiny]]></category>

		<guid isPermaLink="false">http://www.visophyte.org/blog/?p=281</guid>
		<description><![CDATA[Gaudily syntax-highlighted code listing in gdb joins the gaudy gdb plugin family!  (Other members include gaudily colorized backtraces, which you can also see in the bottom of the screenshot.)  This, of course, requires gdb with python crammed inside.  It might require one crammed a few months ago too; I haven&#8217;t updated my archer-gdb repo for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.visophyte.org/blog/wp-content/uploads/2009/04/pyglist.png"><img class="alignnone size-full wp-image-282" title="pyglist sl command output" src="http://www.visophyte.org/blog/wp-content/uploads/2009/04/pyglist.png" alt="pyglist sl command output" width="926" height="498" /></a></p>
<p>Gaudily syntax-highlighted code listing in gdb joins the gaudy gdb plugin family!  (Other members include <a href="http://www.visophyte.org/blog/2009/03/04/gaudily-colorized-gdb-backtraces-woo/">gaudily colorized backtraces</a>, which you can also see in the bottom of the screenshot.)  This, of course, requires <a href="http://sourceware.org/gdb/wiki/PythonGdb">gdb with python crammed inside</a>.  It might require one crammed a few months ago too; I haven&#8217;t updated my archer-gdb repo for at least that long.</p>
<p>The &#8220;sl&#8221; plugin uses <a href="http://pygments.org/">Pygments</a> for the syntax highlighting.  Although pygments has a 256 color terminal formatter (woo!), I ended up using my pyflam module because it did not support my need to color the background of the current line without doing something convoluted.  (I would have had to create a filter that did its own line-counting and created background-color-styled token variant of every token on the desired line.)  Also, it didn&#8217;t do line numbers.</p>
<p>The color theme is based off the &#8220;fruity&#8221; color theme.  Much of the gaudy comes from a filter I added that tries to do various Mozilla C++-aware code styling things by recognizing naming patterns of Name tokens.  Before you complain about the colors hurting your brain, remember that this is the alternative:</p>
<p><a href="http://www.visophyte.org/blog/wp-content/uploads/2009/04/not-pyglist.png"><img class="alignnone size-full wp-image-285" title="not-pyglist, standard list command" src="http://www.visophyte.org/blog/wp-content/uploads/2009/04/not-pyglist.png" alt="not-pyglist, standard list command" width="770" height="206" /></a></p>
<p>That&#8217;s right.  It&#8217;s like looking at static.  You can barely make anything out.  And imagine if it was more than just the 10 lines &#8220;list&#8221; gives you.</p>
<p>Anywho, the repo is here: <a href="http://hg.mozilla.org/users/bugmail_asutherland.org/pythongdb-gaudy/">http://hg.mozilla.org/users/bugmail_asutherland.org/pythongdb-gaudy/</a></p>
<p>The README tells you what to do.  For complete-ness, and because I went to all the effort to write documentation for the command, here is what it does!</p>
<pre>Prints a syntax-highlighted source listing.  Currently limited to only
work based on the current debug frame and position.

By default, the 11 lines before the current position and 8 lines after are
displayed.  A line context is saved between command invocations if the current
source line does not change.

Arguments when used in a new context:
  (none)  Shows the 11 lines before the current position and 8 lines after.
  N       Shows the N/2 lines befores the current position and N/2 lines after.
  -N      Shows the N lines before the current position and 8 lines after.
  +N      Shows the 11 lines before the current position and N lines after.
  M N     Shows the M lines before the current position and N lines after.

Arguments in an existing context:
  (none)  Shows the 20 lines after the last-shown lines.
  -       Shows the 20 lines preceding the last-shown lines.
  N       Shows the N lines after the last-shown lines.
  -N      Shows the N lines preceding the last-shown lines.
  M N     Shows the M last lines of the last-shown lines and N lines after the
            last-shown lines.

Arguments regardless of context
  @A,B    Shows lines A through B.</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.visophyte.org/blog/2009/04/25/gaudily-syntax-highlighted-code-listings-in-archer-gdb/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

