/* GNU/Linux/TILE-Gx specific low level interface, GDBserver.
- Copyright (C) 2012 Free Software Foundation, Inc.
+ Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of GDB.
#include "server.h"
#include "linux-low.h"
-#include <sys/ptrace.h>
+#include <arch/abi.h>
+#include "nat/gdb_ptrace.h"
-/* Defined in auto-generated file reg-tile.c. */
-void init_registers_tile (void);
+/* Defined in auto-generated file reg-tilegx.c. */
+void init_registers_tilegx (void);
+extern const struct target_desc *tdesc_tilegx;
+
+/* Defined in auto-generated file reg-tilegx32.c. */
+void init_registers_tilegx32 (void);
+extern const struct target_desc *tdesc_tilegx32;
#define tile_num_regs 65
return 1;
}
-static CORE_ADDR
-tile_get_pc (struct regcache *regcache)
-{
- unsigned long pc;
+static uint64_t tile_breakpoint = 0x400b3cae70166000ULL;
+#define tile_breakpoint_len 8
- collect_register_by_name (regcache, "pc", &pc);
- return pc;
-}
+/* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
-static void
-tile_set_pc (struct regcache *regcache, CORE_ADDR pc)
+static const gdb_byte *
+tile_sw_breakpoint_from_kind (int kind, int *size)
{
- unsigned long newpc = pc;
-
- supply_register_by_name (regcache, "pc", &newpc);
+ *size = tile_breakpoint_len;
+ return (const gdb_byte *) &tile_breakpoint;
}
-static uint64_t tile_breakpoint = 0x400b3cae70166000ULL;
-#define tile_breakpoint_len 8
-
static int
tile_breakpoint_at (CORE_ADDR where)
{
for (i = 0; i < tile_num_regs; i++)
if (tile_regmap[i] != -1)
- collect_register (regcache, i, ((unsigned int *) buf) + tile_regmap[i]);
+ collect_register (regcache, i, ((uint_reg_t *) buf) + tile_regmap[i]);
}
static void
for (i = 0; i < tile_num_regs; i++)
if (tile_regmap[i] != -1)
- supply_register (regcache, i, ((unsigned long *) buf) + tile_regmap[i]);
+ supply_register (regcache, i, ((uint_reg_t *) buf) + tile_regmap[i]);
}
-struct regset_info target_regsets[] =
+static struct regset_info tile_regsets[] =
{
- { PTRACE_GETREGS, PTRACE_SETREGS, 0, tile_num_regs * 4,
+ { PTRACE_GETREGS, PTRACE_SETREGS, 0, tile_num_regs * 8,
GENERAL_REGS, tile_fill_gregset, tile_store_gregset },
- { 0, 0, 0, -1, -1, NULL, NULL }
+ NULL_REGSET
};
+static struct regsets_info tile_regsets_info =
+ {
+ tile_regsets, /* regsets */
+ 0, /* num_regsets */
+ NULL, /* disabled_regsets */
+ };
+
+static struct usrregs_info tile_usrregs_info =
+ {
+ tile_num_regs,
+ tile_regmap,
+ };
+
+static struct regs_info regs_info =
+ {
+ NULL, /* regset_bitmap */
+ &tile_usrregs_info,
+ &tile_regsets_info,
+ };
+
+static const struct regs_info *
+tile_regs_info (void)
+{
+ return ®s_info;
+}
+
+static void
+tile_arch_setup (void)
+{
+ int pid = pid_of (current_thread);
+ unsigned int machine;
+ int is_elf64 = linux_pid_exe_is_elf_64_file (pid, &machine);
+
+ if (sizeof (void *) == 4)
+ if (is_elf64 > 0)
+ error (_("Can't debug 64-bit process with 32-bit GDBserver"));
+
+ if (!is_elf64)
+ current_process ()->tdesc = tdesc_tilegx32;
+ else
+ current_process ()->tdesc = tdesc_tilegx;
+}
+
+/* Support for hardware single step. */
+
+static int
+tile_supports_hardware_single_step (void)
+{
+ return 1;
+}
+
+
struct linux_target_ops the_low_target =
{
- init_registers_tile,
- tile_num_regs,
- tile_regmap,
- NULL,
+ tile_arch_setup,
+ tile_regs_info,
tile_cannot_fetch_register,
tile_cannot_store_register,
NULL,
- tile_get_pc,
- tile_set_pc,
- (const unsigned char *) &tile_breakpoint,
- tile_breakpoint_len,
+ linux_get_pc_64bit,
+ linux_set_pc_64bit,
+ NULL, /* breakpoint_kind_from_pc */
+ tile_sw_breakpoint_from_kind,
NULL,
0,
tile_breakpoint_at,
+ NULL, /* supports_z_point_type */
+ NULL, /* insert_point */
+ NULL, /* remove_point */
+ NULL, /* stopped_by_watchpoint */
+ NULL, /* stopped_data_address */
+ NULL, /* collect_ptrace_register */
+ NULL, /* supply_ptrace_register */
+ NULL, /* siginfo_fixup */
+ NULL, /* new_process */
+ NULL, /* new_thread */
+ NULL, /* new_fork */
+ NULL, /* prepare_to_resume */
+ NULL, /* process_qsupported */
+ NULL, /* supports_tracepoints */
+ NULL, /* get_thread_area */
+ NULL, /* install_fast_tracepoint_jump_pad */
+ NULL, /* emit_ops */
+ NULL, /* get_min_fast_tracepoint_insn_len */
+ NULL, /* supports_range_stepping */
+ NULL, /* breakpoint_kind_from_current_state */
+ tile_supports_hardware_single_step,
};
+
+void
+initialize_low_arch (void)
+{
+ init_registers_tilegx32();
+ init_registers_tilegx();
+
+ initialize_regsets_info (&tile_regsets_info);
+}