YES! That works for me.
There is still one wafer-thin problem...
When I use this in an array context, I am getting the function name (and possibly other further parameters) one level above what the package, file, and line number are. I can code around this, but I also wonder if this is a bug or not. Here is a run using Perl 5.18.1:
./bin/trepan.pl example/gcd.pl 3 5
-- main::(example/gcd.pl:18)
die sprintf "Need two integer arguments, got %d", scalar(@ARGV) unless
@ARGV == 2;
$DB::D[0] = 0
(trepanpl): @ caller
$DB::D1 =
@{[
[0] "main",
1 "example/gcd.pl",
2 18,
3 "DB::DB", <---- WRONG!
4 "",
5 1,
6 undef,
7 undef,
8 2018,
9 "UUUUUUUUUUUUUUUU",
10 undef
]}
(trepanpl): @ caller 1
$DB::D2 =
@{<undef>}
(trepanpl): c gcd
-> main::(example/gcd.pl:8)
{
my ($a, $b) = @_;
trepanpl: s # there is a "feature" here in my program where I need to step one more
x1 main::(example/gcd.pl:9)
my ($a, $b) = @_;
(trepanpl): @ caller
$DB::D2 =
@{[
[0] "main",
1 "example/gcd.pl",
2 9,
3 "DB::DB", <--- still wrong
4 "",
5 1,
6 undef,
7 undef,
8 1762,
9 "UUUUUUUUUUUUUUUU",
10 undef
]}
(trepanpl): @ caller 1
$DB::D3 =
@{[
[0] "main",
1 "example/gcd.pl",
2 21,
3 "main::gcd",
4 1,
5 1,
6 undef,
7 undef,
8 2018,
9 "UUUUUUUUUUUUUUUU",
10 undef
]}
(trepanpl): @ caller 2
$DB::D4 =
@{<undef>}
(trepanpl): q
Really quit? (N/y) y
trepan.pl: That's all, folks...
If you want to try the code yourself, see the github Devel::Trepan repo with a commit after 0babe47e08831a9d5b1099a9971fc2677f604331
In reply to Re^4: How/can one do save/restore CORE::caller inside an eval?
by rockyb
in thread How/can one do save/restore CORE::caller inside an eval?
by rockyb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |