aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorPiotr Rudnicki <piotr.rudnicki@intel.com>2025-04-09 15:17:31 +0200
committerPiotr Rudnicki <piotr.rudnicki@intel.com>2025-04-14 11:42:54 +0200
commite25c84752c9df2bf3a999b53afb58e5bebaf3b7c (patch)
tree6182c394db62656f90e24b7c915b85163500ab85 /gdb/testsuite
parent29b68e449be8816505487ef7cd5abde72ed21ca4 (diff)
downloadbinutils-e25c84752c9df2bf3a999b53afb58e5bebaf3b7c.zip
binutils-e25c84752c9df2bf3a999b53afb58e5bebaf3b7c.tar.gz
binutils-e25c84752c9df2bf3a999b53afb58e5bebaf3b7c.tar.bz2
gdb: add check for empty array
With the command before the change, gdb crashes with message: (gdb) p 1 == { } Fatal signal: Segmentation fault After the fix in this commit, gdb shows following message: (gdb) p 1 == { } size of the array element must not be zero Add new test cases to file gdb.base/printcmds.exp to test this change Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.base/printcmds.exp7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index e1c996e..8634668 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -744,6 +744,12 @@ proc test_print_char_arrays {} {
gdb_test_no_output "set print address off" "address off char arrays"
}
+proc test_print_arrays_negative {} {
+ # Check whether correct error messages are printed
+ gdb_test "p 1 == { }" "size of the array element must not be zero"
+ gdb_test "p 1 == { 1, 'a' }" "array elements must all be the same size"
+}
+
proc test_print_nibbles {} {
gdb_test_no_output "set print nibbles on"
foreach lang_line {
@@ -1235,6 +1241,7 @@ test_print_int_arrays
test_print_typedef_arrays
test_artificial_arrays
test_print_char_arrays
+test_print_arrays_negative
test_print_nibbles
# We used to do the runto main here.
test_print_string_constants