Devel-Debug-DBGp

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


    - Actually use the XS implementation added in 0.13
    - Fix lvalue subroutines

0.13      2016-07-25 22:41:44 CEST

    - Add optional XS implementation for DB::sub, for speed
    - Return 'undef' type for undefined values (the value is still
      an empty string because DBGp does not have a special "null"
      value)
    - Blind fix for 32-bit Perls when not using PadWalker
    - use strict 'vars' and 'subs' in the debugger

0.12      2016-07-17 17:09:17 CEST

    - Reduce slowdown caused by enabling the debugger

0.11      2016-06-20 19:38:41 CEST

    - Another Xdebug compatibility option (for temporary breakpoints)
    - Don't crash when changing output redirection mode multiple times

Changes  view on Meta::CPAN

      'breakpoint_list', 'breakpoint_get' (see git log for full description)

0.10      2016-06-04 16:07:33 CEST

    - Perl 5.22 fixes

0.09      2016-06-04 10:14:56 CEST

    - Require perl 5.8
    - Use B instead of code parsing to implement context_get when
      PadWalker is not installed
    - Remove 'interact' command
    - Use 'open $fh, $mode, \$scalar' instead of IO::Scalar

0.08      2016-05-01 19:40:42 CEST

    - Speed up evaluation of complex evals from inside the debugger

0.07      2016-04-28 15:06:27 CEST

    - Fix check for unbreakable line

DB/DbgrContext.pm  view on Meta::CPAN

package DB::DbgrContext;

use strict qw(vars subs);

require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(
	     emitContextNames
	     emitContextProperties
	     getContextProperties
	     getProximityVarsViaPadWalker
	     hasPadWalker
	     GlobalVars
	     LocalVars
	     FunctionArguments
	     PunctuationVariables
	     );
our @EXPORT_OK = ();

use DB::DbgrCommon;
use DB::DbgrProperties;

DB/DbgrContext.pm  view on Meta::CPAN

        } elsif ($kind eq 'HASH') {
            return B::svref_2object($$vref)->RITER != -1;
        }
    } elsif ($sigil eq '@') {
        return _hasActiveArrayIterator(B::svref_2object($vref));
    } elsif ($sigil eq '%') {
        return B::svref_2object($vref)->RITER != -1;
    }
}

sub getProximityVarsViaPadWalker($$$$) {
    my ($pkg, $filename, $line, $stackDepth) = @_;
    $stackDepth += 2; # Because we're two levels above the user code here.
    my $my_var_hash = PadWalker::peek_my($stackDepth);
    my $our_var_hash = PadWalker::peek_our($stackDepth);
    my %merged_vars = (%$my_var_hash, %$our_var_hash);
    our @dbline;
    local *dbline = $main::{'_<' . $filename};
    my $sourceText = join("\n", @dbline);

    my @results = ();
    while(my($k, $v) = each %merged_vars) {
	my $sigil = substr($k, 0, 1);
	if (!_hasActiveIterator($sigil, $v)) {
	    push(@results, [$k, $sigil eq '$' ? $$v : $v, 0]);

DB/DbgrContext.pm  view on Meta::CPAN

}

{
    # needs to be defined in package DB, otherwise eval "" sees a package
    # which is not "DB" and uses it to get the lexical context
    package DB;

    sub getProximityVarsViaB($$$$) {
	package DB::DbgrContext;
	my ($pkg, $filename, $line, $stackDepth) = @_;
	# there is no accurate way of getting these without PadWalker, and
	# there is not way to get the values without PadWalker anyway
	return [] if $stackDepth != 0;
	require B;
	undef *lex_var_hook;
	my $b_cv = eval "sub DB::lex_var_hook {};
			 B::svref_2object(\\&DB::lex_var_hook)->OUTSIDE->OUTSIDE";
	my ($evaltext, %vars, @vars) = ('');
	for ( ; $b_cv && !$b_cv->isa('B::SPECIAL'); $b_cv = $b_cv->OUTSIDE) {
	    my $pad = $b_cv->PADLIST->ARRAYelt(0);
	    for my $i (1 .. ($] < 5.022 ? $pad->FILL : $pad->MAX)) {
		my $v = $pad->ARRAYelt($i);

DB/DbgrContext.pm  view on Meta::CPAN

	    } elsif ($ldebug) {
		dblog("Skipping $vars[$i] because it has an active iterator");
	    }
	}
	return \@results;
    }
}

# -1: unknown, 0: no, 1:yes  #### Do not init as 1, only -1 or 0.
# bug 93570 - allow padwalker detection/use to be disabled
my $havePadWalker = $ENV{DBGP_PERL_IGNORE_PADWALKER} ? 0 : -1;

sub hasPadWalker {
    if ($havePadWalker == -1) {
        local $@;
        eval {
            require PadWalker;
            PadWalker->VERSION(0.08);
            $havePadWalker = 1;
        };
        if ($@) {
            $havePadWalker = 0;
        }
    }
    return $havePadWalker;
}

1;

Devel/Debug/DBGp.pm  view on Meta::CPAN

=head2 DBGP_COOKIE

If set, it is returned as the C<session> attribute of the C<init> message.

=head2 HOST_HTTP

If set, overrides the value of the C<hostname> attribute in the C<init> message.

=head2 DBGP_PERL_IGNORE_PADWALKER

If set to a true value, does not use L<PadWalker> to get the list of
local variables, but uses a combination of L<B> and C<eval STRING>.

=head2 DBGP_PURE_PERL, DBGP_XS_ONLY

The default is to try to load an XS helper for the debugger, and fall
back to the pure-Perl implementation if loading the XS helper fails
(or the helper has not been built). Setting C<DBGP_PURE_PERL> or
C<DBGP_XS_ONLY> allows to explicitly choose one or the other.

=head1 FUNCTIONS

perl5db.pl  view on Meta::CPAN


			# dblog("caller => [@unused]");
			# dblog("stack depth [$stackDepth]: curr args are [", join(", ", @args), "]") if $ldebug;
			$namesAndValues = [];
			for (my $j = 0; $j < @savedArgs; $j++) {
			    push @$namesAndValues, [sprintf('$_[%d]', $j), $savedArgs[$j], 0];
			}
		    }
		} elsif ($context_id == LocalVars) {
		    $namesAndValues = eval {
                        hasPadWalker() ?
                            getProximityVarsViaPadWalker($pkg, $currentFilename, $currentLine, $stackDepth) :
                            getProximityVarsViaB($pkg, $currentFilename, $currentLine, $stackDepth);
                    };
		} else {
		    $namesAndValues = eval { getContextProperties($context_id, $pkg); };
		}
		if ($@) {
		    my ($code, $error) = ($@ =~ /code:(.*):error<:<(.*?)>:>/);
		    if (!$code) {
			$code = DBP_E_ParseError;
			$error = _trimExceptionInfo($@);

t/142_context_get_padwalker.t  view on Meta::CPAN

#!/usr/bin/perl

use if !eval { require PadWalker; 1 }, 'Test::More' =>
    skip_all => 'PadWalker not installed';
use t::lib::Test;

$ENV{DBGP_PERL_IGNORE_PADWALKER} = 0;

run_debugger($] < 5.012 ? 't/scripts/variables_complex_510.pl' : 't/scripts/variables_complex.pl');

send_command('run');

command_is(['context_get'], {
    command => 'context_get',



( run in 1.061 second using v1.01-cache-2.11-cpan-05444aca049 )