develooper Front page | perl.debugger | Postings from September 2016

The memory for variables is not allocated for DB::DB reentrance

Thread Next
From:
KES
Date:
September 2, 2016 21:44
Subject:
The memory for variables is not allocated for DB::DB reentrance
Message ID:
122661472750364@web12j.yandex.ru
Hi, I am trying to write perl debugger which will allow to debug debugger commands. So I play with '$^D |=  (1<<30)' much.
This allows me to reenter DB::DB and do my staff.

Here is minified example which shows that memory for '$x' variable is not allocated again for DB::DB reentrance.

$ cat t3.pl
#!/usr/bin/env perl

sub t0 {}

1;



$ cat Devel/DB.pm
package DB;

use strict;
use warnings;

our $level =  0;

sub DB {
	my $x =  0;
	$x += $level;
	print ">LEVEL: $level; VALUE: $x", \$x,"\n";
	local $level =  $level +1;
	$^D |=  (1<<30)   if $level < 3;
	main::t0();
	print "<LEVEL: $level; VALUE: $x", \$x,"\n";
	return;
}

1;


$ perl -I. -d:DB t3.pl
>LEVEL: 0; VALUE: 0SCALAR(0x1ceb008)
>LEVEL: 1; VALUE: 1SCALAR(0x1ceb008)
>LEVEL: 2; VALUE: 2SCALAR(0x1ceb008)
<LEVEL: 3; VALUE: 2SCALAR(0x1ceb008)
Use of uninitialized value $x in concatenation (.) or string at Devel/DB.pm line 15.
<LEVEL: 2; VALUE: SCALAR(0x1ceb008)
Use of uninitialized value $x in concatenation (.) or string at Devel/DB.pm line 15.
<LEVEL: 1; VALUE: SCALAR(0x1ceb008)

Here we see that for each reentrance the address of $x pointer same place.

mst guess: that my weird reentrancy means the 'sub DB' pad stack isn't getting pushed to allocate a new pad

Is this a bug? 
May someone advice workaround for this until this will be fixed?
Thanks.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About