]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb, testsuite: Extend core_find procedure to save program output.
authorChristina Schimpe <christina.schimpe@intel.com>
Fri, 27 Jun 2025 16:09:17 +0000 (09:09 -0700)
committerChristina Schimpe <christina.schimpe@intel.com>
Fri, 29 Aug 2025 17:02:08 +0000 (17:02 +0000)
From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>

The change comes from ARM's GCS series:

[PATCH v3 5/9] GDB, gdbserver: aarch64-linux: Initial Guarded Control Stack support.

We need it for testing coredump files, too.  So include it in this patch series.

Abridged-by: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
---
This is the patch mentioned above:

https://sourceware.org/pipermail/gdb-patches/2025-June/218892.html

Minus everything except for the change in gdb.exp's corefind procedure.

gdb/testsuite/lib/gdb.exp

index d3e2a454902cdabffae5073adc7c10a9e7af904e..4e28c1ba6b2a608f95fb32a71eb702b057d81fb1 100644 (file)
@@ -9568,7 +9568,13 @@ proc remove_core {pid {test ""}} {
     }
 }
 
-proc core_find {binfile {deletefiles {}} {arg ""}} {
+# Runs ${binfile} expecting it to crash and generate a core file.
+# If DELETEFILES is provided, remove these files after running the program.
+# If ARG is provided, pass it as a command line argument to the program.
+# If OUTPUT_FILE is provided, save the program output to it.
+# Returns the name of the core dump, or empty string if not found.
+
+proc core_find {binfile {deletefiles {}} {arg ""} {output_file "/dev/null"}} {
     global objdir subdir
 
     set destcore "$binfile.core"
@@ -9590,7 +9596,7 @@ proc core_find {binfile {deletefiles {}} {arg ""}} {
     set found 0
     set coredir [standard_output_file coredir.[getpid]]
     file mkdir $coredir
-    catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile} ${arg}; true) >/dev/null 2>&1\""
+    catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile} ${arg}; true) >${output_file} 2>&1\""
     #      remote_exec host "${binfile}"
     set binfile_basename [file tail $binfile]
     foreach i [list \