- Patches added: * avoid-crash-with-length.patch * correct-bounds-check-when-working-around-gas-dwarf-5.patch * fix-crash-in-f-typeprint.c.patch - Patches added (swo#33560, bsc#1251213): * bfd-elf-handle-prstatus-of-156-bytes-in-elf32_arm_na.patch * gdb-corefiles-fix-segfault-in-add_thread_silent.patch - Patches added (swo#32542, swo#33354): * change-return-value-of-_bfd_mmap_temporary.patch - Patches added (swo#33068, swo#33069): * gdb-fix-handling-of-aborted-inferior-call.patch - Patches added (swo#33620): * gdb-rust-fix-handling-of-unsigned-discriminant.patch - Patches added (swo#33444): * have-gdb.threadexitedevent-inherit-from-gdb.threadev.patch - Patches added (swo#33617): * mark-pascal-as-case-insensitive.patch - Patches added (testsuite): * check-gnatmake-version-in-gnat_version_compare.patch * gdb-testsuite-fix-build-id-check-in-gdb.python-py-mi.patch * gdb-testsuite-fix-gdb.mi-mi-sym-info.exp.patch * gdb-testsuite-fix-gdb.rust-methods.exp-on-i686-linux.patch * gdb-testsuite-fix-main-in-gdb.trace-mi-trace-frame-c.patch * gdb-testsuite-fix-possible-tcl-errors-in-gdb.threads.patch * gdb-testsuite-fix-sizeof-test-in-gdb.rust-simple.exp.patch * gdb-testsuite-fix-xfail-in-gdb.ada-array_of_variant..patch * gdb-testsuite-fix-xfail-in-gdb.ada-variant_record_fi.patch * gdb-testsuite-force-dwarf-in-gdb.pascal.patch * gdb-testsuite-rust-fix-for-empty-array.patch * gdb-testsuite-use-expect_build_id_in_core_file-a-bit.patch * gdb-testsuite-use-std-c99-in-gdb.base-callfuncs.exp.patch * gdb-testsuite-use-std-c99-in-gdb.base-nodebug.exp.patch * powerpc-mark-rtti-typeid-tests-as-expected-fail-befo.patch - Maintenance script import-patches.sh: * Use git instead of osc. - Maintenance script qa.sh: * Add PR32893 kfail.
60 lines
1.9 KiB
Diff
60 lines
1.9 KiB
Diff
From 772b7c2a75f392589518a0ee17a48914f1395c67 Mon Sep 17 00:00:00 2001
|
|
From: "Rudnicki, Piotr" <piotr.rudnicki@intel.com>
|
|
Date: Wed, 12 Feb 2025 10:50:37 +0100
|
|
Subject: [PATCH 03/25] gdb, testsuite, rust: fix for empty array
|
|
|
|
For the Rust language, to avoid segmentation fault in case of an empty
|
|
array, do not try to copy any elements, but allocate and return
|
|
the empty array immediately.
|
|
|
|
With the command before the change, gdb crashes with message:
|
|
|
|
(gdb) set lang rust
|
|
(gdb) p [1;0]
|
|
Fatal signal: Segmentation fault
|
|
|
|
After the fix in this commit, gdb shows following message:
|
|
(gdb) set lang rust
|
|
(gdb) p [1;0]
|
|
$1 = []
|
|
|
|
Update the existing test case gdb.rust/expr.exp to verify the change.
|
|
|
|
Approved-By: Tom Tromey <tom@tromey.com>
|
|
---
|
|
gdb/rust-lang.c | 2 +-
|
|
gdb/testsuite/gdb.rust/expr.exp | 4 ++++
|
|
2 files changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
|
|
index d4cd8802fa5..8bec934983e 100644
|
|
--- a/gdb/rust-lang.c
|
|
+++ b/gdb/rust-lang.c
|
|
@@ -1455,7 +1455,7 @@ eval_op_rust_array (struct type *expect_type, struct expression *exp,
|
|
if (copies < 0)
|
|
error (_("Array with negative number of elements"));
|
|
|
|
- if (noside == EVAL_NORMAL)
|
|
+ if (noside == EVAL_NORMAL && copies > 0)
|
|
return value_array (0, std::vector<value *> (copies, elt));
|
|
else
|
|
{
|
|
diff --git a/gdb/testsuite/gdb.rust/expr.exp b/gdb/testsuite/gdb.rust/expr.exp
|
|
index 97db748abf6..ca01c5feb36 100644
|
|
--- a/gdb/testsuite/gdb.rust/expr.exp
|
|
+++ b/gdb/testsuite/gdb.rust/expr.exp
|
|
@@ -115,6 +115,10 @@ gdb_test "print \[1,2 3" "',' or ']' expected"
|
|
gdb_test "print \[1 2" "',', ';', or ']' expected"
|
|
gdb_test "print \[23\]" " = \\\[23\\\]"
|
|
|
|
+gdb_test "print \[0;0\]" " = \\\[\\\]"
|
|
+gdb_test "print \[1;0\]" " = \\\[\\\]"
|
|
+gdb_test "print \[0;1\]" " = \\\[0\\\]"
|
|
+
|
|
gdb_test "print b\"hi rust\"" " = b\"hi rust\""
|
|
# This isn't rusty syntax yet, but that's another bug -- this is just
|
|
# testing that byte escapes work properly.
|
|
--
|
|
2.51.0
|
|
|