PowerPC: Fix test gdb.ada/finish-large.exp

Message ID 208227c23637af9092d488399f5c197c21f742cb.camel@linux.ibm.com
State New
Headers
Series PowerPC: Fix test gdb.ada/finish-large.exp |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 warning Patch is already merged
linaro-tcwg-bot/tcwg_gdb_check--master-arm warning Patch is already merged

Commit Message

Carl Love Nov. 16, 2023, 10:10 p.m. UTC
  GDB maintainers:

The following patch fixes a single regression error in test
gdb.ada/finish-large.exp on the PowerPC platform.

The patch compiles the test with the -fvar-tracking command line option
enabled so the DWARF DW_TAG_call_site information will be included in
the binary.  This DWARF information is used by PowerPC to obtain the
value of r3 on entry to a function.  The address to return a structure
is passed into a function in r3.  But r3 is not guaranteed to be the
same at the end of the function when the finish command prints the
function return value.  With -fvar-tracking enabled, GDB can now print
the return value of a function returning a large structure on the
PowerPC platform.

The patch has been tested on Power 10 and X86-64 with no regression
errors.

Please let me know if this patch is acceptable for mainline.  Thanks.

Thanks to Luis, Tom and Keith for their help.

                           Carl

------------------------------------
PowerPC: Fix test gdb.ada/finish-large.exp

Function Create_large returns a large data structure.  On PowerPC, register
r3 contains the address of where the data structure to be returned is to
be stored.  However, on exit the ABI does not guarantee that r3 has not
been changed.  The GDB finish command prints the return value of the
function at the end of the function.  GDB needs to use the
DW_TAG_call_site information to determine the value of r3 on entry to
the function to correctly print the return value at the end of the
function.  The test must be compiled with -fvar-tracking for the
DW_TAG_call_site information to be included in the executable file.

This patch adds the -fvar-tracking option to the compile line if the
option is supported.

The patch fixes the one regression error for the test on PowerPC.

The patch has been tested on Power 10 and X86-64 with no regressions.
---
 gdb/testsuite/gdb.ada/finish-large.exp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Comments

Tom Tromey Nov. 17, 2023, 1:33 p.m. UTC | #1
>>>>> "Carl" == Carl Love <cel@linux.ibm.com> writes:

Carl> Please let me know if this patch is acceptable for mainline.  Thanks.

Thanks, this is ok.

Tom
  

Patch

diff --git a/gdb/testsuite/gdb.ada/finish-large.exp b/gdb/testsuite/gdb.ada/finish-large.exp
index 5661d132a18..6c8b1b2648d 100644
--- a/gdb/testsuite/gdb.ada/finish-large.exp
+++ b/gdb/testsuite/gdb.ada/finish-large.exp
@@ -19,7 +19,13 @@  require allow_ada_tests
 
 standard_ada_testfile p
 
-if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} {
+set flags {debug}
+
+if {[have_fvar_tracking]} {
+  lappend flags "additional_flags=-fvar-tracking"
+}
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
   return -1
 }