2004-02-14 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / ppcnbsd-tdep.c
index 3d052a83ff2b67a798a5ac4d53fdfc4419c9df4e..adc2a4f1386e2374a69f96a1aa9a1d8e9c077206 100644 (file)
@@ -1,5 +1,5 @@
 /* Target-dependent code for PowerPC systems running NetBSD.
-   Copyright 2002 Free Software Foundation, Inc.
+   Copyright 2002, 2003 Free Software Foundation, Inc.
    Contributed by Wasabi Systems, Inc.
 
    This file is part of GDB.
@@ -25,6 +25,7 @@
 #include "target.h"
 #include "breakpoint.h"
 #include "value.h"
+#include "osabi.h"
 
 #include "ppc-tdep.h"
 #include "ppcnbsd-tdep.h"
@@ -203,15 +204,37 @@ ppcnbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
   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 enum return_value_convention
+ppcnbsd_return_value (struct gdbarch *gdbarch, struct type *valtype,
+                     struct regcache *regcache, void *readbuf,
+                     const void *writebuf)
+{
+  if ((TYPE_CODE (valtype) == TYPE_CODE_STRUCT
+       || TYPE_CODE (valtype) == TYPE_CODE_UNION)
+      && !((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8)
+           && TYPE_VECTOR (valtype))
+      && !(TYPE_LENGTH (valtype) == 1
+          || TYPE_LENGTH (valtype) == 2
+          || TYPE_LENGTH (valtype) == 4
+          || TYPE_LENGTH (valtype) == 8))
+    return RETURN_VALUE_STRUCT_CONVENTION;
+  else
+    return ppc_sysv_abi_broken_return_value (gdbarch, valtype, regcache,
+                                            readbuf, writebuf);
+}
+
 static void
 ppcnbsd_init_abi (struct gdbarch_info info,
                   struct gdbarch *gdbarch)
 {
-  /* Stop at main.  */
-  set_gdbarch_frame_chain_valid (gdbarch, generic_func_frame_chain_valid);
-
   set_gdbarch_pc_in_sigtramp (gdbarch, ppcnbsd_pc_in_sigtramp);
-
+  /* For NetBSD, this is an on again, off again thing.  Some systems
+     do use the broken struct convention, and some don't.  */
+  set_gdbarch_return_value (gdbarch, ppcnbsd_return_value);
   set_solib_svr4_fetch_link_map_offsets (gdbarch,
                                 nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
 }
@@ -219,7 +242,7 @@ ppcnbsd_init_abi (struct gdbarch_info info,
 void
 _initialize_ppcnbsd_tdep (void)
 {
-  gdbarch_register_osabi (bfd_arch_powerpc, GDB_OSABI_NETBSD_ELF,
+  gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_NETBSD_ELF,
                          ppcnbsd_init_abi);
 
   add_core_fns (&ppcnbsd_core_fns);
This page took 0.024067 seconds and 4 git commands to generate.