1 /* GNU/Linux/TILE-Gx specific low level interface, GDBserver.
3 Copyright (C) 2012-2019 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
21 #include "linux-low.h"
24 #include "nat/gdb_ptrace.h"
26 /* Defined in auto-generated file reg-tilegx.c. */
27 void init_registers_tilegx (void);
28 extern const struct target_desc
*tdesc_tilegx
;
30 /* Defined in auto-generated file reg-tilegx32.c. */
31 void init_registers_tilegx32 (void);
32 extern const struct target_desc
*tdesc_tilegx32
;
34 #define tile_num_regs 65
36 static int tile_regmap
[] =
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,
50 tile_cannot_fetch_register (int regno
)
52 if (regno
>= 0 && regno
< 56)
61 tile_cannot_store_register (int regno
)
63 if (regno
>= 0 && regno
< 56)
71 static uint64_t tile_breakpoint
= 0x400b3cae70166000ULL
;
72 #define tile_breakpoint_len 8
74 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
76 static const gdb_byte
*
77 tile_sw_breakpoint_from_kind (int kind
, int *size
)
79 *size
= tile_breakpoint_len
;
80 return (const gdb_byte
*) &tile_breakpoint
;
84 tile_breakpoint_at (CORE_ADDR where
)
88 (*the_target
->read_memory
) (where
, (unsigned char *) &insn
, 8);
89 if (insn
== tile_breakpoint
)
92 /* If necessary, recognize more trap instructions here. GDB only uses the
98 tile_fill_gregset (struct regcache
*regcache
, void *buf
)
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
]);
108 tile_store_gregset (struct regcache
*regcache
, const void *buf
)
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
]);
117 static struct regset_info tile_regsets
[] =
119 { PTRACE_GETREGS
, PTRACE_SETREGS
, 0, tile_num_regs
* 8,
120 GENERAL_REGS
, tile_fill_gregset
, tile_store_gregset
},
124 static struct regsets_info tile_regsets_info
=
126 tile_regsets
, /* regsets */
128 NULL
, /* disabled_regsets */
131 static struct usrregs_info tile_usrregs_info
=
137 static struct regs_info regs_info
=
139 NULL
, /* regset_bitmap */
144 static const struct regs_info
*
145 tile_regs_info (void)
151 tile_arch_setup (void)
153 int pid
= pid_of (current_thread
);
154 unsigned int machine
;
155 int is_elf64
= linux_pid_exe_is_elf_64_file (pid
, &machine
);
157 if (sizeof (void *) == 4)
159 error (_("Can't debug 64-bit process with 32-bit GDBserver"));
162 current_process ()->tdesc
= tdesc_tilegx32
;
164 current_process ()->tdesc
= tdesc_tilegx
;
167 /* Support for hardware single step. */
170 tile_supports_hardware_single_step (void)
176 struct linux_target_ops the_low_target
=
180 tile_cannot_fetch_register
,
181 tile_cannot_store_register
,
185 NULL
, /* breakpoint_kind_from_pc */
186 tile_sw_breakpoint_from_kind
,
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 */
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 */
209 NULL
, /* get_min_fast_tracepoint_insn_len */
210 NULL
, /* supports_range_stepping */
211 NULL
, /* breakpoint_kind_from_current_state */
212 tile_supports_hardware_single_step
,
216 initialize_low_arch (void)
218 init_registers_tilegx32();
219 init_registers_tilegx();
221 initialize_regsets_info (&tile_regsets_info
);