<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>rockyb</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/rockyb/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/rockyb/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/rockyb//1443</id>
    <updated>2012-09-14T07:27:50Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>A plan for revamping and replacing the Perl debugger.</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/rockyb/2012/09/a-plan-for-revamping-and-replacing-the-perl-debugger.html" />
    <id>tag:blogs.perl.org,2012:/users/rockyb//1443.3823</id>

    <published>2012-09-13T02:21:54Z</published>
    <updated>2012-09-14T07:27:50Z</updated>

    <summary>There is a little bit of overlap here with the first blog on Devel::Trepan. I apologize for that, but I don&#8217;t see how this can be avoided. The focus here though is more on the existing Perl debugger rather than...</summary>
    <author>
        <name>rockyb</name>
        
    </author>
    
    <category term="debugger" label="debugger" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/rockyb/">
        <![CDATA[<p><em>There is a little bit of overlap here with the first blog on Devel::Trepan. I apologize for that, but I don&#8217;t see how this can be avoided. The focus here though is more on the existing Perl debugger rather than Devel::Trepan which is given as one concrete example from which to draw lessons from.</em></p>

<p>A number of people, myself included, have talked about modernizing or replacing the venerable Perl debugger, <em>perl5db.pl</em>. Here I&#8217;d like to suggest a plan of action.</p>

<p>First the situation. It is in many ways similar to the challenges faced say in going from Perl5 to Perl6 &#8212; and in other languages Ruby 1.8 to 1.9 or Python 2.7 to Python 3K. What is there is:</p>

<ul>
<li>well known</li>
<li>battle tested</li>
<li>has lots of features, and is therefore&#8230;</li>
<li>useful &#8230;</li>
<li>used by a large number of people &#8230;</li>
<li>and comes with Perl</li>
</ul>

<p>That&#8217;s the good side. On the bad side, what is there is doesn&#8217;t represent current modern programming practice. In particular
it is one large 10K file. It isn&#8217;t modular in two aspects. First, it doesn&#8217;t use Perl Modules or namespaces very effectively. Second, it doesn&#8217;t have an API that facilitates extension of its debugger commands or provide an API that allows front-ends to easily hook into it. This is not to say that, people haven&#8217;t extended tor written front ends for it. But these all feel like uncoordinated, custom, and heroic efforts.</p>

<p>Related to perl5db being large and not modular, there aren&#8217;t many tests for it, especially not the smaller &#8220;glass-box&#8221; unit tests. Even with the recent activity of adding tests to perl5db.pl, those tests and coverage pale in comparison to those that comes with Devel::Trepan. And to be honest, the coverage in <em>Devel::Trepan</em> leaves something to be desired. But comparing the number of tests does give a feel for how much is probably missing in terms of testing for <em>perl5db.pl</em>. </p>

<p>Finally, <em>perl5db</em> feels to me one-off in its command set. There is no other debugger that I know of that is similar to it to any great extent. Sure, all debuggers allow some sort of stopping, stepping and evaluation of expressions, but that is about where the similarity ends.</p>

<p>There have been some inquiry about using <em>Devel::Trepan</em> or something else as a replacement for <em>perl5db.pl</em>. It appears to me that in the past there have been efforts, and understanding why those have not succeeded might be instructive. </p>

<p>The challenges in replacing <em>perl5db.pl</em> are suggested by looking at perl5db.pl&#8217;s advantages. One of the harder challenges that I see is, again, similar to revamping Perl itself. How does one migrate programmers from <em>perl5db</em> given that there are already a number of people using <em>perl5db.pl</em>, either directly or via a front-end and are happy with it and the features it provides no matter how arcane or fragile they may be?</p>

<p>The overall approach I suggest is really two fold and again not unlike what I see for example in Perl5 versus Perl6. One approach is to work on a replacement such as Perl6 or <em>Devel::Trepan</em>. The replacement debugger aspect is what I have been doing. The other is approach to rework the existing debugger to modernize it. (For Perl5 there is perl5-porters which is trying to modernize Perl5). One hopes that the two disparate efforts meet in the middle, hopefully more towards <em>Devel::Trepan</em> or Perl6 side since both ends of the efforts are moving presumably forward.</p>

<p>But how does that specifically apply here to Perl debugger(s)? I&#8217;ve offered some <a href="http://news.perlfoundation.org/2012/08/2012q3-grant-proposal-adding-t.html">specific suggestions on writing tests</a> on the <em>perl5db.p</em>l project proposal.</p>

<p>At some point I should probably write more about how I test <em>Devel::Trepan</em>. I find it relatively easy, although it really needs more explanation as it might not be as self-evident until after the fact.</p>

<p>The other area I think very important is defining more of a debugger API as opposed to a command-line interface. The DB API effort was from a while ago, but it looks like that was also abandoned long ago.</p>

<p>In <em>Devel::Trepan</em> I am pretty convinced I have laid the ground work for using parts of the DB API but equally important isolating and breaking out other modules. There is something called an &#8220;interface&#8221; that glues together I/O layers so output could very easily be XML (or XML over a socket) rather than less-structured text. And there is a &#8220;Command Processor&#8221; which has command-oriented part but there are more API-ish things available separated from the specific command-line commands. </p>

<p>An interesting exercise is that someone should be able to replace <em>Devel::Trepan::CmdProcessor</em> so that it handles <em>exactly</em> the <em>perl5db.pl</em> commands using the other parts of  <em>Devel::Trepan</em> &#8212; the Interface part with its separate I/O routines  and the lower-level DB part which sort of subsumes the DB API. To date though, all of the people I&#8217;ve mentioned this to have felt that the <em>perl5db.pl</em> is ugly and are therefore are not interested in. However, I suspect there are people out there who don&#8217;t want to switch from <em>perl5db.pl</em>. </p>

<p>Right now in <em>Devel::Trepan</em> there is a DB layer that ultimately should be pulled out of <em>Devel::Trepan</em> and turned into a separate package that <em>Devel::Trepan</em> uses. This similar to what <em>perl5db</em> and the <em>DB</em> API both use. This is another area where I feel there should be a &#8220;meeting in the middle&#8221;. The two reasons I have not separated this out right now is that the <em>DB</em> namespace is special in its powers and that namespace is taken. So I can&#8217;t register that. Secondly, right now <em>Devel::Trepan</em> is the only user of this. So breaking this out adds gratuitous complexity for <em>Devel::Trepan</em> users. For example, if I change that lower-level API in an incompatible way, <em>Devel::Trepan</em> will also have to change. And users of <em>Devel::Trepan</em> will have to update two packages where they would have had to update only one when they are bundled together. </p>

<p>Still, if <em>Devel::Trepan</em> becomes more popular or there is a desire in other packages to use some of the lower level routines, this can be changed. For example, <em>DB::LineCache</em> caches Perl source code lines. When there is another package that wants to use that, I&#8217;ll make the split. </p>

<p>Let me close this off by listing things that a new debugger should have, some of which has been alluded to above:</p>

<ol>
<li>It needs to be modular and represent current programming practice. However it probably needs to handle lots of older Perls as well.</li>
<li>It needs to work in minimal and hostile environments. And that&#8217;s why in <em>Devel::Trepan</em> I don&#8217;t use Moose. </li>
<li>On the other hand it should be extensible so that environments it can use things that many environments might have. For example terminal coloring, nice data structure formatters, disassemblers, interactive shells like <em>Devel::REPL</em>. </li>
<li>It should facilitate hooking into front-ends like <em>Padre</em> or <em>Eclipse</em> and so on, and out-of-process or out-of-host remote debugging (which for example is useful in debugging web server modules). </li>
<li>It should facilitate different styles of debugging and debugger entry: non-interactive tracing, or pulling in the debugger in via a signal handler or Josh Ben-Jore&#8217;s Enbugger.  </li>
</ol>
]]>
        

    </content>
