2006-02-21 Paul Brook <paul@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / ppc-linux-tdep.c
index 514ff4bdb866c215d1514a18721bf16997c1aca4..045208498269a41fed97135e4aaec27aac77ec63 100644 (file)
@@ -1,7 +1,8 @@
 /* Target-dependent code for GDB, the GNU debugger.
 
-   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
+   1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -17,8 +18,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "frame.h"
@@ -157,7 +158,7 @@ ppc_linux_in_sigtramp (CORE_ADDR pc, char *func_name)
   CORE_ADDR lr;
   CORE_ADDR sp;
   CORE_ADDR tramp_sp;
-  char buf[4];
+  gdb_byte buf[4];
   CORE_ADDR handler;
 
   lr = read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
@@ -205,7 +206,7 @@ insn_is_sigreturn (unsigned long pcinsn)
 static int
 ppc_linux_at_sigtramp_return_path (CORE_ADDR pc)
 {
-  char buf[12];
+  gdb_byte buf[12];
   unsigned long pcinsn;
   if (target_read_memory (pc - 4, buf, sizeof (buf)) != 0)
     return 0;
@@ -224,7 +225,7 @@ ppc_linux_at_sigtramp_return_path (CORE_ADDR pc)
 static CORE_ADDR
 ppc_linux_skip_trampoline_code (CORE_ADDR pc)
 {
-  char buf[4];
+  gdb_byte buf[4];
   struct obj_section *sect;
   struct objfile *objfile;
   unsigned long insn;
@@ -317,7 +318,8 @@ ppc_linux_skip_trampoline_code (CORE_ADDR pc)
   /* Fetch the string; we don't know how long it is.  Is it possible
      that the following will fail because we're trying to fetch too
      much? */
-  if (target_read_memory (strtab + symidx, symname, sizeof (symname)) != 0)
+  if (target_read_memory (strtab + symidx, (gdb_byte *) symname,
+                         sizeof (symname)) != 0)
     return 0;
 
   /* This might not work right if we have multiple symbols with the
@@ -455,17 +457,18 @@ ppc_linux_skip_trampoline_code (CORE_ADDR pc)
    regard to removing breakpoints in some potentially self modifying
    code.  */
 int
-ppc_linux_memory_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+ppc_linux_memory_remove_breakpoint (CORE_ADDR addr,
+                                   gdb_byte *contents_cache)
 {
   const unsigned char *bp;
   int val;
   int bplen;
-  char old_contents[BREAKPOINT_MAX];
+  gdb_byte old_contents[BREAKPOINT_MAX];
 
   /* Determine appropriate breakpoint contents and size for this address.  */
   bp = BREAKPOINT_FROM_PC (&addr, &bplen);
   if (bp == NULL)
-    error ("Software breakpoints not implemented for this target.");
+    error (_("Software breakpoints not implemented for this target."));
 
   val = target_read_memory (addr, old_contents, bplen);
 
@@ -485,8 +488,8 @@ ppc_linux_memory_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
 
 static enum return_value_convention
 ppc_linux_return_value (struct gdbarch *gdbarch, struct type *valtype,
-                       struct regcache *regcache, void *readbuf,
-                       const void *writebuf)
+                       struct regcache *regcache, gdb_byte *readbuf,
+                       const gdb_byte *writebuf)
 {  
   if ((TYPE_CODE (valtype) == TYPE_CODE_STRUCT
        || TYPE_CODE (valtype) == TYPE_CODE_UNION)
@@ -498,48 +501,6 @@ ppc_linux_return_value (struct gdbarch *gdbarch, struct type *valtype,
                                      writebuf);
 }
 
-/* Fetch (and possibly build) an appropriate link_map_offsets
-   structure for GNU/Linux PPC targets using the struct offsets
-   defined in link.h (but without actual reference to that file).
-
-   This makes it possible to access GNU/Linux PPC shared libraries
-   from a GDB that was not built on an GNU/Linux PPC host (for cross
-   debugging).  */
-
-struct link_map_offsets *
-ppc_linux_svr4_fetch_link_map_offsets (void)
-{
-  static struct link_map_offsets lmo;
-  static struct link_map_offsets *lmp = NULL;
-
-  if (lmp == NULL)
-    {
-      lmp = &lmo;
-
-      lmo.r_debug_size = 8;    /* The actual size is 20 bytes, but
-                                  this is all we need.  */
-      lmo.r_map_offset = 4;
-      lmo.r_map_size   = 4;
-
-      lmo.link_map_size = 20;  /* The actual size is 560 bytes, but
-                                  this is all we need.  */
-      lmo.l_addr_offset = 0;
-      lmo.l_addr_size   = 4;
-
-      lmo.l_name_offset = 4;
-      lmo.l_name_size   = 4;
-
-      lmo.l_next_offset = 12;
-      lmo.l_next_size   = 4;
-
-      lmo.l_prev_offset = 16;
-      lmo.l_prev_size   = 4;
-    }
-
-  return lmp;
-}
-
-
 /* Macros for matching instructions.  Note that, since all the
    operands are masked off before they're or-ed into the instruction,
    you can use -1 to make masks.  */
@@ -1091,7 +1052,7 @@ ppc_linux_init_abi (struct gdbarch_info info,
       set_gdbarch_skip_trampoline_code (gdbarch,
                                         ppc_linux_skip_trampoline_code);
       set_solib_svr4_fetch_link_map_offsets
-        (gdbarch, ppc_linux_svr4_fetch_link_map_offsets);
+        (gdbarch, svr4_ilp32_fetch_link_map_offsets);
 
       /* Trampolines.  */
       tramp_frame_prepend_unwinder (gdbarch, &ppc32_linux_sigaction_tramp_frame);
@@ -1106,11 +1067,19 @@ ppc_linux_init_abi (struct gdbarch_info info,
         (gdbarch, ppc64_linux_convert_from_func_ptr_addr);
       set_gdbarch_skip_trampoline_code (gdbarch, ppc64_skip_trampoline_code);
 
+      /* Shared library handling.  */
+      set_solib_svr4_fetch_link_map_offsets
+        (gdbarch, svr4_lp64_fetch_link_map_offsets);
+
       /* Trampolines.  */
       tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sigaction_tramp_frame);
       tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sighandler_tramp_frame);
     }
   set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section);
+
+  /* Enable TLS support.  */
+  set_gdbarch_fetch_tls_load_module_address (gdbarch,
+                                             svr4_fetch_objfile_link_map);
 }
 
 void
This page took 0.028399 seconds and 4 git commands to generate.