diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index f872f73e414..cc300cd0f6b 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -2059,26 +2059,13 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, return RETURN_VALUE_REGISTER_CONVENTION; } - /* Small character arrays are returned, right justified, in r3. */ - if (tdep->elf_abi == POWERPC_ELF_V1 - && valtype->code () == TYPE_CODE_ARRAY - && !valtype->is_vector () - && valtype->length () <= 8 - && (valtype->target_type ()->code () == TYPE_CODE_INT - || valtype->target_type ()->code () == TYPE_CODE_CHAR) - && valtype->target_type ()->length () == 1) - { - int regnum = tdep->ppc_gp0_regnum + 3; - int offset = (register_size (gdbarch, regnum) - valtype->length ()); - - if (writebuf != NULL) - regcache->cooked_write_part (regnum, offset, valtype->length (), - writebuf); - if (readbuf != NULL) - regcache->cooked_read_part (regnum, offset, valtype->length (), - readbuf); - return RETURN_VALUE_REGISTER_CONVENTION; - } + /* Small character arrays are returned, right justified, in r3, according to + the v1 ELF ABI spec [1]. But GCC doesn't implement this (PR gcc/122282), + so we treat this as an ABI spec bug, and use + RETURN_VALUE_STRUCT_CONVENTION. We don't handle this case explicly, but + let it be handled by the default return. + [1] https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html. + */ /* In the ELFv2 ABI, homogeneous floating-point or vector aggregates are returned in registers. */ diff --git a/gdb/testsuite/gdb.ada/return-small-char-array.exp b/gdb/testsuite/gdb.ada/return-small-char-array.exp index 1f6412edff4..63009bed2df 100644 --- a/gdb/testsuite/gdb.ada/return-small-char-array.exp +++ b/gdb/testsuite/gdb.ada/return-small-char-array.exp @@ -19,7 +19,13 @@ require allow_ada_tests standard_ada_testfile proc -if { [gdb_compile_ada $srcfile $binfile executable debug] != "" } { +set opts {} +lappend opts debug +if { [ada_fvar_tracking] } { + lappend opts "additional_flags=-fvar-tracking" +} + +if { [gdb_compile_ada $srcfile $binfile executable $opts] != "" } { return } @@ -31,9 +37,13 @@ runto "proc.adb:$bp_location" gdb_test "print Value.Name(My_Value)" \ { = "abcd"} -# Step into the function. -gdb_test "step 2" \ - "return Of_Value;" +# Step into the function. Don't do this by stepping, but by setting a +# breakpoint and continuing to it, to avoid the problem that varying line info +# may require us to step a different amount of times to land at the same +# location. +set bp_location_2 [gdb_get_line_number "STOP" $testdir/value.adb] +gdb_breakpoint value.adb:$bp_location_2 +gdb_continue_to_breakpoint "STOP" # and finish. gdb_test "finish" \ diff --git a/gdb/testsuite/gdb.ada/return-small-char-array/value.adb b/gdb/testsuite/gdb.ada/return-small-char-array/value.adb index 2dd9faacc1b..351e67aa27a 100644 --- a/gdb/testsuite/gdb.ada/return-small-char-array/value.adb +++ b/gdb/testsuite/gdb.ada/return-small-char-array/value.adb @@ -16,6 +16,6 @@ package body Value is function Name (Of_Value : T) return T is begin - return Of_Value; + return Of_Value; -- STOP end Name; end Value;