gdbserver/linux-low: turn 'arch_setup' into a method
[deliverable/binutils-gdb.git] / gdbserver / linux-sh-low.cc
CommitLineData
0a30fbc4 1/* GNU/Linux/SH specific low level interface, for the remote server for GDB.
b811d2c2 2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
0a30fbc4
DJ
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
a9762ec7 8 the Free Software Foundation; either version 3 of the License, or
0a30fbc4
DJ
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
a9762ec7 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
0a30fbc4
DJ
18
19#include "server.h"
58caa3dc 20#include "linux-low.h"
0a30fbc4 21
ef0478f6
TBA
22/* Linux target op definitions for the SH architecture. */
23
24class sh_target : public linux_process_target
25{
26public:
27
797bcff5
TBA
28protected:
29
30 void low_arch_setup () override;
ef0478f6
TBA
31};
32
33/* The singleton target ops object. */
34
35static sh_target the_sh_target;
36
d05b4ac3
UW
37/* Defined in auto-generated file reg-sh.c. */
38void init_registers_sh (void);
3aee8918 39extern const struct target_desc *tdesc_sh;
d05b4ac3 40
0a30fbc4
DJ
41#ifdef HAVE_SYS_REG_H
42#include <sys/reg.h>
43#endif
44
45#include <asm/ptrace.h>
46
2ec06d2e 47#define sh_num_regs 41
0a30fbc4
DJ
48
49/* Currently, don't check/send MQ. */
2ec06d2e 50static int sh_regmap[] = {
0a30fbc4
DJ
51 0, 4, 8, 12, 16, 20, 24, 28,
52 32, 36, 40, 44, 48, 52, 56, 60,
53
54 REG_PC*4, REG_PR*4, REG_GBR*4, -1,
55 REG_MACH*4, REG_MACL*4, REG_SR*4,
56 REG_FPUL*4, REG_FPSCR*4,
57
c8a86edf
DJ
58 REG_FPREG0*4+0, REG_FPREG0*4+4, REG_FPREG0*4+8, REG_FPREG0*4+12,
59 REG_FPREG0*4+16, REG_FPREG0*4+20, REG_FPREG0*4+24, REG_FPREG0*4+28,
60 REG_FPREG0*4+32, REG_FPREG0*4+36, REG_FPREG0*4+40, REG_FPREG0*4+44,
61 REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60,
0a30fbc4
DJ
62};
63
2ec06d2e
DJ
64static int
65sh_cannot_store_register (int regno)
0a30fbc4
DJ
66{
67 return 0;
68}
69
2ec06d2e
DJ
70static int
71sh_cannot_fetch_register (int regno)
0a30fbc4
DJ
72{
73 return 0;
74}
75
0d62e5e8
DJ
76/* Correct in either endianness, obviously. */
77static const unsigned short sh_breakpoint = 0xc3c3;
78#define sh_breakpoint_len 2
79
dd373349
AT
80/* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
81
82static const gdb_byte *
83sh_sw_breakpoint_from_kind (int kind, int *size)
84{
85 *size = sh_breakpoint_len;
86 return (const gdb_byte *) &sh_breakpoint;
87}
88
0d62e5e8
DJ
89static int
90sh_breakpoint_at (CORE_ADDR where)
91{
92 unsigned short insn;
93
52405d85 94 the_target->read_memory (where, (unsigned char *) &insn, 2);
0d62e5e8
DJ
95 if (insn == sh_breakpoint)
96 return 1;
97
98 /* If necessary, recognize more trap instructions here. GDB only uses the
99 one. */
100 return 0;
101}
102
7d00775e
AT
103/* Support for hardware single step. */
104
105static int
106sh_supports_hardware_single_step (void)
107{
108 return 1;
109}
110
0d37add9
DJ
111/* Provide only a fill function for the general register set. ps_lgetregs
112 will use this for NPTL support. */
113
442ea881 114static void sh_fill_gregset (struct regcache *regcache, void *buf)
0d37add9
DJ
115{
116 int i;
117
118 for (i = 0; i < 23; i++)
119 if (sh_regmap[i] != -1)
442ea881 120 collect_register (regcache, i, (char *) buf + sh_regmap[i]);
0d37add9
DJ
121}
122
3aee8918 123static struct regset_info sh_regsets[] = {
1570b33e 124 { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL },
50bc912a 125 NULL_REGSET
0d37add9
DJ
126};
127
3aee8918
PA
128static struct regsets_info sh_regsets_info =
129 {
130 sh_regsets, /* regsets */
131 0, /* num_regsets */
132 NULL, /* disabled_regsets */
133 };
134
135static struct usrregs_info sh_usrregs_info =
136 {
137 sh_num_regs,
138 sh_regmap,
139 };
140
141static struct regs_info regs_info =
142 {
143 NULL, /* regset_bitmap */
144 &sh_usrregs_info,
145 &sh_regsets_info
146 };
147
148static const struct regs_info *
149sh_regs_info (void)
150{
151 return &regs_info;
152}
153
797bcff5
TBA
154void
155sh_target::low_arch_setup ()
3aee8918
PA
156{
157 current_process ()->tdesc = tdesc_sh;
158}
159
2ec06d2e 160struct linux_target_ops the_low_target = {
3aee8918 161 sh_regs_info,
2ec06d2e
DJ
162 sh_cannot_fetch_register,
163 sh_cannot_store_register,
c14dfd32 164 NULL, /* fetch_register */
276d4552
YQ
165 linux_get_pc_32bit,
166 linux_set_pc_32bit,
dd373349
AT
167 NULL, /* breakpoint_kind_from_pc */
168 sh_sw_breakpoint_from_kind,
0d62e5e8
DJ
169 NULL,
170 0,
171 sh_breakpoint_at,
7d00775e
AT
172 NULL, /* supports_z_point_type */
173 NULL, /* insert_point */
174 NULL, /* remove_point */
175 NULL, /* stopped_by_watchpoint */
176 NULL, /* stopped_data_address */
177 NULL, /* collect_ptrace_register */
178 NULL, /* supply_ptrace_register */
179 NULL, /* siginfo_fixup */
180 NULL, /* new_process */
04ec7890 181 NULL, /* delete_process */
7d00775e 182 NULL, /* new_thread */
466eecee 183 NULL, /* delete_thread */
7d00775e
AT
184 NULL, /* new_fork */
185 NULL, /* prepare_to_resume */
186 NULL, /* process_qsupported */
187 NULL, /* supports_tracepoints */
188 NULL, /* get_thread_area */
189 NULL, /* install_fast_tracepoint_jump_pad */
190 NULL, /* emit_ops */
191 NULL, /* get_min_fast_tracepoint_insn_len */
192 NULL, /* supports_range_stepping */
193 NULL, /* breakpoint_kind_from_current_state */
194 sh_supports_hardware_single_step,
2ec06d2e 195};
3aee8918 196
ef0478f6
TBA
197/* The linux target ops object. */
198
199linux_process_target *the_linux_target = &the_sh_target;
200
3aee8918
PA
201void
202initialize_low_arch (void)
203{
204 init_registers_sh ();
205
206 initialize_regsets_info (&sh_regsets_info);
207}
This page took 1.353056 seconds and 4 git commands to generate.