* dwarf2read.c (dwarf_decode_macros): New arg section_name.
[deliverable/binutils-gdb.git] / gdb / mips-linux-tdep.c
index be346d75844e2efb52f99a57fb27153f0812fb76..47af572f245088cdd100ea6e28164c8bde4c8a55 100644 (file)
@@ -1,7 +1,6 @@
 /* Target-dependent code for GNU/Linux on MIPS processors.
 
-   Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2004-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -40,6 +39,7 @@
 #include "mips-linux-tdep.h"
 #include "glibc-tdep.h"
 #include "linux-tdep.h"
+#include "xml-syscall.h"
 
 static struct target_so_ops mips_svr4_so_ops;
 
@@ -119,13 +119,8 @@ mips_supply_gregset (struct regcache *regcache,
   supply_32bit_reg (regcache, mips_regnum (gdbarch)->cause,
                    regp + EF_CP0_CAUSE);
 
-  /* Fill inaccessible registers with zero.  */
+  /* Fill the inaccessible zero register with zero.  */
   regcache_raw_supply (regcache, MIPS_ZERO_REGNUM, zerobuf);
-  regcache_raw_supply (regcache, MIPS_UNUSED_REGNUM, zerobuf);
-  for (regi = MIPS_FIRST_EMBED_REGNUM;
-       regi <= MIPS_LAST_EMBED_REGNUM;
-       regi++)
-    regcache_raw_supply (regcache, regi, zerobuf);
 }
 
 static void
@@ -374,13 +369,8 @@ mips64_supply_gregset (struct regcache *regcache,
   supply_64bit_reg (regcache, mips_regnum (gdbarch)->cause,
                    (const gdb_byte *) (regp + MIPS64_EF_CP0_CAUSE));
 
-  /* Fill inaccessible registers with zero.  */
+  /* Fill the inaccessible zero register with zero.  */
   regcache_raw_supply (regcache, MIPS_ZERO_REGNUM, zerobuf);
-  regcache_raw_supply (regcache, MIPS_UNUSED_REGNUM, zerobuf);
-  for (regi = MIPS_FIRST_EMBED_REGNUM;
-       regi <= MIPS_LAST_EMBED_REGNUM;
-       regi++)
-    regcache_raw_supply (regcache, regi, zerobuf);
 }
 
 static void
@@ -591,7 +581,7 @@ mips64_fill_fpregset_wrapper (const struct regset *regset,
   mips64_fill_fpregset (regcache, (mips64_elf_fpregset_t *)gregs, regnum);
 }
 
-const struct regset *
+static const struct regset *
 mips_linux_regset_from_core_section (struct gdbarch *gdbarch,
                                     const char *sect_name, size_t sect_size)
 {
@@ -1207,6 +1197,38 @@ mips_linux_syscall_next_pc (struct frame_info *frame)
   return pc + 4;
 }
 
+/* Return the current system call's number present in the
+   v0 register.  When the function fails, it returns -1.  */
+
+static LONGEST
+mips_linux_get_syscall_number (struct gdbarch *gdbarch,
+                              ptid_t ptid)
+{
+  struct regcache *regcache = get_thread_regcache (ptid);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int regsize = register_size (gdbarch, MIPS_V0_REGNUM);
+  /* The content of a register */
+  gdb_byte buf[8];
+  /* The result */
+  LONGEST ret;
+
+  /* Make sure we're in a known ABI */
+  gdb_assert (tdep->mips_abi == MIPS_ABI_O32
+             || tdep->mips_abi == MIPS_ABI_N32
+             || tdep->mips_abi == MIPS_ABI_N64);
+
+  gdb_assert (regsize <= sizeof (buf));
+
+  /* Getting the system call number from the register.
+     syscall number is in v0 or $2.  */
+  regcache_cooked_read (regcache, MIPS_V0_REGNUM, buf);
+
+  ret = extract_signed_integer (buf, regsize, byte_order);
+
+  return ret;
+}
+
 /* Initialize one of the GNU/Linux OS ABIs.  */
 
 static void
@@ -1219,6 +1241,9 @@ mips_linux_init_abi (struct gdbarch_info info,
 
   linux_init_abi (info, gdbarch);
 
+  /* Get the syscall number from the arch's register.  */
+  set_gdbarch_get_syscall_number (gdbarch, mips_linux_get_syscall_number);
+
   switch (abi)
     {
       case MIPS_ABI_O32:
@@ -1228,6 +1253,7 @@ mips_linux_init_abi (struct gdbarch_info info,
          (gdbarch, svr4_ilp32_fetch_link_map_offsets);
        tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_sigframe);
        tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_rt_sigframe);
+       set_xml_syscall_file_name ("syscalls/mips-o32-linux.xml");
        break;
       case MIPS_ABI_N32:
        set_gdbarch_get_longjmp_target (gdbarch,
@@ -1241,6 +1267,7 @@ mips_linux_init_abi (struct gdbarch_info info,
           does not distinguish between quiet and signalling NaNs).  */
        set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
        tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n32_rt_sigframe);
+       set_xml_syscall_file_name ("syscalls/mips-n32-linux.xml");
        break;
       case MIPS_ABI_N64:
        set_gdbarch_get_longjmp_target (gdbarch,
@@ -1254,6 +1281,7 @@ mips_linux_init_abi (struct gdbarch_info info,
           does not distinguish between quiet and signalling NaNs).  */
        set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
        tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n64_rt_sigframe);
+       set_xml_syscall_file_name ("syscalls/mips-n64-linux.xml");
        break;
       default:
        break;
@@ -1296,6 +1324,7 @@ mips_linux_init_abi (struct gdbarch_info info,
         described or not).  */
       gdb_assert (gdbarch_num_regs (gdbarch) <= MIPS_RESTART_REGNUM);
       set_gdbarch_num_regs (gdbarch, MIPS_RESTART_REGNUM + 1);
+      set_gdbarch_num_pseudo_regs (gdbarch, MIPS_RESTART_REGNUM + 1);
 
       /* If it's present, then assign it to the reserved number.  */
       feature = tdesc_find_feature (info.target_desc,
This page took 0.025164 seconds and 4 git commands to generate.