target.h: #include <sys/types.h>.
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-xtensa-low.c
index 4dacceebc718e5a5af576ca80753e8ef83f880ba..7c71631ad9d41e8822421f0e1673ec5d189cf0c6 100644 (file)
@@ -26,6 +26,8 @@ extern const struct target_desc *tdesc_xtensa;
 
 #include <asm/ptrace.h>
 #include <xtensa-config.h>
+#include "arch/xtensa.h"
+#include "gdb_proc_service.h"
 
 #include "xtensa-xtregs.c"
 
@@ -140,7 +142,7 @@ static struct regset_info xtensa_regsets[] = {
   { PTRACE_GETXTREGS, PTRACE_SETXTREGS, 0, XTENSA_ELF_XTREG_SIZE,
     EXTENDED_REGS,
     xtensa_fill_xtregset, xtensa_store_xtregset },
-  { 0, 0, 0, -1, -1, NULL, NULL }
+  NULL_REGSET
 };
 
 #if XCHAL_HAVE_BE
@@ -149,9 +151,18 @@ static struct regset_info xtensa_regsets[] = {
 #define XTENSA_BREAKPOINT {0x2d,0xf0}
 #endif
 
-static const unsigned char xtensa_breakpoint[] = XTENSA_BREAKPOINT;
+static const gdb_byte xtensa_breakpoint[] = XTENSA_BREAKPOINT;
 #define xtensa_breakpoint_len 2
 
+/* Implementation of linux_target_ops method "sw_breakpoint_from_kind".  */
+
+static const gdb_byte *
+xtensa_sw_breakpoint_from_kind (int kind, int *size)
+{
+  *size = xtensa_breakpoint_len;
+  return xtensa_breakpoint;
+}
+
 static CORE_ADDR
 xtensa_get_pc (struct regcache *regcache)
 {
@@ -179,6 +190,25 @@ xtensa_breakpoint_at (CORE_ADDR where)
                  xtensa_breakpoint, xtensa_breakpoint_len) == 0;
 }
 
+/* Called by libthread_db.  */
+
+ps_err_e
+ps_get_thread_area (const struct ps_prochandle *ph,
+                    lwpid_t lwpid, int idx, void **base)
+{
+  xtensa_elf_gregset_t regs;
+
+  if (ptrace (PTRACE_GETREGS, lwpid, NULL, &regs) != 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 *) regs.threadptr - idx);
+
+  return PS_OK;
+}
+
 static struct regsets_info xtensa_regsets_info =
   {
     xtensa_regsets, /* regsets */
@@ -213,8 +243,8 @@ struct linux_target_ops the_low_target = {
   NULL, /* fetch_register */
   xtensa_get_pc,
   xtensa_set_pc,
-  xtensa_breakpoint,
-  xtensa_breakpoint_len,
+  NULL, /* breakpoint_kind_from_pc */
+  xtensa_sw_breakpoint_from_kind,
   NULL,
   0,
   xtensa_breakpoint_at,
This page took 0.024159 seconds and 4 git commands to generate.