pdl2 中的分段错误,其中一些来自我的 .perldlrc 的代码可以直接从 pdl2 shell 正常工作
结合
是否有等效的pdl2(或 Devel::REPL)中的 perl 调试器“x”?
和
我已经创建了我的perldlrc,例如
use feature ':5.10';
use Data::Dumper;
use PadWalker qw/peek_our peek_my/;
sub x {
my $depth = shift||0;
$Data::Dumper::Maxdepth = $depth;
print Data::Dumper->Dump([@_])
}
sub lvars {
my $vars = in_scope_variables();
print Dumper [keys %$vars];
}
sub in_scope_variables {
my %in_scope = %{peek_our(1)};
my $lexical = peek_my(1);
for my $name (keys %main::) {
my $glob = $main::{$name};
if (defined ${$glob}) {
$in_scope{'$' . $name} = ${$glob};
}
if ( @{$glob}) {
$in_scope{'@' . $name} = [@{$glob}];
}
if (%{$glob}) {
$in_scope{'%' . $name} = {%{$glob}};
}
}
#lexicals hide package variables
while (my ($var, $ref) = each %$lexical) {
$in_scope{$var} = $ref;
}
return \%in_scope;
}
然后我启动pdl2但方法不起作用:
$ pdl2
pdl> $xx=in_scope_variables()
Runtime error: You can't FIRSTKEY with the %~ hash at (eval 254) line 38
pdl> lvars
Segmentation fault
如果我评论了循环
# for my $name (keys %main::) {
# [...]
# }
那么只有lvars失败:
pdl> $xx=in_scope_variables()
pdl> lvars
Segmentation fault
但是如果我运行直接在 pdl2 shell 中编写代码它可以工作
pdl> $xx=in_scope_variables()
pdl> x 1, $xx
$VAR1 = {
'$_REPL' => 'REF(0x19999708)'
};
pdl> print Dumper [keys %$xx];
$VAR1 = [
'$_REPL'
];
有人知道为什么会发生这两个错误吗?
这是 pdl2 问题、Devel::REPL 问题还是我做了一些愚蠢的事情?
我正在使用 perl 5.12 和 Perldl2 Shell v0.005
combining
Is there an equivalent to the perl debugger 'x' in pdl2 (or Devel::REPL)?
and
How can I list all variables that are in a given scope?
I have created my perldlrc like
use feature ':5.10';
use Data::Dumper;
use PadWalker qw/peek_our peek_my/;
sub x {
my $depth = shift||0;
$Data::Dumper::Maxdepth = $depth;
print Data::Dumper->Dump([@_])
}
sub lvars {
my $vars = in_scope_variables();
print Dumper [keys %$vars];
}
sub in_scope_variables {
my %in_scope = %{peek_our(1)};
my $lexical = peek_my(1);
for my $name (keys %main::) {
my $glob = $main::{$name};
if (defined ${$glob}) {
$in_scope{'
Then I start pdl2 but the methods do not work:
$ pdl2
pdl> $xx=in_scope_variables()
Runtime error: You can't FIRSTKEY with the %~ hash at (eval 254) line 38
pdl> lvars
Segmentation fault
If I commented the loop
# for my $name (keys %main::) {
# [...]
# }
Then only lvars fail:
pdl> $xx=in_scope_variables()
pdl> lvars
Segmentation fault
But if I run the code directly in the pdl2 shell it works
pdl> $xx=in_scope_variables()
pdl> x 1, $xx
$VAR1 = {
'$_REPL' => 'REF(0x19999708)'
};
pdl> print Dumper [keys %$xx];
$VAR1 = [
'$_REPL'
];
Do someone have any idea why this two errors happens?
Is that a pdl2 problem a Devel::REPL problem or me doing something stupid?
I am using perl 5.12 and Perldl2 Shell v0.005
. $name} = ${$glob};
}
if ( @{$glob}) {
$in_scope{'@' . $name} = [@{$glob}];
}
if (%{$glob}) {
$in_scope{'%' . $name} = {%{$glob}};
}
}
#lexicals hide package variables
while (my ($var, $ref) = each %$lexical) {
$in_scope{$var} = $ref;
}
return \%in_scope;
}
Then I start pdl2 but the methods do not work:
If I commented the loop
Then only lvars fail:
But if I run the code directly in the pdl2 shell it works
Do someone have any idea why this two errors happens?
Is that a pdl2 problem a Devel::REPL problem or me doing something stupid?
I am using perl 5.12 and Perldl2 Shell v0.005
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经更新了一年前的 PadWalker 版本,现在使用
PadWalker-1.92 工作正常。
不幸的是,我在更新之前没有写下我的版本,所以我无法报告哪个版本有问题。
捕获
%main::
变量时仍出现错误:运行时错误:您无法在 (eval 254) 第 38 行使用 %~ 哈希值进行 FIRSTKEY
I have updated my one year old PadWalker version and now with the
PadWalker-1.92 it works ok.
Unfortunately I didn't write down my version before updating, so I can not report with which version I had problems.
Still pending the error in the capture of the
%main::
variables:Runtime error: You can't FIRSTKEY with the %~ hash at (eval 254) line 38