summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2023-12-24 12:12:21 +0200
committerArnold D. Robbins <arnold@skeeve.com>2023-12-24 12:12:21 +0200
commit8083ca907e3c427ae514a6b4ca91c7459d69ffdb (patch)
tree8b7eb06d40adbc2ed1bb803b97bbaad61fd57114
parentf48672bba12d1abde280ba7eafc0dbdba7a7680a (diff)
downloadgawk-8083ca907e3c427ae514a6b4ca91c7459d69ffdb.tar.gz
Fix yet another array printing bug in the debugger.
-rw-r--r--ChangeLog7
-rw-r--r--debug.c8
-rw-r--r--pc/ChangeLog4
-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/dbugarray3.awk18
-rw-r--r--test/dbugarray3.in3
-rw-r--r--test/dbugarray3.ok14
11 files changed, 85 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 1d7e0bf..9e83d05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-12-24 Arnold D. Robbins <arnold@skeeve.com>
+
+ * debug.c pr (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.
+
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 28211ab..aee27b4 100644
--- a/debug.c
+++ b/debug.c
@@ -1145,7 +1145,13 @@ print_array(volatile NODE *arr, char *arr_name)
subs = list[i];
r = *assoc_lookup((NODE *) arr, subs);
if (r->type == Node_var_array) {
- ret = print_array(r, r->vname);
+ // 12/2023: Use sub->stptr here, not r->vname, since
+ // a subarray could have been created via
+ // split() or some other mechanism where flags has NUMINT in it.
+ // In this case, r->vname can be NULL, so pass in the
+ // subscript itself. This should be fixed in the code that
+ // builds such arrays.
+ ret = print_array(r, subs->stptr);
} else {
print_array_names(names, cur_name, out_fp);
gprintf(out_fp, "[\"%.*s\"] = ", (int) subs->stlen, subs->stptr);
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 1f40112..199b5ad 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+2023-12-24 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.tst: Regenerated.
+
2023-12-21 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.tst: Regenerated.
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index bf99343..4245f4f 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
+ re_test typeof7 typeof8 dbugarray1 dbugarray2 dbugarray3
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
+ dbugarray1 dbugarray2 dbugarray3
# List of the tests which should be run with --lint option:
@@ -3660,6 +3660,11 @@ dbugarray2:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+dbugarray3:
+ @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 6ce1077..fd9a9e8 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +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.
+
2023-12-21 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (EXTRA_DIST): New test: dbugarray2.
diff --git a/test/Makefile.am b/test/Makefile.am
index ee59046..eccd1e0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -250,6 +250,9 @@ EXTRA_DIST = \
dbugarray2.awk \
dbugarray2.in \
dbugarray2.ok \
+ dbugarray3.awk \
+ dbugarray3.in \
+ dbugarray3.ok \
dbugeval.in \
dbugeval.ok \
dbugeval2.awk \
@@ -1580,7 +1583,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
+ re_test typeof7 typeof8 dbugarray1 dbugarray2 dbugarray3
ARRAYDEBUG_TESTS = arrdbg
@@ -1605,7 +1608,7 @@ SHLIB_TESTS = \
# List of the tests which should be run with --debug option:
NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3 dbugeval4 \
- dbugarray1 dbugarray2
+ dbugarray1 dbugarray2 dbugarray3
# List of the tests which should be run with --lint option:
NEED_LINT = \
diff --git a/test/Makefile.in b/test/Makefile.in
index 9e421a3..6315701 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -514,6 +514,9 @@ EXTRA_DIST = \
dbugarray2.awk \
dbugarray2.in \
dbugarray2.ok \
+ dbugarray3.awk \
+ dbugarray3.in \
+ dbugarray3.ok \
dbugeval.in \
dbugeval.ok \
dbugeval2.awk \
@@ -1844,7 +1847,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
+ re_test typeof7 typeof8 dbugarray1 dbugarray2 dbugarray3
ARRAYDEBUG_TESTS = arrdbg
EXTRA_TESTS = inftest regtest ignrcas3
@@ -1866,7 +1869,7 @@ SHLIB_TESTS = \
# List of the tests which should be run with --debug option:
NEED_DEBUG = dbugtypedre1 dbugtypedre2 dbugeval2 dbugeval3 dbugeval4 \
- dbugarray1 dbugarray2
+ dbugarray1 dbugarray2 dbugarray3
# List of the tests which should be run with --lint option:
@@ -5459,6 +5462,11 @@ dbugarray2:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+dbugarray3:
+ @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 73be058..98f6849 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -2339,6 +2339,11 @@ dbugarray2:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk --debug < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+dbugarray3:
+ @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/dbugarray3.awk b/test/dbugarray3.awk
new file mode 100644
index 0000000..c179c1f
--- /dev/null
+++ b/test/dbugarray3.awk
@@ -0,0 +1,18 @@
+function walk_array(arr, name, i)
+{
+ for (i in arr) {
+ if (isarray(arr[i]))
+ walk_array(arr[i], (name "[" i "]"))
+ else
+ printf("%s[%s] = %s\n", name, i, arr[i])
+ }
+}
+
+BEGIN {
+ $0 = "1 2 3"
+ split($0, a[0])
+ a[1][1]
+ split($0, a[1])
+
+ walk_array(a, "a")
+}
diff --git a/test/dbugarray3.in b/test/dbugarray3.in
new file mode 100644
index 0000000..5abbb9a
--- /dev/null
+++ b/test/dbugarray3.in
@@ -0,0 +1,3 @@
+r
+p @a
+quit
diff --git a/test/dbugarray3.ok b/test/dbugarray3.ok
new file mode 100644
index 0000000..b5ee4a9
--- /dev/null
+++ b/test/dbugarray3.ok
@@ -0,0 +1,14 @@
+Starting program:
+a[0][1] = 1
+a[0][2] = 2
+a[0][3] = 3
+a[1][1] = 1
+a[1][2] = 2
+a[1][3] = 3
+Program exited normally with exit value: 0
+a["0"]["1"] = "1"
+a["0"]["2"] = "2"
+a["0"]["3"] = "3"
+a["1"]["1"] = "1"
+a["1"]["2"] = "2"
+a["1"]["3"] = "3"