Tom de Vries a16f37e888 [gdb/tdep] Fix gdb.ada/finish-var-size.exp on ppc64le-linux
On openSUSE Tumbleweed ppc64le-linux using gcc 14.3.0, with a gdb 16.3 based
package and test-case gdb.ada/finish-var-size.exp, I run into:
...
(gdb) finish^M
Run till exit from #0  pck.get (value=true) at pck.adb:19^M
0x0000000100004a20 in p () at finish-var-size/p.adb:18^M
18        V : Result_T := Get (True);^M
Value returned is $1 = <error reading variable: \
  Cannot access memory at address 0x0>^M
(gdb) FAIL: gdb.ada/finish-var-size.exp: finish
...

Function pck.get returns type Result_T:
...
  type Array_Type is array (1 .. 64) of Integer;

  type Maybe_Array (Defined : Boolean := False) is
    record
      Arr : Array_Type;
      Arr2 : Array_Type;
    end record;

  type Result_T (Defined : Boolean := False) is
    record
      case Defined is
        when False =>
          Arr : Maybe_Array;
        when True =>
          Payload : Boolean;
      end case;
    end record;
...
and uses r3 as address of the return value, which means
RETURN_VALUE_STRUCT_CONVENTION, but while executing finish_command we do:
...
      return_value
	= gdbarch_return_value_as_value (gdbarch,
                                         read_var_value (sm->function, nullptr,
                                                         callee_frame),
                                         val_type, nullptr, nullptr, nullptr);
...
and get:
...
(gdb) p return_value
$1 = RETURN_VALUE_REGISTER_CONVENTION
...

This is caused by this check in ppc64_sysv_abi_return_value:
...
   /* In the ELFv2 ABI, aggregate types of up to 16 bytes are
      returned in registers r3:r4.  */
   if (tdep->elf_abi == POWERPC_ELF_V2
       && valtype->length () <= 16
...
which succeeds because valtype->length () == 0.

Fix this by also checking for !TYPE_HAS_DYNAMIC_LENGTH (valtype).

[ I also tested a version of this patch using "!is_dynamic_type (valtype)"
instead, but ran into a regression in test-case gdb.ada/variant-record.exp,
because type T:
...
    Length : constant Positive := 8;
    subtype Name_T is String (1 .. Length);

    type A_Record_T is
      record
        X1 : Natural;
        X2 : Natural;
      end record;

    type Yes_No_T is (Yes, No);
    type T (Well : Yes_No_T := Yes) is
      record
	case Well is
          when Yes =>
            Name : Name_T;
          when No =>
            Unique_Name : A_Record_T;
	end case;
      end record;
...
while being dynamic, also has a non-zero size, and is small enough to be
returned in registers r3:r4. ]

Fixing this causes the test-case to fail with the familiar:
...
warning: Cannot determine the function return value.
Try compiling with -fvar-tracking.
...
and indeed using -fvar-tracking makes the test-case pass.

Tested on ppc64le-linux.

PR tdep/33000
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33000
2025-06-01 14:06:01 +02:00
2025-01-19 12:09:01 +00:00
2025-06-01 13:21:00 +09:30
2023-08-12 10:27:57 +09:30
2025-05-20 09:49:13 +02:00
2022-01-28 08:25:42 -05:00
2025-02-28 16:06:25 +00:00

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.
Description
Unofficial mirror of sourceware binutils-gdb repository. Updated daily.
Readme 738 MiB
Languages
C 51.8%
Makefile 22.4%
Assembly 12.3%
C++ 6%
Roff 1.4%
Other 5.4%