Devel-DebugHooks
view release on metacpan or search on metacpan
lib/Devel/DebugHooks.pm view on Meta::CPAN
Why the DB::DB is called twice for:
print "@{[ (caller(0))[0..2] ]}\n";
but only one for this:
print sb();
A: It is called once for caller(0) and second for whole line.
It is called once for each statement at line, maybe.
+
use should have args. and the caller called from DB:: namespace should set @DB::args
at compile time 'caller' also does not fill @DB::args
BEGIN {
print caller, @DB::args
}
A: Try, to ensure the DB::args used after the call ot caller
BEGIN {
@caller = caller
print @caller, @DB::args
}
How 'the first non-DB piece of code' is calculated for the 'eval'?
#BUG? I can ${ '!@#$' } = 3, but can not my ${ '!@#$' }
BUG?
The localization of $DB::single works fine, but the reference to it does not work:
{
$DB::single = 7; my $x = \$DB::single;
print "Before: ". \$DB::single ." <<$x $$x\n";
local $DB::single = 0;
print "After: ". \$DB::single ." <<$x $$x\n";
}
The output:
Before: SCALAR(0x10f8310) <<SCALAR(0x10f8310) 7
After: SCALAR(0x110cbc8) <<SCALAR(0x10f8310) 0
Where as works fine:
{
$DB::z = 7; my $x = \$DB::z;
print "Before: ". \$DB::z ." <<$x $$x\n";
local $DB::z = 0;
print "After: ". \$DB::z ." <<$x $$x\n";
}
The output:
Before: SCALAR(0x134d398) <<SCALAR(0x134d398) 7
After: SCALAR(0x1239bc8) <<SCALAR(0x134d398) 7
We see that in *first* example the new variable is created: The new address of $DB::single is SCALAR(0x110cbc8)
but when assigning to $DB::single the value by old reference (SCALAR(0x10f8310) changed too.
In *second* example we see that addressing works in same manner, but value 7 is preserved as expected.
Why the value of $DB::single is not preserved?
# my $y = \$DB::single;
# # Can not use weaken. See error at 'reports/readline' file
# use Scalar::Util 'weaken';
# weaken $y;
# Because of $DB::single magic we can not access to old value by reference
# The localization is broken if we save a reference to $DB::single
# {
# my $x = $DB::single;
# print "Before: ". \$DB::single ." <<$DB::single $x >$y $$y\n"; # $$x == 0
# local $DB::single = $DB::single +1;
# print "After: ". \$DB::single ." <<$DB::single $x >$y $$y\n"; # $$x == 1, not 0
# }
# print "OUT: ". \$DB::single ." <<$DB::single - $x - $$x >$y\n";
# {
# print "BEFORE: $DB::single\n";
# local $DB::single = 7;
# print "AFTER $DB::single\n";
# }
# print "OUT $DB::single\n";
# BUG: The perl goes tracing if you uncomment this
# { local $DB::trace = 1; }
# # But it shows us the value 0 but internally it is 1
# die $DB::trace if $DB::trace != 0;
sub sub {
...
# BUG: without +0 the localized value is broken
local $DB::single = ($DB::single & 2) ? 0 : $DB::single+0;
Breakpoint does not work for this when hash key is initialized
b x64: my $hash = $c->stash->{'mojo.content'} ||= {};
#TODO: $X=(condition)
The debugger do not single step into sub called from string
Notice strange file:line
POP FRAME <<<< l:0 b:0:0 e:1 s:1 t:1 -- Apache::DB::handler@1
/home/kes/perl_lib/lib/perl5/x86_64-linux-gnu-thread-multi/Apache/DB.pm:77 }
else {
if (ref $r) {
$SIG{INT} = \&DB::catch;
$r->register_cleanup(sub {
$SIG{INT} = \&DB::ApacheSIGINT();
});
}
}
print "HERE: " .$DB::single; #line 77
DB::state( 'trace', 1 );
$DB::single = 1;
print "HERE: A" .$DB::single;
print "DONE\n";
( run in 3.061 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )