From 3eba3a011a89c75c10bd1860eee4589e65697165 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 14 Sep 2020 08:30:10 -0600 Subject: Various m68k fixes for gdb Recently I tried the m68k port of gdb. It had some issues, which are fixed in this patch. * Various types of return values were not being handled properly. In particular: * arrays are returned by following the same convention as structures. This matters in languages like Ada, where an array can in fact be returned as a value. * "long double" was not being handled correctly in m68k_svr4_return_value. * GCC's m68k back end does not return vector types in registers, so change gdb to follow. * GCC's m68k back end doesn't faithfully implement the ABI, and so some objects with unusual size (not possible in C, but possible in Ada) are not returned correctly. * gcc implements an m68k ABI variant that it simply describes as "embedded". This ABI is similar to the SVR4 ABI, but rather than returning pointer-typed values in %a0, such values are returned in %d0. To support this, an ELF osabi sniffer is added. * Commit 85f7484a ("m68k: tag floating-point ABI used") adds an attribute that can be used to recognize when hard- or soft-float is in use. gdb can now read this tag and choose the ABI accordingly. I was unable to run the gdb test suite with this patch. Instead, I tested it using qemu and the internal AdaCore test suite. gdb/ChangeLog 2020-09-14 Tom Tromey * m68k-tdep.c (m68k_extract_return_value): Use pointer_result_regnum. (m68k_store_return_value): Likewise. (m68k_reg_struct_return_p): Handle vectors and arrays. (m68k_return_value): Handle arrays. (m68k_svr4_return_value): Fix single-element aggregate handling. Handle long double. Adjust for embedded ABI. (m68k_svr4_init_abi): Set pointer_result_regnum. (m68k_embedded_init_abi): New function. (m68k_gdbarch_init): Handle Tag_GNU_M68K_ABI_FP. (m68k_osabi_sniffer): New function. (_initialize_m68k_tdep): Register osabi sniffer. * m68k-tdep.h (struct gdbarch_tdep) : New member. --- gdb/m68k-tdep.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gdb/m68k-tdep.h') diff --git a/gdb/m68k-tdep.h b/gdb/m68k-tdep.h index 1567505..513190f 100644 --- a/gdb/m68k-tdep.h +++ b/gdb/m68k-tdep.h @@ -79,6 +79,10 @@ struct gdbarch_tdep passed to a function. */ int struct_value_regnum; + /* Register in which a pointer value is returned. In the SVR4 ABI, + this is %a0, but in GCC's "embedded" ABI, this is %d0. */ + int pointer_result_regnum; + /* Convention for returning structures. */ enum struct_return struct_return; -- cgit v1.1