2004-02-14 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / ppcnbsd-tdep.c
index 16662fd628793d64e81aa514b7d17497a3cd8771..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"
@@ -196,17 +197,44 @@ static struct core_fns ppcnbsd_elfcore_fns =
   NULL                                 /* next */
 };
 
+static int
+ppcnbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+{
+  /* FIXME: Need to add support for kernel-provided signal trampolines.  */
+  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)
 {
-  /* Until November 2001, gcc was not complying to the SYSV ABI for
-     returning structures less than or equal to 8 bytes in size. It was
-     returning everything in memory. When this was corrected, it wasn't
-     fixed for native platforms.  */
-  set_gdbarch_use_struct_convention (gdbarch,
-                                   ppc_sysv_abi_broken_use_struct_convention);
-
+  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);
 }
@@ -214,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.02455 seconds and 4 git commands to generate.