summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2023-12-24 17:41:07 +0200
committerArnold D. Robbins <arnold@skeeve.com>2023-12-24 17:41:07 +0200
commit4217d4bd8600d49335d8a1d2922d5a1ee1921d7c (patch)
tree4a6952a0e20b283ad8dc50278281d4cfb95222cf
parent8083ca907e3c427ae514a6b4ca91c7459d69ffdb (diff)
downloadgawk-4217d4bd8600d49335d8a1d2922d5a1ee1921d7c.tar.gz
Fix core dump on debugger watchpoints.
-rw-r--r--ChangeLog8
-rw-r--r--debug.c4
-rw-r--r--pc/Makefile.tst9
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am7
-rw-r--r--test/Makefile.in12
-rw-r--r--test/Maketests5
-rw-r--r--test/dbugarray4.awk4
-rw-r--r--test/dbugarray4.in7
-rw-r--r--test/dbugarray4.ok23
10 files changed, 75 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e83d05..ab3e2fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,16 @@
2023-12-24 Arnold D. Robbins <arnold@skeeve.com>
- * debug.c pr (print_array): Use the subscript as the
+ * debug.c (print_array): Use the subscript as the
subarray name instead of the `vname' field. This field
is not there for arrays created with NUMINT subscripts.
Thanks again to Hermann Peifer for the report.
+ Unrelated:
+
+ * debug.c (find_subscript): Fail early on Node_var_new
+ and Node_elem_new. Thanks yet again to Hermann Peifer
+ for the report.
+
2023-12-21 Arnold D. Robbins <arnold@skeeve.com>
Fix multidimensional array printing in the debugger, again.
diff --git a/debug.c b/debug.c
index aee27b4..fc53d4e 100644
--- a/debug.c
+++ b/debug.c
@@ -1682,6 +1682,10 @@ find_subscript(struct list_item *item, NODE **ptr)
NODE *sub, *r;
int i = 0, count = item->num_subs;
+ // without this check, in_array() will SEGV...
+ if (symbol->type == Node_var_new || symbol->type == Node_elem_new)
+ return -1;
+
r = *ptr = NULL;
for (i = 0; i < count; i++) {
sub = item->subs[i];
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index 4245f4f..daf3c56 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -222,7 +222,7 @@ GAWK_EXT_TESTS = \
symtab11 symtab12 timeout typedregex1 typedregex2 typedregex3 \
typedregex4 typedregex5 typedregex6 typeof1 typeof2 typeof3 \
typeof4 typeof5 typeof6 unicode1 watchpoint1 \
- re_test typeof7 typeof8 dbugarray1 dbugarray2 dbugarray3
+ re_test typeof7 typeof8 dbugarray1 dbugarray2 dbugarray3 dbugarray4
ARRAYDEBUG_TESTS = arrdbg
EXTRA_TESTS = inftest regtest ignrcas3
@@ -244,7 +244,7 @@ SHLIB_TESTS = \
# List of the tests which should be run with --debug option:
NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3 dbugeval4 \
- dbugarray1 dbugarray2 dbugarray3
+ dbugarray1 dbugarray2 dbugarray3 dbugarray4
# List of the tests which should be run with --lint option:
@@ -3665,6 +3665,11 @@ dbugarray3:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+dbugarray4:
+ @echo $@
+ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
double1:
@echo $@ $(ZOS_FAIL)
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/ChangeLog b/test/ChangeLog
index fd9a9e8..b955dcd 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,7 +1,8 @@
2023-12-24 Arnold D. Robbins <arnold@skeeve.com>
- * Makefile.am (EXTRA_DIST): New test: dbugarray3.
- * dbugarray3.awk, dbugarray3.in, dbugarray3.ok: New files.
+ * Makefile.am (EXTRA_DIST): New tests: dbugarray3, dbugarray4.
+ * dbugarray3.awk, dbugarray3.in, dbugarray3.ok,
+ dbugarray4.awk, dbugarray4.in, dbugarray4.ok: New files.
2023-12-21 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/test/Makefile.am b/test/Makefile.am
index eccd1e0..a876b3a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -253,6 +253,9 @@ EXTRA_DIST = \
dbugarray3.awk \
dbugarray3.in \
dbugarray3.ok \
+ dbugarray4.awk \
+ dbugarray4.in \
+ dbugarray4.ok \
dbugeval.in \
dbugeval.ok \
dbugeval2.awk \
@@ -1583,7 +1586,7 @@ GAWK_EXT_TESTS = \
symtab11 symtab12 timeout typedregex1 typedregex2 typedregex3 \
typedregex4 typedregex5 typedregex6 typeof1 typeof2 typeof3 \
typeof4 typeof5 typeof6 unicode1 watchpoint1 \
- re_test typeof7 typeof8 dbugarray1 dbugarray2 dbugarray3
+ re_test typeof7 typeof8 dbugarray1 dbugarray2 dbugarray3 dbugarray4
ARRAYDEBUG_TESTS = arrdbg
@@ -1608,7 +1611,7 @@ SHLIB_TESTS = \
# List of the tests which should be run with --debug option:
NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3 dbugeval4 \
- dbugarray1 dbugarray2 dbugarray3
+ dbugarray1 dbugarray2 dbugarray3 dbugarray4
# List of the tests which should be run with --lint option:
NEED_LINT = \
diff --git a/test/Makefile.in b/test/Makefile.in
index 6315701..1ef143f 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -517,6 +517,9 @@ EXTRA_DIST = \
dbugarray3.awk \
dbugarray3.in \
dbugarray3.ok \
+ dbugarray4.awk \
+ dbugarray4.in \
+ dbugarray4.ok \
dbugeval.in \
dbugeval.ok \
dbugeval2.awk \
@@ -1847,7 +1850,7 @@ GAWK_EXT_TESTS = \
symtab11 symtab12 timeout typedregex1 typedregex2 typedregex3 \
typedregex4 typedregex5 typedregex6 typeof1 typeof2 typeof3 \
typeof4 typeof5 typeof6 unicode1 watchpoint1 \
- re_test typeof7 typeof8 dbugarray1 dbugarray2 dbugarray3
+ re_test typeof7 typeof8 dbugarray1 dbugarray2 dbugarray3 dbugarray4
ARRAYDEBUG_TESTS = arrdbg
EXTRA_TESTS = inftest regtest ignrcas3
@@ -1869,7 +1872,7 @@ SHLIB_TESTS = \
# List of the tests which should be run with --debug option:
NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3 dbugeval4 \
- dbugarray1 dbugarray2 dbugarray3
+ dbugarray1 dbugarray2 dbugarray3 dbugarray4
# List of the tests which should be run with --lint option:
@@ -5467,6 +5470,11 @@ dbugarray3:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+dbugarray4:
+ @echo $@
+ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
double1:
@echo $@ $(ZOS_FAIL)
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 98f6849..bac220f 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -2344,6 +2344,11 @@ dbugarray3:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+dbugarray4:
+ @echo $@
+ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
double1:
@echo $@ $(ZOS_FAIL)
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/dbugarray4.awk b/test/dbugarray4.awk
new file mode 100644
index 0000000..632ecb6
--- /dev/null
+++ b/test/dbugarray4.awk
@@ -0,0 +1,4 @@
+BEGIN {
+ a[1][1] = 1
+ a[1][2] = 2
+}
diff --git a/test/dbugarray4.in b/test/dbugarray4.in
new file mode 100644
index 0000000..8e85497
--- /dev/null
+++ b/test/dbugarray4.in
@@ -0,0 +1,7 @@
+r
+watch a[1]
+r
+cont
+cont
+cont
+q
diff --git a/test/dbugarray4.ok b/test/dbugarray4.ok
new file mode 100644
index 0000000..27217f4
--- /dev/null
+++ b/test/dbugarray4.ok
@@ -0,0 +1,23 @@
+Starting program:
+Program exited normally with exit value: 0
+Watchpoint 1: a["1"]
+error: attempt to use scalar value as array
+Restarting ...
+Starting program:
+Stopping in BEGIN ...
+Watchpoint 1: a["1"]
+ Old value: element not in array
+ New value: array, 0 elements
+main() at `dbugarray4.awk':2
+2 a[1][1] = 1
+Watchpoint 1: a["1"]
+ Old value: array, 0 elements
+ New value: array, 1 elements
+main() at `dbugarray4.awk':2
+2 a[1][1] = 1
+Watchpoint 1: a["1"]
+ Old value: array, 1 elements
+ New value: array, 2 elements
+main() at `dbugarray4.awk':3
+3 a[1][2] = 2
+Program exited normally with exit value: 0