gdbserver: fix killed-outside.exp
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-amd64-ipa.c
index dcc1e6f2ecc27cbb0be8799966ec6cad0d62b19b..a6dfb0372e9b35496111501767e233aeaf3bdf65 100644 (file)
@@ -1,7 +1,7 @@
 /* GNU/Linux/x86-64 specific low level interface, for the in-process
    agent library for GDB.
 
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "server.h"
+#include "tracepoint.h"
 
 /* Defined in auto-generated file amd64-linux.c.  */
 void init_registers_amd64_linux (void);
+extern const struct target_desc *tdesc_amd64_linux;
 
 /* fast tracepoints collect registers.  */
 
@@ -66,12 +68,107 @@ supply_fast_tracepoint_registers (struct regcache *regcache,
                     ((char *) buf) + x86_64_ft_collect_regmap[i]);
 }
 
-/* This is only needed because reg-i386-linux-lib.o references it.  We
-   may use it proper at some point.  */
-const char *gdbserver_xmltarget;
+IP_AGENT_EXPORT_FUNC ULONGEST
+gdb_agent_get_raw_reg (const unsigned char *raw_regs, int regnum)
+{
+  if (regnum >= X86_64_NUM_FT_COLLECT_GREGS)
+    return 0;
+
+  return *(ULONGEST *) (raw_regs + x86_64_ft_collect_regmap[regnum]);
+}
+
+#ifdef HAVE_UST
+
+#include <ust/processor.h>
+
+/* "struct registers" is the UST object type holding the registers at
+   the time of the static tracepoint marker call.  This doesn't
+   contain RIP, but we know what it must have been (the marker
+   address).  */
+
+#define ST_REGENTRY(REG)                       \
+  {                                            \
+    offsetof (struct registers, REG),          \
+    sizeof (((struct registers *) NULL)->REG)  \
+  }
+
+static struct
+{
+  int offset;
+  int size;
+} x86_64_st_collect_regmap[] =
+  {
+    ST_REGENTRY(rax),
+    ST_REGENTRY(rbx),
+    ST_REGENTRY(rcx),
+    ST_REGENTRY(rdx),
+    ST_REGENTRY(rsi),
+    ST_REGENTRY(rdi),
+    ST_REGENTRY(rbp),
+    ST_REGENTRY(rsp),
+    ST_REGENTRY(r8),
+    ST_REGENTRY(r9),
+    ST_REGENTRY(r10),
+    ST_REGENTRY(r11),
+    ST_REGENTRY(r12),
+    ST_REGENTRY(r13),
+    ST_REGENTRY(r14),
+    ST_REGENTRY(r15),
+    { -1, 0 },
+    ST_REGENTRY(rflags),
+    ST_REGENTRY(cs),
+    ST_REGENTRY(ss),
+  };
+
+#define X86_64_NUM_ST_COLLECT_GREGS \
+  (sizeof (x86_64_st_collect_regmap) / sizeof (x86_64_st_collect_regmap[0]))
+
+/* GDB's RIP register number.  */
+#define AMD64_RIP_REGNUM 16
+
+void
+supply_static_tracepoint_registers (struct regcache *regcache,
+                                   const unsigned char *buf,
+                                   CORE_ADDR pc)
+{
+  int i;
+  unsigned long newpc = pc;
+
+  supply_register (regcache, AMD64_RIP_REGNUM, &newpc);
+
+  for (i = 0; i < X86_64_NUM_ST_COLLECT_GREGS; i++)
+    if (x86_64_st_collect_regmap[i].offset != -1)
+      {
+       switch (x86_64_st_collect_regmap[i].size)
+         {
+         case 8:
+           supply_register (regcache, i,
+                            ((char *) buf)
+                            + x86_64_st_collect_regmap[i].offset);
+           break;
+         case 2:
+           {
+             unsigned long reg
+               = * (short *) (((char *) buf)
+                              + x86_64_st_collect_regmap[i].offset);
+             reg &= 0xffff;
+             supply_register (regcache, i, &reg);
+           }
+           break;
+         default:
+           internal_error (__FILE__, __LINE__,
+                           "unhandled register size: %d",
+                           x86_64_st_collect_regmap[i].size);
+           break;
+         }
+      }
+}
+
+#endif /* HAVE_UST */
 
 void
 initialize_low_tracepoint (void)
 {
   init_registers_amd64_linux ();
+  ipa_tdesc = tdesc_amd64_linux;
 }
This page took 0.024947 seconds and 4 git commands to generate.