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 | 14 | ||||
-rw-r--r-- | test/Makefile.in | 19 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-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 |
11 files changed, 165 insertions, 6 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 @@ -74,6 +74,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 --------------------------- @@ -3658,8 +3658,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 c3f6c218..7ecd2716 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 090ad0ea..e573f5e1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1031,6 +1031,10 @@ EXTRA_DIST = \ uparrfs.awk \ uparrfs.in \ uparrfs.ok \ + watchpoint1.awk \ + watchpoint1.in \ + watchpoint1.ok \ + watchpoint1.script \ wideidx.awk \ wideidx.in \ wideidx.ok \ @@ -1133,8 +1137,9 @@ GAWK_EXT_TESTS = \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ symtab7 symtab8 symtab9 \ - typedregex1 typedregex2 typedregex3 typeof1 typeof2 typeof3 typeof4 - timeout + typedregex1 typedregex2 typedregex3 typeof1 typeof2 typeof3 typeof4 \ + timeout \ + watchpoint1 EXTRA_TESTS = inftest regtest @@ -2186,6 +2191,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 a00f887c..9771921c 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1288,6 +1288,10 @@ EXTRA_DIST = \ uparrfs.awk \ uparrfs.in \ uparrfs.ok \ + watchpoint1.awk \ + watchpoint1.in \ + watchpoint1.ok \ + watchpoint1.script \ wideidx.awk \ wideidx.in \ wideidx.ok \ @@ -1389,7 +1393,9 @@ GAWK_EXT_TESTS = \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ symtab7 symtab8 symtab9 \ - typedregex1 typedregex2 typedregex3 typeof1 typeof2 typeof3 typeof4 + typedregex1 typedregex2 typedregex3 typeof1 typeof2 typeof3 typeof4 \ + timeout \ + watchpoint1 EXTRA_TESTS = inftest regtest INET_TESTS = inetdayu inetdayt inetechu inetecht @@ -1633,7 +1639,6 @@ uninstall-am: .PRECIOUS: Makefile - timeout # Message stuff is to make it a little easier to follow. # Make the pass-fail last and dependent on others to avoid @@ -2623,6 +2628,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: @@ -4007,6 +4017,11 @@ typeof4: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +timeout: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + double1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 5b4f3d43..689dcdc9 100644 --- a/test/Maketests +++ b/test/Maketests @@ -1382,6 +1382,11 @@ typeof4: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +timeout: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + double1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ 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 |