Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: How can I get the current OP address (akin to PC)?

by Khen1950fx (Canon)
on Aug 18, 2012 at 18:30 UTC ( #988245=note: print w/replies, xml ) Need Help??

in reply to How can I get the current OP address (akin to PC)?

Maybe something like this:
#!/usr/bin/perl -l BEGIN { $| = 1; } use autodie; use common::sense; use Opcode; use Opcodes qw/ppaddr opdesc/; my $ppaddr = &Opcodes::ppaddr(0); print $ppaddr; my $opdesc = &Opcodes::opdesc(0); print $opdesc;

Replies are listed 'Best First'.
Re^2: How can I get the current OP address (akin to PC)?
by rockyb (Scribe) on Aug 18, 2012 at 23:27 UTC

    Thanks for the suggestion. I tried and it didn't work for me.

    Here is something that sort of works but doesn't really.

    In file /tmp/Devel/

    package DB; sub DB { ($pkg, $filename, $lineno) = caller; $COP = 0; local(*DB::dbline) = "::_<$DB::filename"; if (defined $DB::dbline[$lineno]) { $COP = 0 + $DB::dbline[$lineno] ; } }; 1;
    And to test it, put in file /tmp/
    #!/usr/bin/perl use B::Concise; sub testit () { my $walker = B::Concise::compile('-basic', '-src', 'testit'); B::Concise::set_style_standard('debug'); B::Concise::walk_output(\my $buf); $walker->(); # walks and renders into $buf; print $buf, "\n"; printf "COP is 0%x\n", $DB::COP; } testit();
    Now run as perl -I/tmp d:COP /tmp/

    The problem is that the COP address is always the first statement for the line. And what I really want is the one we are currently at which might not be the first COP of the line. Sigh.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988245]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2018-03-18 19:57 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.