/* GNU/Linux/Xtensa specific low level interface, for the remote server for GDB.
- Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007-2015 Free Software Foundation, Inc.
This file is part of GDB.
/* Defined in auto-generated file reg-xtensa.c. */
void init_registers_xtensa (void);
+extern const struct target_desc *tdesc_xtensa;
-#include <sys/ptrace.h>
+#include <asm/ptrace.h>
#include <xtensa-config.h>
+#include "arch/xtensa.h"
+#include "gdb_proc_service.h"
#include "xtensa-xtregs.c"
R_LBEG, R_LEND, R_LCOUNT,
R_SAR,
R_WS, R_WB,
- R_A0 = 64
+ R_A0 = 64
};
static void
-xtensa_fill_gregset (void *buf)
+xtensa_fill_gregset (struct regcache *regcache, void *buf)
{
elf_greg_t* rset = (elf_greg_t*)buf;
+ const struct target_desc *tdesc = regcache->tdesc;
int ar0_regnum;
char *ptr;
int i;
/* Take care of AR registers. */
- ar0_regnum = find_regno ("ar0");
+ ar0_regnum = find_regno (tdesc, "ar0");
ptr = (char*)&rset[R_A0];
for (i = ar0_regnum; i < ar0_regnum + XCHAL_NUM_AREGS; i++)
{
- collect_register (i, ptr);
- ptr += register_size(i);
+ collect_register (regcache, i, ptr);
+ ptr += register_size (tdesc, i);
}
/* Loop registers, if hardware has it. */
-#if XCHAL_HAVE_LOOP
- collect_register_by_name ("lbeg", (char*)&rset[R_LBEG]);
- collect_register_by_name ("lend", (char*)&rset[R_LEND]);
- collect_register_by_name ("lcount", (char*)&rset[R_LCOUNT]);
+#if XCHAL_HAVE_LOOPS
+ collect_register_by_name (regcache, "lbeg", (char*)&rset[R_LBEG]);
+ collect_register_by_name (regcache, "lend", (char*)&rset[R_LEND]);
+ collect_register_by_name (regcache, "lcount", (char*)&rset[R_LCOUNT]);
#endif
- collect_register_by_name ("sar", (char*)&rset[R_SAR]);
- collect_register_by_name ("pc", (char*)&rset[R_PC]);
- collect_register_by_name ("ps", (char*)&rset[R_PS]);
- collect_register_by_name ("windowbase", (char*)&rset[R_WB]);
- collect_register_by_name ("windowstart", (char*)&rset[R_WS]);
+ collect_register_by_name (regcache, "sar", (char*)&rset[R_SAR]);
+ collect_register_by_name (regcache, "pc", (char*)&rset[R_PC]);
+ collect_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
+ collect_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
+ collect_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
}
static void
-xtensa_store_gregset (const void *buf)
+xtensa_store_gregset (struct regcache *regcache, const void *buf)
{
const elf_greg_t* rset = (const elf_greg_t*)buf;
+ const struct target_desc *tdesc = regcache->tdesc;
int ar0_regnum;
char *ptr;
int i;
/* Take care of AR registers. */
- ar0_regnum = find_regno ("ar0");
+ ar0_regnum = find_regno (tdesc, "ar0");
ptr = (char *)&rset[R_A0];
for (i = ar0_regnum; i < ar0_regnum + XCHAL_NUM_AREGS; i++)
{
- supply_register (i, ptr);
- ptr += register_size(i);
+ supply_register (regcache, i, ptr);
+ ptr += register_size (tdesc, i);
}
/* Loop registers, if hardware has it. */
-#if XCHAL_HAVE_LOOP
- supply_register_by_name ("lbeg", (char*)&rset[R_LBEG]);
- supply_register_by_name ("lend", (char*)&rset[R_LEND]);
- supply_register_by_name ("lcount", (char*)&rset[R_LCOUNT]);
+#if XCHAL_HAVE_LOOPS
+ supply_register_by_name (regcache, "lbeg", (char*)&rset[R_LBEG]);
+ supply_register_by_name (regcache, "lend", (char*)&rset[R_LEND]);
+ supply_register_by_name (regcache, "lcount", (char*)&rset[R_LCOUNT]);
#endif
- supply_register_by_name ("sar", (char*)&rset[R_SAR]);
- supply_register_by_name ("pc", (char*)&rset[R_PC]);
- supply_register_by_name ("ps", (char*)&rset[R_PS]);
- supply_register_by_name ("windowbase", (char*)&rset[R_WB]);
- supply_register_by_name ("windowstart", (char*)&rset[R_WS]);
+ supply_register_by_name (regcache, "sar", (char*)&rset[R_SAR]);
+ supply_register_by_name (regcache, "pc", (char*)&rset[R_PC]);
+ supply_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
+ supply_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
+ supply_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
}
/* Xtensa GNU/Linux PTRACE interface includes extended register set. */
static void
-xtensa_fill_xtregset (void *buf)
+xtensa_fill_xtregset (struct regcache *regcache, void *buf)
{
const xtensa_regtable_t *ptr;
for (ptr = xtensa_regmap_table; ptr->name; ptr++)
{
- collect_register_by_name (ptr->name,
+ collect_register_by_name (regcache, ptr->name,
(char*)buf + ptr->ptrace_offset);
}
}
static void
-xtensa_store_xtregset (const void *buf)
+xtensa_store_xtregset (struct regcache *regcache, const void *buf)
{
const xtensa_regtable_t *ptr;
for (ptr = xtensa_regmap_table; ptr->name; ptr++)
{
- supply_register_by_name (ptr->name,
+ supply_register_by_name (regcache, ptr->name,
(char*)buf + ptr->ptrace_offset);
}
}
-struct regset_info target_regsets[] = {
- { PTRACE_GETREGS, PTRACE_SETREGS, sizeof (elf_gregset_t),
+static struct regset_info xtensa_regsets[] = {
+ { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t),
GENERAL_REGS,
xtensa_fill_gregset, xtensa_store_gregset },
- { PTRACE_GETXTREGS, PTRACE_SETXTREGS, XTENSA_ELF_XTREG_SIZE,
+ { PTRACE_GETXTREGS, PTRACE_SETXTREGS, 0, XTENSA_ELF_XTREG_SIZE,
EXTENDED_REGS,
xtensa_fill_xtregset, xtensa_store_xtregset },
- { 0, 0, -1, -1, NULL, NULL }
+ NULL_REGSET
};
#if XCHAL_HAVE_BE
#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 (void)
+xtensa_get_pc (struct regcache *regcache)
{
unsigned long pc;
- collect_register_by_name ("pc", &pc);
+ collect_register_by_name (regcache, "pc", &pc);
return pc;
}
static void
-xtensa_set_pc (CORE_ADDR pc)
+xtensa_set_pc (struct regcache *regcache, CORE_ADDR pc)
{
unsigned long newpc = pc;
- supply_register_by_name ("pc", &newpc);
+ supply_register_by_name (regcache, "pc", &newpc);
}
static int
(*the_target->read_memory) (where, (unsigned char *) &insn,
xtensa_breakpoint_len);
- return memcmp((char *)&insn, xtensa_breakpoint, xtensa_breakpoint_len) == 0;
+ return memcmp((char *) &insn,
+ 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, ®s) != 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 */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+ };
+
+static struct regs_info regs_info =
+ {
+ NULL, /* regset_bitmap */
+ NULL, /* usrregs */
+ &xtensa_regsets_info
+ };
+
+static void
+xtensa_arch_setup (void)
+{
+ current_process ()->tdesc = tdesc_xtensa;
+}
+
+static const struct regs_info *
+xtensa_regs_info (void)
+{
+ return ®s_info;
}
struct linux_target_ops the_low_target = {
- init_registers_xtensa,
- 0,
- 0,
+ xtensa_arch_setup,
+ xtensa_regs_info,
0,
0,
+ 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,
};
+
+
+void
+initialize_low_arch (void)
+{
+ /* Initialize the Linux target descriptions. */
+ init_registers_xtensa ();
+
+ initialize_regsets_info (&xtensa_regsets_info);
+}