Permalink
Browse files

Reset debugger state between runs.

This makes things better for multiple debug runs in the REPL.
  • Loading branch information...
1 parent cc1d58c commit 8bb85f6afa6030312ebc4c6312855c3029e8a5a9 @jnthn committed Oct 13, 2012
Showing with 25 additions and 1 deletion.
  1. +10 −1 bin/perl6-debug.nqp
  2. +15 −0 lib/Debugger/UI/CommandLine.pm
View
@@ -404,6 +404,15 @@ sub hll-config($config) {
$config<build-date> := '2012-08-05T16:57:45Z';
}
+class Perl6::Debugger is Perl6::Compiler {
+ method eval(*@pos, *%named) {
+ if $*DEBUG_HOOKS.has_hook('reset') {
+ $*DEBUG_HOOKS.get_hook('reset')();
+ }
+ nqp::findmethod(Perl6::Compiler, 'eval')(self, |@pos, |%named)
+ }
+}
+
sub MAIN(@ARGS) {
# Initialize dynops.
pir::rakudo_dynop_setup__v();
@@ -412,7 +421,7 @@ sub MAIN(@ARGS) {
pir::getinterp__P().recursion_limit(100000);
# Create and configure compiler object.
- my $comp := Perl6::Compiler.new();
+ my $comp := Perl6::Debugger.new();
$comp.language('perl6');
$comp.parsegrammar(Perl6::HookGrammar);
$comp.parseactions(Perl6::HookActions);
@@ -593,6 +593,18 @@ my class DebugState {
'q[uit] exit the debugger'
;
}
+
+ method reset() {
+ $run_mode = Step;
+ $dying = False;
+ $in_prompt = False;
+ $cur_ex = Mu;
+ %stepping_out_of = ();
+ %stepping_over_in = ();
+ %breakpoints = ();
+ %tracepoints = ();
+ @tp_log = ();
+ }
}
# Install various hooks.
@@ -629,6 +641,9 @@ $*DEBUG_HOOKS.set_hook('regex_atom', -> $filename, $ctx, $from, $to {
DebugState.issue_prompt($ctx, $filename, $from, $to);
}
});
+$*DEBUG_HOOKS.set_hook('reset', -> {
+ DebugState.reset();
+});
# Allow interception of throwing an exception.
my $IN_UNHANDLED = 0;

0 comments on commit 8bb85f6

Please sign in to comment.