</entry>

<entry>
    <title>Devel::Trepan 0.31 release</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-030-release.html" />
    <id>tag:blogs.perl.org,2012:/users/rockyb//1443.3711</id>

    <published>2012-08-20T01:30:19Z</published>
    <updated>2012-08-21T05:24:54Z</updated>

    <summary>A new release of Devel::Trepan is out there. A number of changes were the result of problems found in writing the various debugger blogs and in preparing for a little local NY Perl Mongers meeting. Possibly there will be one...</summary>
    <author>
        <name>rockyb</name>
        
    </author>
    
    <category term="debugger" label="debugger" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/rockyb/">
        <![CDATA[<p>A new release of <em>Devel::Trepan</em> is out there. </p>

<p>A number of changes were the result of problems found in writing the various <a href="http://blogs.perl.org/users/rockyb/2012/08/location-location-location.html">debugger blogs </a> and in preparing for a little local <a href="http://www.meetup.com/The-New-York-Perl-Meetup-Group/events/78230112/">NY Perl Mongers meeting</a>. </p>

<p>Possibly there will be one more debugger blog on stepping.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Location, Location, Location </title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/rockyb/2012/08/location-location-location.html" />
    <id>tag:blogs.perl.org,2012:/users/rockyb//1443.3686</id>

    <published>2012-08-12T11:35:36Z</published>
    <updated>2012-08-19T21:38:15Z</updated>

    <summary>By way of explanation... In preparing this and my previous blogs, I have noticed aspects where Devel::Trepan could be improved. For this blog, I discovered when comparing Devel::Trepan output with that from a recent perl5db that perl5db sometimes prints several...</summary>
    <author>
        <name>rockyb</name>
        
    </author>
    
    <category term="debugger" label="debugger" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/rockyb/">
        <![CDATA[<h3>By way of explanation...</h3>

<p>In preparing this and my previous blogs, I have noticed aspects where <a href="https://metacpan.org/module/Devel::Trepan"><i>Devel::Trepan</i></a> could be improved. For this blog, I discovered when comparing <i>Devel::Trepan</i> output with that from a recent <i>perl5db</i> that <i>perl5db</i> sometimes prints several lines of output to try to show a full Perl statement. <i>Devel::Trepan</i> prints a single line &mdash; normal in command-line debuggers. However, do see the <i>set auto list</i> command.

<p>As I've done in preparing <a href="http://blogs.perl.org/users/rockyb/2012/07/on-writing-a-new-perl-debugger-part-1---why.html">previous</a> <a href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-debugger-command-aliases-and-command-completion.html">blogs</a>, I then take time from writing the blog to improve <i>Devel::Trepan</i>. Although no one has said anything about this yet in prior blogs, the output you see in the blogs may be a little bit different than what you see if you install from CPAN. However it does match what you will see if you install from <a href="https://github.com/rocky/Perl-Devel-Trepan">the github repository</a>.</p></p>

<p>But this brings up a couple of other points. First, that one of the reasons that <i>perl5db</i> is probably hard to replace by <i>any</i> debugger is that right now people are still tweaking it.

<p>Before I had started <i>Devel::Trepan</i>, I was trying to the acess alternatives to <i>perl5db</i> and came across the <a href="http://perldoc.perl.org/DB.html">DB API</a> which makes the <i>DB</i> package more object oriented. There are a couple of interesting ideas I have used; it also modularizes the code more. I figured since it was on the <i>perl.org</i> site and part of the CORE modules, it was being actively maintained. Then I got to this part in the <a href="http://perldoc.perl.org/DB.html#BUGS">BUGS</a> section:

<blockquote>
The interface defined by this module is missing some of the later additions to perl's debugging functionality
</blockquote>

<p>This is a bit of an understatement. How old is the version of <i>perl5db</i> that  <i>DB</i> uses? The <i>DB</i> code is virtually unchanged since Perl 5.8.9. The difference between the version in Perl 5.8.9 and Perl 5.6.2 are some small bug fixes. Given this, the <i>perl5db</i> code that the <i>DB</i> module is based off of is about a decade old. <i>perl5db</i> has changed a lot since then and continues to change a little.</p>

<p>My second point here, however is a little more optimistic. It didn't take me long to improve <i>Devel::Trepan</i> so it had the enhancement. Furthermore, all the pains taken to make the code more modular and testable <i>do</i> pay off here, at least for me. I was able to test this aspect in isolation and without having to install the code in order to test it out. The integration tests also notice the change.</p></p>

<p>And now that I have made the change, even those of you who are running an older Perl, you can get this feature now in <i>Devel::Trepan</i>. But until I make another release, you need to use the github repository.</p>

<p><i>Note to perl5db advocates:</i> If you feel this is an unfair advantage to <i>Devel::Trepan</i>, there is a simple fix &mdash; provide <i>perl5db</i> as a module of its own on CPAN. (Devlish grin.)

<h3>Now back to your regularly scheduled blog...</h3>

<p>One important piece of information that a debugger provide is where you are, and why. Although this simple and basic, part of what I'll discuss below is how and when it gets difficult.</p>

<p>Programming Languages that don't support debugging tend be looser about recording location information accurately. In fact every programming language where I have worked on a debugger where previously there was none or where it was weak, I have found that I had to correct <a href="http://rubyforge.org/tracker/?func=detail&atid=22040&aid=18749&group_id=426">inaccuracies or vagueness or in the parsing</a> or run-time system.</p>

<p>While reporting a vague or misleading location in say a <code>die</code> location may be tolerated by a Perl programmer (although not appreciated), in a debugger reporting the wrong or vague location is unacceptable.</p>

<p>But the good news for Perl is that since it has had a debugger for a very long time, many of location weaknesses have long been corrected.</p>

<p>Let's now look at how a location and status is reported in <i>Devel::Trepan</i>. </p>

<pre>
$ <b>trepan.pl gcd.pl 3 5</b>
-- main::(gcd.pl:18)
die sprintf <font color="gray">"Need two integer arguments, got %d"</font>, scalar(<font color="blue">@ARGV</font>) unless 
    <font color="blue">@ARGV</font> == <font color="blue">2</font>;
                                                                            <u>(trepanpl):</u>
</pre>

<p>The location reporting here is more like <i>perl5db</i> than it is <i>gdb</i>. <a href="http://blogs.perl.org/users/rockyb/2012/08/to-gdb-or-not-to-gdb.html">Perhaps this is a mistake</a>, but when I embarked on the first debugger, <a href="http://bashdb.sf.net">one for bash</a>, I recall feeling that <em>perl5db</em>'s format was nicer. Still, the location output above is a little bit different from both in some respects.</p></p>

<p>Since the line we are stopped on isn't a full Perl statement, the next line which completes the statement is shown. More recent <i>perl5db</i> does this too while <em>gdb</em> and many other command-line debuggers do not. 

<p>The heuristic that both use can be somewhat easily fooled. For example, if your statement is a string that spans several lines and has what looks like a comment or a blank line, both will think that's the end of the statement. That is, if your statement is:</p>

<pre>
  $x = <<'EOS';
Hi
# This is not a comment
EOS
</pre>

<p>when either debugger is stopped at the assignment above, they show the line with "Hi" in it, but not the line after that.</p></p>

<p>Here is another thing to notice. In showing the source text, <i>Devel::Trepan</i> doesn't include the line number at the left. This was a usability thing for me. The line number is redundant in <i>perl5db</i> and <i>gdb</i> because it is given on the line before listing the source code. I prefer to see the line as it really is in the source text. If you want line numbers before the source code, use the <i>list</i> command.</p></p>

<p>Another difference which might be a bit subtle here is the innocuous-looking "<code>--</code>" at the beginning of the line</p>

<pre>
-- main::(gcd.pl:18)
</pre>

<p>This is a two-character icon for the event name. An <i>event</i> is the reason that you were stopped. Here <code>--</code> indicates a "line" event and is given when you have just started the program or have stopped because of stepping. A full list of even icons and there meaning is given on the <a href="https://github.com/rocky/Perl-Devel-Trepan/wiki/Event-icons"><i>Perl::Devel::Trepan</i> github wiki</a>.</p>

<p>Another way to see the more complete event name is to use one of the debugger commands taken from <i>gdb</i>: "<code>info program</code>" or "<code>info line</code>". Here are examples of using those:</p>

<pre>
<u>(trepanpl):</u> <b>info program</b>
Program: gcd.pl.
Program stop event: line.
<u>(trepanpl):</u> <b>info line</b>
Line 18, file gcd.pl
</pre>

<p>What I would like to add but don't know how to do is add something called "COP address". As described in the <a href="http://perldoc.perl.org/B/Concise.html#OP-class-abbreviations">B::Concise documentation</a>, a "COP" is an operation that starts the beginning of a statement. I recall reading somewhere "COP" stands for "Control OpCode". </p>

<p>Why include this? I'll get back to this shortly.</p>

<p>Suppose you are trying to debug your new <a href="http://en.wikipedia.org/wiki/Obfuscated_Perl_Contest">Obfuscated Perl</a> or <a href="http://en.wikipedia.org/wiki/Just_another_Perl_hacker">JAPH</a> code? This is a fine use of a debugger if there ever was one. It is also a good stress-test case of the debugger too. </p>

<p>Let's say your Perl code is this:<br />
<pre><br />
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(<br />
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;<br />
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++<br />
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`<br />
</pre></p>

<p>You can debug it this way: </p>

<pre>
trepan.pl  -e '`$=`;$_=\%!;($_)=/(.)/;$==++$|;...`'
</pre>

<p>Or the more traditional Perlish way: </p>

<pre>
perl -d:Trepan -e '`$=`;$_=\%!;($_)=/(.)/;$==++$|;...`'
</pre>

<p>I would like to be able to give some indication of where you are in that multi-line statement. There are 3 approaches that I can think of. However first let me explore a misconception. </p>

<p>If you reformatted this with a Perl pretty printer like <a href="https://metacpan.org/module/perltidy">perltidy</a>, wouldn't that do the trick? Well, yes, it helps; but that's not the whole story. Suppose your code is this:</p>

<pre>
#...
@x = ($a/$b, $c/$d);
</pre>

<p>If an "Illegal division by 0" occurs, was the division in the first entry of the array or the second? So let me restate the problem.  We want a way to identify in a Perl program more precisely &mdash; generally more precise than a line and filename &mdash; where the program was at various "trace" points. A "trace" point can be a call, a place where an exception can occur, or at a Perl statement boundary.</p>

<p>The first way to give more precise location information would be to improve the Perl implementation to pass column information within the line down to make it accessible somehow at runtime. It could be stored in the OP nodes, or as in separate place which is accessible when needed. This latter approach is done in more static languages and standarized in the various binary formats like <a href="http://en.wikipedia.org/wiki/COFF">COFF</a> or ELF's <a href="http://en.wikipedia.org/wiki/DWARF">DWARF</a>. I think the liklihood of this happening is slim and it adds more overhead the interpreter. </p>

<p>The second way to give more precise location information is a little ugly but probably the most doable: Give a disassembly of the instruction tree at that trace point. In a debugger this is at the point the program is stopped at. <i>Devel::Trepan</i> has a plugin to add a <code>dissassemble</code> command allows you to see dissassembly of the code around the line the program is stopped at. But right now, I can't figure out how to get information on which node is the one that is going to be interpreted next. </p>

<p>The third possibility extends on the idea of pretty printing the source code. But it goes in the other extreme direction than that given above in the obfuscated code: put each Perl token on its own line. </p>

<p><i>Scratch this third possibility: line information is only stored in COP nodes and those appear only at <b>statement</b> boundaries.</i></p>

<p>Now let us go back to one of the "<code>perl -e</code>" invocations given above. When you are debugging the obfuscated code, stopped inside the debugger, in what "file" are you in? Well, there isn't a file in a file system. So what Perl does is report that as "eval" and some number. And in the runtime access to lines in that "file" work as though there were lines in a filesystem. However what if you are working from a front-end GUI such as <a href="https://metacpan.org/module/Padre">Padre</a>, or the <a href="https://github.com/rocky/emacs-dbgr/wiki">one I wrote for GNU Emacs</a>? What <i>Devel::Trepan</i> does to make it easier here is <i>write</i> the eval string to a temporary file changing the location reported from a psuedo-filename into a real one, albeit temporary. Having this eval string in expanded form is also helpful even if you are just in <i>Devel::Trepan</i> because you might want to edit that temporary file in order to understand how the expansion worked or modify and experiment with it. <br />
</p>]]>
        
    </content>
</entry>

<entry>
    <title>To gdb or not to gdb?</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/rockyb/2012/08/to-gdb-or-not-to-gdb.html" />
    <id>tag:blogs.perl.org,2012:/users/rockyb//1443.3666</id>

    <published>2012-08-08T08:33:59Z</published>
    <updated>2012-08-14T02:41:17Z</updated>

    <summary>Whether &apos;tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles Spoiler alert: the answer is 1 or true Before delving back in the next planned blog...</summary>
    <author>
        <name>rockyb</name>
        
    </author>
    
    <category term="debugger" label="debugger" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/rockyb/">
        <![CDATA[<blockquote>Whether 'tis nobler in the mind to suffer<br>
The slings and arrows of outrageous fortune,<br>
Or to take arms against a sea of troubles</blockquote>

<p><em>Spoiler alert: the answer is 1 or true</em></p>

<p>Before delving back in the next planned blog post of another important nuts-and-bolts <a href="https://metacpan.org/module/Devel::Trepan"><em>Devel::Trepan</em></a> topic &mdash; <a href="http://blogs.perl.org/users/rockyb/2012/08/location-location-location.html">position and status information</a> &mdash; I'd like to take a step back and talk a little bit philosophical like I did in the first blog.</p>

<p> In <a href="http://blogs.perl.org/users/rockyb/2012/07/on-writing-a-new-perl-debugger-part-1---why.html">that blog</a>, I wrote something a bit contradictory. I wrote that I wrote <em>Devel::Trepan</em> to follow <em>gdb</em>.  But at the end of the blog I wrote that I wanted it to be more of a platform for (cough, cough) research.</p></p>

<p>The coughing noise you hear is because as far as I can tell there has been very <em>little</em> research on debuggers that I am aware of. If you know of some, let me know. I think there has been an emergence or awareness of <a href="http://en.wikipedia.org/wiki/DTrace">dtrace</a>-like implementations and protocols which are more popular in <a href="http://bugs.ruby-lang.org/issues/2565">Ruby</a> than in <a href="https://metacpan.org/module/Devel::DTrace">Perl</a> . There is the sadly and largely ignored work on protocols for debugging such as <a href="http://xdebug.org/docs-dbgp.php">DBGP</a> for which there is even an implementation in Perl. There is possibly <a href="http://www.gnu.org/software/gdb/news/reversible.html">reverse debugging</a> which is new in gdb 7. But this idea goes back a while.</p>

<p>So let me back off expectations of "research". Think of what I mean more in the category of software-engineering usability issues in what a debugger might offer to make it easier to debug programs.</p>

<p>Still, there is the contradiction: how can one do research and still follow <em>gdb</em>? And the answer is simple: you can''t completely.</p>

<p>So what I meant is: <em>be like gdb, unless there is reason not to</em>. </p>

<p>To prove that I really mean to be like <em>gdb</em>, I will mention a recent <a href="https://github.com/rocky/Perl-Devel-Trepan/issues/7">bug</a> where I was caught in erroneously  thinking that in <em>gdb</em> "d" meant "down" (it means "delete"), while "u" meant "up" (it means "until").  Fixing this means making an incompatible change to possibly 7 or so other debuggers for which I'll probably have to take the heat for. But when I am wrong, I am wrong.</p>

<p>But let's now go into areas where we don't strictly follow <em>gdb</em>. </p>

<p>One area alluded to in the <a href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-debugger-command-aliases-and-command-completion.html">second blog</a> had to do with macros and aliases; <em>gdb</em> doesn't have command aliases. It has <em>macros</em> which are more powerful and subsumes command aliases. But because it is a little more cumbersome, I thought I would add this simpler mechanism which covers most of what I think will be programmers' needs. And we don't follow <em>gdb</em>'s macros because Perl already is a good programming language for writing debugger macros. Also, people using the Perl debugger probably already are familiar with Perl. So why invent another language? <em>gdb</em> has to do that because it is <em>not</em> a Perl, or Python, or Lisp, or POSIX Shell, or Ruby debugger. It is a debugger for C, C++, Objective-C, Java, Fortran, Pascal, Modula-2 or Ada which is generally a different crowd. Most of those languages don't have an <em>eval()</em> function. And even if they did, would you want to write debugger macros in a statically typed language where you have to declare variables? Even if some variables were pre-defined, I'm not sure I would want to write my debugger macros in, say C.</p>

<p>The point I am trying to make here is that in this case, for macros, it doesn't make sense to follow <em>gdb</em>. And while I have written debuggers in POSIX shell, Perl, Python and Ruby, the macro language used in each debugger is not one common language (as it is in <em>gdb</em>). Instead, the underlying of the language of the program getting debugged.</p>

<p>The example of macros introduces two other broad areas. First, that while <em>gdb</em> is a debugger for <em>static</em> languages, Perl is not a static language. Second, each programming language has its own idiosyncrasies. An example of this second category for Perl is in the dynamically-scoped "local" variables. </p.

<p>Furthermore, different implementations have their own run-time environments and these too add their own twists. Fortunately for Perl, there's basically the one implementation &mdash; if you don't count Perl 6. If you do count Perl 6, a big difference I think is that the parrot interpreter is instruction based while the Perl 5 interpreter is tree-based.</p>

<p>But let me take an example from Ruby where I have more experience. There is a  Ruby implementation where the run-time environment is written mostly written in C. This implementation is called MRI. There is another implementation that is written mostly in Ruby, called <a href="http://rubini.us/">Rubinius</a>. Imagine in Perl if most of the built-in functions like <i>shift()</i>, <i>substr()</i>, <i>grep()</i>, and even many of the "operators" like hash/array indexing, and slicing were written in Perl. That sort of gives you a feel of Rubinius. MRI, has callbacks to the debugger/tracer when you are entering and leaving a C function, but of course not stepping inside the C function. Rubinius on the other hand allows C extensions through <a href="http://en.wikipedia.org/wiki/Foreign_function_interface">FFI</a> and tracing/debugging doesn't show these foreign calls. 

<p>Now consider now the difference in debugging the same Ruby program in MRI versus Rubinius.  Since many primitives of the MRI implementation are written in Ruby in Rubinius, single stepping in Rubinius is more tedious. Consequently, in a debugger for Rubinius it is more imperative to provide mechanisms to make stepping less cumbersome where "step over" instead of "step in" is more used.</p>

<p> <p>It turns out though that improvements in ways to step is beneficial on other Ruby's as well as Perl.<p></p>

<p>A discussion about stepping may too one day be a blog entry. But it also is one area where I think it may be useful to extend what is available in <em>gdb</em>. To be fair, <em>gdb</em> has also fairly recently extended its <code>step</code> command. And so, sometimes in the past it has happened I have not followed <em>gdb</em> only to later change things more towards <em>gdb</em> when it catches up.

<p><br />
</p>]]>
        
    </content>
</entry>

<entry>
    <title>Devel::Trepan Debugger evaluation of Perl statements</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-debugger-evaluation-of-perl-statements.html" />
    <id>tag:blogs.perl.org,2012:/users/rockyb//1443.3655</id>

    <published>2012-08-03T22:57:13Z</published>
    <updated>2012-09-01T10:28:22Z</updated>

    <summary>In the last blog, I started describing features that are new in Devel::Trepan that aren&apos;t in perl5db. Here I will continue with one more: the evaluation aspects of the debugger REPL (read, eval, and print loop). By default, when you...</summary>
    <author>
        <name>rockyb</name>
        
    </author>
    
    <category term="debuggerdeveltrepan" label="debugger Devel::Trepan" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/rockyb/">
        <![CDATA[<p><a href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-debugger-command-aliases-and-command-completion.html">In the last blog</a>, I started describing features that are new in <a href="https://metacpan.org/module/Devel::Trepan"><em>Devel::Trepan</em></a> that aren't in <em>perl5db</em>. Here I will continue with one more: the <em>evaluation</em> aspects of the debugger REPL (<u>r</u>ead, <u>e</u>val, and <u>p</u>rint <u>l</u>oop). </p>

<p>By default, when you type something that isn't a debugger command the debugger just tries to evaluate the string you gave it. If what you typed was really a mistyped debugger command you might get a weird error message. For example:</p>

<pre>
<code>
<u>(trepanpl):</u> <strong>stp</strong>
Unquoted string "stp" may clash with future reserved word ...
</code>
</pre>

<p>If you don't want this behavior, you can turn off "auto eval". And here is what happens then:</p>

<pre>
<u>(trepanpl):</u> <strong>set auto eval off</strong
set auto eval is off.

<p><u>(trepanpl):</u> <strong>stp</strong><br />
<u>** Undefined command: "stp". Try "help".</u><br />
</pre></p>

<p>By the way, bold and underline really is what you get in the debugger if the terminal you are using supports underlining and bold.</p>

<p>Now let's go back and type some Perl commands to be evaluated and let us see what happens.</p>

<pre>
$ trepan.pl <strong>gcd.pl 3 5</strong>
-- main::(gcd.pl:18)
die sprintf <font color="gray">"Need two integer arguments, got %d"</font>, scalar(<font color="green">@ARGV</font>) unless 
     <font color="blue">@ARGV</font> == <font color="blue">2</font>
<u>(trepanpl):</u> <strong>$0</strong>
$DB::D[1] = gcd.pl
 
(trepanpl): <strong>@ARGV</strong>
$DB::D[2] =
@{[
    [0] 3,
    [1] 5
]}
</pre>

<p>In the above there is again a little bit to explain. First, As mentioned in the first blog, the code itself is colorized. Second, notice the format of the output in showing the array <code>@ARGV</code>. This is comes from the module <em>Data::Printer</em>, because I happened to have this installed. </p>

<p>Because <em>Data::Printer</em> pulls in a number of dependencies and <em>Devel::Trepan</em> should work in somewhat sparse environments, that module is not a required dependency. Instead <em>Data::Dumper</em> is a dependency and <em>Data::Dumper</em> does not depend on anything. We can also use <em>Data::Dumper::Perltidy</em> if that is installed. Originally that was required instead of <em>Data::Dumper</em> even though it pulls in other modules. However I backed away from that when it learned that on some systems there is a bug that can cause it not to be installed.</p>

<p>To recap. The order of preference that <em>Devel::Trepan</em> uses is first <em>Data::Printer</em>. Failing that, <em>Data::Dumper::Perltidy</em>; and failing that, <em>Data::Dumper</em> which should be around because it is a build dependency.  You can specify which type of print output you want using the <code>set display eval</code> debugger command.</p>

<p>Another thing to notice is that the results of evaluation is pushed onto the array <em>@DB::D</em>.</p>

<p>Next, notice that the debugger changed <code>$0</code> from what it was initially, <code>trepan.pl</code>, to what it would have been if you hadn't been debugging the program, <code>gcd.pl</code>. And thanks to the <a href="http://www.perlmonks.com/?node_id=985545">perlmonks</a>, <code>__FILE__</code> and <code>__LINE__</code> are now also handled properly. </p>

<p>The last item worth mentioning is to note that the debugger figured out that <code>@ARGV</code> was an array while <code>$0</code> is a scalar. How did it get the evaluation context correct? In this case it was simple: it looked at the first non-blank character of what you wanted to evaluate. </p>

<p>In more complex situations such as when you evaluate a function, the debugger's eval code might not be able to figure out whether a scalar context or an array context was intended. In those cases, it is pretty easy to tell the debugger what you mean. Just use the debugger aliases for the <em>eval</em> command <code>@</code> or <code>$</code>. Here is an example:</p>

<pre>
<u>(trepanpl):</u> <strong>grep {/\d+/} @ARGV # default context is scalar</strong>
$DB::D[3] = 2
<u>(trepanpl):</u> <strong>$ grep {/\d+/} @ARGV</strong>
$DB::D[4] = 2
<u>(trepanpl):</u> <strong>@ grep {/\d+/} @ARGV</strong>
$DB::D[5] =
@{[
    [0] 3,
    [1] 5
]}
</pre>

<p>If you were astute, you might have noticed those two aliases in the list of aliases shown in the <a href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-debugger-command-aliases-and-command-completion.html">last blog</a> where I described a little about debugger command aliases.</p>

<p>Some debugger commands such as <em>eval</em> use suffixes on alias names to modify their behavior a little.  Another example of this is <em>quit</em> or <em>kill</em> which have aliases with an exclamation point at the end. When the exclamation point is added, these debugger commands don't prompt for confirmation, although by default they normally they would. That is, while <code>quit</code> asks you if you are sure you want to quit (as <em>gdb</em> does), <code>quit!</code> or <code>q!</code> doesn't prompt.</p>

<p>But back to <em>eval</em>. The at sign <code>@</code> is an alias for the debugger command <code>eval</code>; <code>eval@</code> is another longer alias for the same thing. </p>

<p>Now that we've been exposed to the debugger command <em>eval</em>, a little more about it. Giving it a string to evaluate ultimately runs Perl's <em>eval()</em>. So in the example above, rather than type "<code>$0</code>", I could have typed the longer "<code>eval $0</code>", or "<code>eval$ $0</code>" and I would have gotten the same results.  Similarly for "<code>@ARGV</code>", "<code>@ @ARGV</code>", or "<code>eval@ @ARGV</code>". </p>

<p>But <em>eval</em> has a couple more tricks up its sleeve! Often when stopped inside the debugger you want to see what the upcomming command is going to do. For that, type "<code>eval</code>" without supplying a string. The <em>eval</em> command will then use as its string to evaluate the current source line of the stopped Perl program.</p>

<p>Here is an example that shows that:</p>

<pre>
$ <strong>trepan.pl /tmp/foo.pl</strong>
-- main::(/tmp/foo.pl:2)

<p><u>(trepanpl):</u> <strong>list</strong><br />
<strong>/tmp/foo.pl [1-5]</strong><br />
  1    	use <font color="green">File::Basename</font>;<br />
  2  ->	<font color="green">$x</font> = basename(<font color="blue">__FILE__</font>);<br />
  3    	if (<font color="green">$x</font> =~ /<font color="blue">foo.pl</font>/) {<br />
  4    	    print "<font color="blue">Fooish here</font><font color="brown">\n</font>";<br />
  5    	}<br />
<u>(trepanpl):</u> <strong>$x</strong><br />
$DB::D[1] = <undef><br />
<u>(trepanpl)</u>: <strong>eval</strong><br />
$DB::D[1] = "foo.pl"<br />
<u>(trepanpl):</u> <strong>$x</strong><br />
$DB::D[2] = foo.pl<br />
</pre><br />
                                                                     <br />
In the above, we use the debugger commands, <em>list</em> which gives a source code listing of a small number of lines. Notice that the <em>eval</em> command ran the command and set the variable <code>$x</code>.</p>

<p>But wait, there's more! Sometimes the line you are stopped on isn't a full statement but has a part of it that makes sense to evaluate. For example it might be part of an <em>if</em> statement. Here what you often want to see is what the expression part in the <em>if</em> statement is. For that, use <em>eval?</em>:</p>

<pre>
-- main::(/tmp/foo.pl:3)
if (<font color="green">$x</font> =~ /<font color="blue">foo.pl</font>/) {
<u>(trepanpl):</u> <strong>eval?</strong>
eval: $x =~ /foo.pl/
$DB::D[3] = 1
</pre>

<p>Notice in the above the debugger echoes the part of the string in the line of code that it is using so you know which part it picked up.</p>

<p>See the help text for the <em>eval</em> command for more details of what happens when the question-mark suffix is used in an alias. See also an eariler <a href="https://github.com/rocky/Perl-Devel-Trepan/wiki/Evaluation-of-Expressions">wiki entry</a> where some this material is presented a little bit differently.</p>

<p>Given all of the care above in the evaluation part, you might think people would be happy with this. My own experience is that people  still sometimes want to go into a real <em>Devel::REPL</em> shell. If you have that module installed, there is a plugin package called <a href="http://search.cpan.org/~rocky/Devel-Trepan-Shell/lib/Devel/Trepan/Shell.pm"><em>Devel::Trepan::Shell</em></a> which adds a <em>shell</em> command and alias <em>re.pl</em>.<br />
</p>]]>
        
    </content>
</entry>

<entry>
    <title>Devel::Trepan Debugger command aliases and command completion</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-debugger-command-aliases-and-command-completion.html" />
    <id>tag:blogs.perl.org,2012:/users/rockyb//1443.3649</id>

    <published>2012-08-02T06:59:30Z</published>
    <updated>2012-09-01T10:22:43Z</updated>

    <summary>In my first blog I described why I wrote a new debugger for Perl and how the rewrite helps me add cool features more easily. Here I&apos;ll start to describe the cool features of this debugger. To my knowledge, all...</summary>
    <author>
        <name>rockyb</name>
        
    </author>
    
    <category term="debuggerdeveltrepan" label="debugger Devel::Trepan" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/rockyb/">
        <![CDATA[<p><a href="http://blogs.perl.org/users/rockyb/2012/07/on-writing-a-new-perl-debugger-part-1---why.html">In my first blog</a> I described why I wrote a new debugger for Perl and how the rewrite helps me add cool features more easily. Here I'll start to describe the cool features of this debugger. To my knowledge, all of the features described below are not in <em>perl5db</em>.</p>

<p>As mentioned in the last blog, this debugger follows <em>gdb</em> conventions. One implication then is that commands follow the <em>gdb</em> names and thus are no longer limited to one (or two) characters. But you may think well won't it be cumbersome typing in those extra characters? No, and for several reasons. First, the debugger has <em>command aliases</em>, which is a way to give a debugger command name an alias. And many of the aliases given by default are single letters. For example <code>T</code> is an alias for the <em>gdb</em> command <code>backtrace</code>. Of course, you are free to change or remove aliases. To see a list of aliases in effect type <code>alias</code></p>

<pre>
<u>(trepanpl)</u>: <strong>alias</strong>
<strong>List of alias names currently defined:</strong>
  $    T     cond      eval%     fin      n        p        s      u    
  %    a     cont      eval%?    kill!    n+       q        s+     where
  ?    b     disasm    eval?     l        n-       q!       s-   
  @    bt    e         eval@     l>       next+    quit!    step+
  R    c     eval$     eval@?    list>    next-    re.pl    step-
</pre>

<p>Notice how the list is nicely aligned in columns courtesy of the <a href="https://metacpan.org/module/Array::Columnize">Array::Columnize</a> module.</p>

<p>In addition to aliases, the debugger has command completion. So if you type "<code>ba</code>" and the tab key, the command name will fill out to "backtrace". If there is more than one completion for the prefix given then <em>all</em> of valid completions are listed. So for example of you just type <code>b</code> and the tab key you will see "backtrace" and "break". But entering "<code>b</code>" by itself will run the "break" command because "<code>b</code>" is an alias as seen in the above list. Command completion is very context sensitive. So entering <code>set</code> and completing that you get "set " with a space appended; then completing that you get:</p>

<pre>
<u>(trepanpl):</u> <strong>set</strong>
abbrev       basename     different    highlight    return      trace
auto         confirm      evaldisplay  max          timer       variable
</pre>

<p>And you can complete on each of those suboptions as well. Here's an example of a something context-sensitive <em>and</em> run-time sensitive. Suppose you enter <code>b 1</code> and then hit tab. You will get a list of all the valid breakpoint line numbers that begin with "1". (For example it is 10, 12 and 18 if you debug the <code>trepan.pl</code> program itself. </p>

<p>Another aspect of this debugger which you find in <em>gdb</em> but not so much in <em>perl5db</em> is its extensive on-line help. Following <em>gdb</em> there is help by category or by individual command. And you can enter a Perl regular expression and you will be given a list of commands that match that regular expression. Since, the debugger is written in Perl, adding a feature like this is pretty easy to do.</p>

<p>Possibly the first thing though that you may notice about this debugger is that by default it shows the Perl code marked up in color. Here is a screen shot of that. </p>

<p><img alt="Trepanpl-Highlight.png" src="http://blogs.perl.org/users/rockyb/src/ex/Trepanpl-Highlight.png" width="659" height="425" class="mt-image-none" style="" /></p>

<p>That's it for now. <a href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-debugger-evaluation-of-perl-statements.html">In the next blog</a> I'll discuss how some of the cool aspects of the <em>eval</em> command. See <a href="https://github.com/rocky/Perl-Devel-Trepan/wiki">github Devel::Trepan wiki</a> for more stuff or better yet, just go into the debugger and ask use the <em>help</em> command. </p>

<p><br />
</p>]]>
        
    </content>
</entry>

<entry>
    <title>On writing a new Perl Debugger (Part 1 - Why?)</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/rockyb/2012/07/on-writing-a-new-perl-debugger-part-1---why.html" />
    <id>tag:blogs.perl.org,2012:/users/rockyb//1443.3638</id>

    <published>2012-07-31T01:40:44Z</published>
    <updated>2012-08-18T01:53:19Z</updated>

    <summary>This is the first part of what will be several parts. The next part may be more interesting to a general audience: what are some of the cool new features of the debugger? But since I am assuming we are...</summary>
    <author>
        <name>rockyb</name>
        
    </author>
    
    <category term="debugger" label="debugger" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/rockyb/">
        <![CDATA[<p>This is the first part of what will be several parts. <a href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-debugger-command-aliases-and-command-completion.html">The next part </a> may be more interesting to a general audience: what are some of the cool new features of the debugger?  But since I am assuming we are all geeks here, I want to talk about some of the geeky aspects first. And be warned -- there are much more geeky things I'd like to talk about. This then constitutes then the more general and less involved geeky aspects...</p>

<h2>Why Write a new debugger?</h2>

<p>Not long ago, I wrote a <a href="https://metacpan.org/module/Devel::Trepan">Perl Debugger</a>.</p>

<p>I should say at the outset that I did this with a lot of trepidation. The Perl debugger that comes with Perl is venerable and has a long history. In fact, one of the 3 or 4 things that attracted me to Perl4 over the competition at the time &#8212; the Korn or Bourne Shell &#8212; was its debugger. And over the years various features have been added to the standard Perl debugger that make it very powerful. </p>

<p>And there have been a <a href="https://metacpan.org/module/Devel::ebug">couple</a> of <a href="http://perldoc.perl.org/DB.html">efforts</a> at extending or rewriting Perl debuggers. But it doesn't look to me that these are in widespread use. Perhaps mine won't be either. There is a lot of tradition, if not code and features, to overcome. </p>

<p><em><big>So why write a new debugger? </big></em></p>

<h3>Use the gdb command set. </h3>

<p>One small reason is non-standard one letter commands. I noticed this even back in the days of Perl4. At the time the debugger was written, the GNU debugger <em>gdb</em> was available. Although I can't say that the <em>gdb</em> command set is awe-inspiring, for someone simple-minded like myself I'd prefer to learn one command set well than learn several. If it were the case that over the years other debuggers had picked up and used Perl's debugger command set then I might feel differently today. But let's face it, the <em>gdb</em> command set is more popular.  And the Perl debugger command set is still somewhat unique.</p>

<p>I've written several debuggers for <a href="http://code.google.com/p/pydbgr/">Python</a>, <a href="https://github.com/rocky/rb-trepanning/wiki">Ruby</a>, and <a href="http://bashdb.sf.net">POSIX shell</a> . They all are modeled off of the <em>gdb </em>command set. In the case debuggers for Ruby and Python, even before I got to them, they were modeled off the <em>gdb</em> command set. Of course when I get involved in the debuggers such as say <a href="https://rubygems.org/gems/ruby-debug"><em>ruby-debug</em></a>, I would tend to make them more like the <em>gdb</em> command set. The knowledge one gets from learning one debugger well can then be translated to knowledge in a debugger for another language. </p>

<p>And here's a little funny story showing that it's not only good for people but it is also good for programs. In one of the debuggers I wrote, I thought I would extend this debugger front-end program called <a href="http://www.gnu.org/software/ddd/"><em>ddd</em></a>. There are all of these little customizations spread out over a dozen C++ files telling it how breakpoints are reported or how to issue a "step" command. Largely for these I could just say, "Do it like you do for gdb". But after I had got done with this and I fired up the debugger, I noticed that there were custom pop-up menus that got created for changing debugger settings. Things like how many lines to show in a backtrace or what argument list to use when restarting the debugger. I wondered: how did it figure out the setting names and data types of the settings? I didn't see this in code I had customized. Well, because I had kept not only the commands the same as <em>gdb</em> but also the <em>format</em> of the output, under the covers <em>ddd </em>had run a query command to get a list of all of the "set" commands and then parsed the output of that! Since the phrasing of the output was the style of  gdb's output, (e.g. "set <em>foo</em> -- Set ... is <em>bar</em>" it knew how to create corresponding custom pop up boxes, even to the point of knowing whether the value was boolean  	&#8212;  by seeing the words "on" or "off"  &#8212; or an integer or a string value. </p>

<h3>More modern Programming practices</h3>

<p><em>Have you ever tried adding a feature to <em>perl5db</em>? Was it fun? </em></p>

<p>I'd venture to say that programming methodology has changed over 25 years or so. At least I know my coding style has changed. But the current <em>perl5db</em> really reflects programming methodology of 25 years ago with only slight changes. I think some tests have been added fairly recently but they are tacked on after the fact. </p>

<p><em>perl5db</em> is basically one <em>huge</em> monolithic program (a little under 10,000 lines) in one file. Recently there are these things called "Modules" that I hear are nifty. <em>perl5db </em>does have a couple of <em>package</em> scopes in it. But not many. </p>

<p><em>Have you ever tried debugging the debugger? Was it fun? <br />
</em></p>

<p>Well to be fair to <em>perl5db</em>, if you were to try to debug the stock Python debugger it is about as bad. In my experience there always is a little bit of a challenge in writing a debugger that can debug itself. (It's easier if the debugger is in a different language than the language it debugs). But on the other hand, a debugger is just a  large program.  And if the program is modular, like anything else, it can be debugged and tested more easily. </p>

<p>In the rewrite, I have modularized things better. I have the ability to make use of other external modules. For example, I allow several different Data dumper modules. If you have one of the ReadLine modules, like <a href="http://search.cpan.org/~ilyaz/Term-ReadLine-Perl-1.0303/"><code>Term::ReadLine::Perl</code></a>, I can use that. </p>

<p>And I have tried to reduce the boilerplate for commands to make it easy for people to write their own commands.  Each debugger command is its own module which is basically a file in a directory. Various debugger extensions then just add themselves into to one of the debugger directories that containing Perl debugger commands. The extension to add a Perl code dissassembly, <a href="https://metacpan.org/module/Devel::Trepan::Disassemble">Devel::Trepan:::Disassemble </a> works like this.</p>

<p>I understand that writing a custom debugger command file may be a little too involved for many Perl programmers to undertake. So at a simpler level, there are command aliases. For example "<code>T</code>" is by default an alias to the <em>gdb</em> command "<code>backtrace</code>". And also since Perl makes a good macro language, there is a "macro" command that allows one to write a Perl anonymous subroutine to expand to debugger commands. </p>

<p>Another thing about each debugger command being its own module, is that it is easier debug and test each command in isolation. </p>

<h3>A Platform for Debugger Experiments</h3>

<p>This last aspect I guess is a little esoteric. As best as I can tell, there hasn't been much in the way of debugger research. In a <a href="http://blogs.perl.org/users/rockyb/2012/08/to-gdb-or-not-to-gdb.html">later blog</a>, I'll elaborate on this a little more. In fact, sadly, some of the  more modern programming languages and runtimes have tended to have <em>worse</em> debugging support. </p>

<p>The kludginess, lack of modularity, and aging style of <em>perl5db a</em> hasn't made it vehicle someone would want to experiment in. </p>

<p>In the <a href="http://blogs.perl.org/users/rockyb/2012/08/develtrepan-debugger-command-aliases-and-command-completion.html">next</a> <a href="http://blogs.perl.org/users/rockyb/2012/08/location-location-location.html">parts</a>, I'll give some of the features that this debugger has over <em>perl5db</em> and the other Perl5 debuggers. But I would like this rewrite to facilitate people expanding the horizons of what is possible in debugging. </p>]]>
        
    </content>
</entry>

</feed>
