This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfa?] Fix PPC32 struct return


Jason,

This fixes a problem with GDB's struct return code vis:
struct xxx foo () { return xxx;
for NetBSD/ppc 1.6. Looking at the history though, It appears that NetBSD/ppc changed it's struct return convention between 1.5 and 1.6?


Does any OS implement the SVr4 abi correctly?

still, ok?
Andrew
2003-09-13  Andrew Cagney  <cagney@redhat.com>

	* ppcnbsd-tdep.c (ppcnbsd_use_struct_convention): New function.
	(ppcnbsd_init_abi): Set "use_struct_convention" to
	"ppcnbsd_use_struct_convention".

Index: ppcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppcnbsd-tdep.c,v
retrieving revision 1.7
diff -u -r1.7 ppcnbsd-tdep.c
--- ppcnbsd-tdep.c	5 Jan 2003 01:39:55 -0000	1.7
+++ ppcnbsd-tdep.c	13 Sep 2003 23:22:34 -0000
@@ -204,12 +204,30 @@
   return (nbsd_pc_in_sigtramp (pc, func_name));
 }
 
+/* NetBSD is confused.  It appears that 1.5 was using the correct SVr4
+   convention but, 1.6 switched to the below broken convention.  For
+   the moment use the broken convention.  Ulgh!.  */
+
+static int     
+ppcnbsd_use_struct_convention (int gcc_p, struct type *value_type)
+{  
+  if ((TYPE_LENGTH (value_type) == 16 || TYPE_LENGTH (value_type) == 8)
+      && TYPE_VECTOR (value_type))
+    return 0;                            
+
+  return !(TYPE_LENGTH (value_type) == 1
+	   || TYPE_LENGTH (value_type) == 2
+	   || TYPE_LENGTH (value_type) == 4
+	   || TYPE_LENGTH (value_type) == 8);
+}
+
 static void
 ppcnbsd_init_abi (struct gdbarch_info info,
                   struct gdbarch *gdbarch)
 {
   set_gdbarch_pc_in_sigtramp (gdbarch, ppcnbsd_pc_in_sigtramp);
 
+  set_gdbarch_use_struct_convention (gdbarch, ppcnbsd_use_struct_convention);
   set_solib_svr4_fetch_link_map_offsets (gdbarch,
                                 nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]