diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | debug.c | 16 | ||||
-rw-r--r-- | test/ChangeLog | 6 | ||||
-rw-r--r-- | test/Makefile.am | 12 | ||||
-rw-r--r-- | test/Makefile.in | 12 | ||||
-rw-r--r-- | test/watchpoint1.awk | 14 | ||||
-rw-r--r-- | test/watchpoint1.in | 8 | ||||
-rw-r--r-- | test/watchpoint1.ok | 65 | ||||
-rw-r--r-- | test/watchpoint1.script | 14 |
10 files changed, 153 insertions, 4 deletions
@@ -1,3 +1,9 @@ +2015-11-24 Arnold D. Robbins <arnold@skeeve.com> + + * debug.c (debug_pre_execute): Fix to check watchpoints before + checking breakpoints. Gives more natural behavior for the user. + * NEWS: Document this. + 2015-10-28 Arnold D. Robbins <arnold@skeeve.com> * awkgram.y (nextc): Don't allow '\0' even if check_for_bad @@ -12,6 +12,10 @@ Changes from 4.1.3 to 4.1.x 2. z/OS support updated. +3. At the beginning of each statement, the debugger now checks and + reports watchpoints that have fired before checking for breakpoints. + This gives more natural behavior to the user. + Changes from 4.1.2 to 4.1.3 --------------------------- @@ -3653,8 +3653,20 @@ debug_pre_execute(INSTRUCTION **pi) assert(sourceline > 0); - if (check_breakpoint(pi) - || check_watchpoint() + /* + * 11/2015: This used to check breakpoints first, but that could + * produce strange behavior, where a watchpoint doesn't print until + * some time after the data changed. This reworks things so that + * watchpoints are checked first. It's a bit of a hack, but + * the behavior for the user is more logical. + */ + if (check_watchpoint()) { + next_command(); /* return to debugger interface */ + if (stop.command == D_return) + *pi = stop.pc; /* jump to this instruction */ + else if (cur_pc->opcode == Op_breakpoint) + cur_pc = cur_pc->nexti; /* skip past the breakpoint instruction */ + } else if (check_breakpoint(pi) || (stop.check_func && stop.check_func(pi))) { next_command(); /* return to debugger interface */ if (stop.command == D_return) diff --git a/test/ChangeLog b/test/ChangeLog index 83174b03..cc709b5c 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,9 @@ +2015-11-24 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (watchpoint1): New test. + * watchpoint1.awk, watchpoint1.in, watchpoint1.ok, + watchpoint1.script: New files. + 2015-10-28 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (nulinsrc): New test. diff --git a/test/Makefile.am b/test/Makefile.am index 97cf8d54..779a1063 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -987,6 +987,10 @@ EXTRA_DIST = \ uparrfs.awk \ uparrfs.in \ uparrfs.ok \ + watchpoint1.awk \ + watchpoint1.in \ + watchpoint1.ok \ + watchpoint1.script \ wideidx.awk \ wideidx.in \ wideidx.ok \ @@ -1084,7 +1088,8 @@ GAWK_EXT_TESTS = \ rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ - symtab7 symtab8 symtab9 + symtab7 symtab8 symtab9 \ + watchpoint1 EXTRA_TESTS = inftest regtest @@ -2101,6 +2106,11 @@ muldimposix:: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +watchpoint1: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -D -f $@.awk $@.in < $@.script >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + # Targets generated for other tests: include Maketests diff --git a/test/Makefile.in b/test/Makefile.in index 90b994c3..eb7748ab 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1244,6 +1244,10 @@ EXTRA_DIST = \ uparrfs.awk \ uparrfs.in \ uparrfs.ok \ + watchpoint1.awk \ + watchpoint1.in \ + watchpoint1.ok \ + watchpoint1.script \ wideidx.awk \ wideidx.in \ wideidx.ok \ @@ -1340,7 +1344,8 @@ GAWK_EXT_TESTS = \ rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ - symtab7 symtab8 symtab9 + symtab7 symtab8 symtab9 \ + watchpoint1 EXTRA_TESTS = inftest regtest INET_TESTS = inetdayu inetdayt inetechu inetecht @@ -2539,6 +2544,11 @@ muldimposix:: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --posix >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +watchpoint1: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -D -f $@.awk $@.in < $@.script >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ Gt-dummy: # file Maketests, generated from Makefile.am by the Gentests program addcomma: diff --git a/test/watchpoint1.awk b/test/watchpoint1.awk new file mode 100644 index 00000000..5e7e9416 --- /dev/null +++ b/test/watchpoint1.awk @@ -0,0 +1,14 @@ +#! /usr/bin/gawk -f +BEGIN { + c = 0 +} + +/apple/ { + nr = NR + c++ + # printf "[c, NR] = [%s, %s]\n", c, NR +} + +END { + print c +} diff --git a/test/watchpoint1.in b/test/watchpoint1.in new file mode 100644 index 00000000..83ac6f43 --- /dev/null +++ b/test/watchpoint1.in @@ -0,0 +1,8 @@ +1 1 pear +2 1 apple 4 +3 2 pear +4 3 apple 9 +5 8 pear +6 9 apple +7 10 pear +8 12 apple diff --git a/test/watchpoint1.ok b/test/watchpoint1.ok new file mode 100644 index 00000000..b1e7e53c --- /dev/null +++ b/test/watchpoint1.ok @@ -0,0 +1,65 @@ +1 #! /usr/bin/gawk -f +2 BEGIN { +3 c = 0 +4 } +5 +6 /apple/ { +7 nr = NR +8 c++ +9 # printf "[c, NR] = [%s, %s]\n", c, NR +10 } +11 +12 END { +13 print c +14 } +Watchpoint 1: c +1: c = untyped variable +2: nr = untyped variable +3: NR = 0 +Breakpoint 2 set at file `watchpoint1.awk', line 6 +Starting program: +Stopping in Rule ... +Watchpoint 1: c + Old value: untyped variable + New value: 0 +main() at `watchpoint1.awk':6 +6 /apple/ { +1: c = 0 +2: nr = untyped variable +3: NR = 1 +Breakpoint 2, main() at `watchpoint1.awk':6 +6 /apple/ { +1: c = 0 +2: nr = untyped variable +3: NR = 1 +Breakpoint 2, main() at `watchpoint1.awk':6 +6 /apple/ { +1: c = 0 +2: nr = untyped variable +3: NR = 2 +Watchpoint 1: c + Old value: 0 + New value: 1 +main() at `watchpoint1.awk':6 +6 /apple/ { +1: c = 1 +2: nr = 2 +3: NR = 3 +Breakpoint 2, main() at `watchpoint1.awk':6 +6 /apple/ { +1: c = 1 +2: nr = 2 +3: NR = 3 +Breakpoint 2, main() at `watchpoint1.awk':6 +6 /apple/ { +1: c = 1 +2: nr = 2 +3: NR = 4 +Watchpoint 1: c + Old value: 1 + New value: 2 +main() at `watchpoint1.awk':6 +6 /apple/ { +1: c = 2 +2: nr = 4 +3: NR = 5 diff --git a/test/watchpoint1.script b/test/watchpoint1.script new file mode 100644 index 00000000..94897d11 --- /dev/null +++ b/test/watchpoint1.script @@ -0,0 +1,14 @@ +list +watch c +display c +display nr +display NR +break 6 +run +continue +continue +continue +continue +continue +continue +quit |