Permalink
Browse files

Add breakpoint setting in code with "#?BREAK".

  • Loading branch information...
1 parent 342266a commit 31763150227b59d2e88a7e572158817be967c86c @jnthn committed Jun 6, 2013
Showing with 16 additions and 0 deletions.
  1. +12 −0 bin/perl6-debug.nqp
  2. +4 −0 lib/Debugger/UI/CommandLine.pm
View
@@ -415,6 +415,18 @@ class Perl6::HookGrammar is Perl6::Grammar {
Perl6::Grammar.HOW.find_method(Perl6::Grammar, 'semilist')(self)
}
}
+
+ method comment:sym<#>() {
+ my $c := Perl6::Grammar.HOW.find_method(Perl6::Grammar, 'comment:sym<#>')(self);
+ my $comment := $c.MATCH.Str;
+ if $comment ~~ /'#?BREAK'/ {
+ if $*DEBUG_HOOKS.has_hook('new_breakpoint') {
+ my $file := pir::find_caller_lex__Ps('$?FILES') // '<unknown>';
+ $*DEBUG_HOOKS.get_hook('new_breakpoint')($file, $c.MATCH().from());
+ }
+ }
+ $c
+ }
}
sub hll-config($config) {
@@ -647,6 +647,10 @@ $*DEBUG_HOOKS.set_hook('regex_atom', -> $filename, $ctx, $from, $to {
$*DEBUG_HOOKS.set_hook('reset', -> {
DebugState.reset();
});
+$*DEBUG_HOOKS.set_hook('new_breakpoint', -> $filename, $pos {
+ DebugState.add_breakpoint($filename,
+ %sources{$filename}.line_of($pos, -1, -1)[0] + 2);
+});
# Allow interception of throwing an exception.
my $IN_UNHANDLED = 0;

0 comments on commit 3176315

Please sign in to comment.