* alpha-tdep.c (alpha_supply_int_regs, alpha_fill_int_regs,
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-arm-low.c
index b2c314fef8176b4446d70651cf48f61d9fc4465d..1267e1d8a000cd0d442ac7dac6769553c079e011 100644 (file)
@@ -1,6 +1,6 @@
 /* GNU/Linux/ARM specific low level interface, for the remote server for GDB.
-   Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2006, 2007 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "server.h"
 #include "linux-low.h"
 
+#include <sys/ptrace.h>
+
+#include "gdb_proc_service.h"
+
+#ifndef PTRACE_GET_THREAD_AREA
+#define PTRACE_GET_THREAD_AREA 22
+#endif
+
+#ifndef PTRACE_GETWMMXREGS
+# define PTRACE_GETWMMXREGS 18
+# define PTRACE_SETWMMXREGS 19
+#endif
+
 #ifdef HAVE_SYS_REG_H
 #include <sys/reg.h>
 #endif
@@ -47,6 +60,60 @@ arm_cannot_fetch_register (int regno)
   return (regno >= arm_num_regs);
 }
 
+static void
+arm_fill_gregset (void *buf)
+{
+  int i;
+
+  for (i = 0; i < arm_num_regs; i++)
+    if (arm_regmap[i] != -1)
+      collect_register (i, ((char *) buf) + arm_regmap[i]);
+}
+
+static void
+arm_store_gregset (const void *buf)
+{
+  int i;
+  char zerobuf[8];
+
+  memset (zerobuf, 0, 8);
+  for (i = 0; i < arm_num_regs; i++)
+    if (arm_regmap[i] != -1)
+      supply_register (i, ((char *) buf) + arm_regmap[i]);
+    else
+      supply_register (i, zerobuf);
+}
+
+#ifdef __IWMMXT__
+
+static void
+arm_fill_wmmxregset (void *buf)
+{
+  int i;
+
+  for (i = 0; i < 16; i++)
+    collect_register (arm_num_regs + i, (char *) buf + i * 8);
+
+  /* We only have access to wcssf, wcasf, and wcgr0-wcgr3.  */
+  for (i = 0; i < 6; i++)
+    collect_register (arm_num_regs + i + 16, (char *) buf + 16 * 8 + i * 4);
+}
+
+static void
+arm_store_wmmxregset (const void *buf)
+{
+  int i;
+
+  for (i = 0; i < 16; i++)
+    supply_register (arm_num_regs + i, (char *) buf + i * 8);
+
+  /* We only have access to wcssf, wcasf, and wcgr0-wcgr3.  */
+  for (i = 0; i < 6; i++)
+    supply_register (arm_num_regs + i + 16, (char *) buf + 16 * 8 + i * 4);
+}
+
+#endif /* __IWMMXT__ */
+
 extern int debug_threads;
 
 static CORE_ADDR
@@ -105,6 +172,35 @@ arm_reinsert_addr ()
   return pc;
 }
 
+/* Fetch the thread-local storage pointer for libthread_db.  */
+
+ps_err_e
+ps_get_thread_area (const struct ps_prochandle *ph,
+                    lwpid_t lwpid, int idx, void **base)
+{
+  if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
+    return PS_ERR;
+
+  /* IDX is the bias from the thread pointer to the beginning of the
+     thread descriptor.  It has to be subtracted due to implementation
+     quirks in libthread_db.  */
+  *base = (void *) ((char *)*base - idx);
+
+  return PS_OK;
+}
+
+struct regset_info target_regsets[] = {
+  { PTRACE_GETREGS, PTRACE_SETREGS, 18 * 4,
+    GENERAL_REGS,
+    arm_fill_gregset, arm_store_gregset },
+#ifdef __IWMMXT__
+  { PTRACE_GETWMMXREGS, PTRACE_SETWMMXREGS, 16 * 8 + 6 * 4,
+    EXTENDED_REGS,
+    arm_fill_wmmxregset, arm_store_wmmxregset },
+#endif
+  { 0, 0, -1, -1, NULL, NULL }
+};
+
 struct linux_target_ops the_low_target = {
   arm_num_regs,
   arm_regmap,
This page took 0.024923 seconds and 4 git commands to generate.