GDBserver
linux-tile-low.c
Go to the documentation of this file.
1 /* GNU/Linux/TILE-Gx specific low level interface, GDBserver.
2 
3  Copyright (C) 2012-2018 Free Software Foundation, Inc.
4 
5  This file is part of GDB.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #include "server.h"
21 #include "linux-low.h"
22 
23 #include <arch/abi.h>
24 #include "nat/gdb_ptrace.h"
25 
26 /* Defined in auto-generated file reg-tilegx.c. */
27 void init_registers_tilegx (void);
28 extern const struct target_desc *tdesc_tilegx;
29 
30 /* Defined in auto-generated file reg-tilegx32.c. */
31 void init_registers_tilegx32 (void);
32 extern const struct target_desc *tdesc_tilegx32;
33 
34 #define tile_num_regs 65
35 
36 static int tile_regmap[] =
37 {
38  0, 1, 2, 3, 4, 5, 6, 7,
39  8, 9, 10, 11, 12, 13, 14, 15,
40  16, 17, 18, 19, 20, 21, 22, 23,
41  24, 25, 26, 27, 28, 29, 30, 31,
42  32, 33, 34, 35, 36, 37, 38, 39,
43  40, 41, 42, 43, 44, 45, 46, 47,
44  48, 49, 50, 51, 52, 53, 54, 55,
45  -1, -1, -1, -1, -1, -1, -1, -1,
46  56
47 };
48 
49 static int
51 {
52  if (regno >= 0 && regno < 56)
53  return 0;
54  else if (regno == 64)
55  return 0;
56  else
57  return 1;
58 }
59 
60 static int
62 {
63  if (regno >= 0 && regno < 56)
64  return 0;
65  else if (regno == 64)
66  return 0;
67  else
68  return 1;
69 }
70 
71 static uint64_t tile_breakpoint = 0x400b3cae70166000ULL;
72 #define tile_breakpoint_len 8
73 
74 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
75 
76 static const gdb_byte *
77 tile_sw_breakpoint_from_kind (int kind, int *size)
78 {
79  *size = tile_breakpoint_len;
80  return (const gdb_byte *) &tile_breakpoint;
81 }
82 
83 static int
85 {
86  uint64_t insn;
87 
88  (*the_target->read_memory) (where, (unsigned char *) &insn, 8);
89  if (insn == tile_breakpoint)
90  return 1;
91 
92  /* If necessary, recognize more trap instructions here. GDB only uses the
93  one. */
94  return 0;
95 }
96 
97 static void
98 tile_fill_gregset (struct regcache *regcache, void *buf)
99 {
100  int i;
101 
102  for (i = 0; i < tile_num_regs; i++)
103  if (tile_regmap[i] != -1)
104  collect_register (regcache, i, ((uint_reg_t *) buf) + tile_regmap[i]);
105 }
106 
107 static void
108 tile_store_gregset (struct regcache *regcache, const void *buf)
109 {
110  int i;
111 
112  for (i = 0; i < tile_num_regs; i++)
113  if (tile_regmap[i] != -1)
114  supply_register (regcache, i, ((uint_reg_t *) buf) + tile_regmap[i]);
115 }
116 
117 static struct regset_info tile_regsets[] =
118 {
119  { PTRACE_GETREGS, PTRACE_SETREGS, 0, tile_num_regs * 8,
120  GENERAL_REGS, tile_fill_gregset, tile_store_gregset },
121  NULL_REGSET
122 };
123 
124 static struct regsets_info tile_regsets_info =
125  {
126  tile_regsets, /* regsets */
127  0, /* num_regsets */
128  NULL, /* disabled_regsets */
129  };
130 
132  {
134  tile_regmap,
135  };
136 
137 static struct regs_info regs_info =
138  {
139  NULL, /* regset_bitmap */
142  };
143 
144 static const struct regs_info *
146 {
147  return &regs_info;
148 }
149 
150 static void
152 {
153  int pid = pid_of (current_thread);
154  unsigned int machine;
155  int is_elf64 = linux_pid_exe_is_elf_64_file (pid, &machine);
156 
157  if (sizeof (void *) == 4)
158  if (is_elf64 > 0)
159  error (_("Can't debug 64-bit process with 32-bit GDBserver"));
160 
161  if (!is_elf64)
163  else
165 }
166 
167 /* Support for hardware single step. */
168 
169 static int
171 {
172  return 1;
173 }
174 
175 
177 {
182  NULL,
185  NULL, /* breakpoint_kind_from_pc */
187  NULL,
188  0,
190  NULL, /* supports_z_point_type */
191  NULL, /* insert_point */
192  NULL, /* remove_point */
193  NULL, /* stopped_by_watchpoint */
194  NULL, /* stopped_data_address */
195  NULL, /* collect_ptrace_register */
196  NULL, /* supply_ptrace_register */
197  NULL, /* siginfo_fixup */
198  NULL, /* new_process */
199  NULL, /* delete_process */
200  NULL, /* new_thread */
201  NULL, /* delete_thread */
202  NULL, /* new_fork */
203  NULL, /* prepare_to_resume */
204  NULL, /* process_qsupported */
205  NULL, /* supports_tracepoints */
206  NULL, /* get_thread_area */
207  NULL, /* install_fast_tracepoint_jump_pad */
208  NULL, /* emit_ops */
209  NULL, /* get_min_fast_tracepoint_insn_len */
210  NULL, /* supports_range_stepping */
211  NULL, /* breakpoint_kind_from_current_state */
213 };
214 
215 void
217 {
220 
221  initialize_regsets_info (&tile_regsets_info);
222 }
CORE_ADDR linux_get_pc_64bit(struct regcache *regcache)
Definition: linux-low.c:7436
struct thread_info * current_thread
Definition: inferiors.c:28
void collect_register(struct regcache *regcache, int n, void *buf)
Definition: regcache.c:402
bfd_vma CORE_ADDR
Definition: common-types.h:41
static const gdb_byte * tile_sw_breakpoint_from_kind(int kind, int *size)
void linux_set_pc_64bit(struct regcache *regcache, CORE_ADDR pc)
Definition: linux-low.c:7425
#define _(String)
Definition: gdb_locale.h:35
static void tile_arch_setup(void)
static int pid_of(const thread_info *thread)
Definition: gdbthread.h:214
struct target_ops * the_target
Definition: target.c:24
const struct target_desc * tdesc
Definition: inferiors.h:67
static uint64_t tile_breakpoint
struct linux_target_ops the_low_target
static const struct regs_info * tile_regs_info(void)
#define tile_num_regs
static int tile_regmap[]
void initialize_low_arch(void)
const struct target_desc * tdesc_tilegx
static int tile_cannot_fetch_register(int regno)
static struct usrregs_info tile_usrregs_info
static struct regs_info regs_info
struct process_info * current_process(void)
Definition: inferiors.c:210
const struct target_desc * tdesc_tilegx32
static void tile_store_gregset(struct regcache *regcache, const void *buf)
int linux_pid_exe_is_elf_64_file(int pid, unsigned int *machine)
Definition: linux-low.c:400
void init_registers_tilegx32(void)
bfd_byte gdb_byte
Definition: common-types.h:38
static int tile_cannot_store_register(int regno)
int(* read_memory)(CORE_ADDR memaddr, unsigned char *myaddr, int len)
Definition: target.h:166
static int tile_supports_hardware_single_step(void)
void init_registers_tilegx(void)
static struct regset_info tile_regsets[]
#define tile_breakpoint_len
static int tile_breakpoint_at(CORE_ADDR where)
void supply_register(struct regcache *regcache, int n, const void *buf)
Definition: regcache.c:318
void error(const char *fmt,...)
Definition: errors.c:38
static void tile_fill_gregset(struct regcache *regcache, void *buf)
static struct regsets_info tile_regsets_info