Devel::Trepan 0.70 has just been released. In it, the deparse command will use the current location to deparse. This does handle multiple statements on a single line, inside a subroutine. (I haven't been able to figure out how to get this to work in the main program.)

Just to get this done, I needed to monkeypatch B::Deparse and add some other routines that probably should in another package somewhere.

In order to be able to figure out the exact location in a callsite, e.g.

fib($x-1) + fib($x-2)
addresses in showing the call stack and are recorded in the stack in the 0.70 release. I beefed up Devel::Trepan::Disassemble and made a release of that too. The basic idea here is you disassemble the surrounding context to reconstruct the fragment of code. (The call location is marked with an arrow automatically if that is found.)

Better though would be more changes to B::Deparse so that you can pass it an opcode location and it deparse around that. Also, I'd like to see more COP instructions added say found for loops of the 3-part kind: initialize, test and increment.

As with other science and engineering, the more you do, the more you realize there is to do. I may beef up B::CodeLines so that it notes which lines have multiple statements in them.

Finally, I observe that providing really good debugging support, not just in Perl but other languages as well, is often really hard and strays way outside of the "debugger" proper. I think that's one reason you don't find things like this often in debuggers.


In reply to Re^3: RFC: Location via B::Deparse by rockyb
in thread RFC: Location via B::Deparse by rockyb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.