gdbserver/linux-low: turn 'regs_info' 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
aa8d21c9
TBA
28 const regs_info *get_regs_info () override;
29
797bcff5
TBA
30protected:
31
32 void low_arch_setup () override;
ef0478f6
TBA
33};
34
35/* The singleton target ops object. */
36
37static sh_target the_sh_target;
38
d05b4ac3
UW
39/* Defined in auto-generated file reg-sh.c. */
40void init_registers_sh (void);
3aee8918 41extern const struct target_desc *tdesc_sh;
d05b4ac3 42
0a30fbc4
DJ
43#ifdef HAVE_SYS_REG_H
44#include <sys/reg.h>
45#endif
46
47#include <asm/ptrace.h>
48
2ec06d2e 49#define sh_num_regs 41
0a30fbc4
DJ
50
51/* Currently, don't check/send MQ. */
2ec06d2e 52static int sh_regmap[] = {
0a30fbc4
DJ
53 0, 4, 8, 12, 16, 20, 24, 28,
54 32, 36, 40, 44, 48, 52, 56, 60,
55
56 REG_PC*4, REG_PR*4, REG_GBR*4, -1,
57 REG_MACH*4, REG_MACL*4, REG_SR*4,
58 REG_FPUL*4, REG_FPSCR*4,
59
c8a86edf
DJ
60 REG_FPREG0*4+0, REG_FPREG0*4+4, REG_FPREG0*4+8, REG_FPREG0*4+12,
61 REG_FPREG0*4+16, REG_FPREG0*4+20, REG_FPREG0*4+24, REG_FPREG0*4+28,
62 REG_FPREG0*4+32, REG_FPREG0*4+36, REG_FPREG0*4+40, REG_FPREG0*4+44,
63 REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60,
0a30fbc4
DJ
64};
65
2ec06d2e
DJ
66static int
67sh_cannot_store_register (int regno)
0a30fbc4
DJ
68{
69 return 0;
70}
71
2ec06d2e
DJ
72static int
73sh_cannot_fetch_register (int regno)
0a30fbc4
DJ
74{
75 return 0;
76}
77
0d62e5e8
DJ
78/* Correct in either endianness, obviously. */
79static const unsigned short sh_breakpoint = 0xc3c3;
80#define sh_breakpoint_len 2
81
dd373349
AT
82/* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
83
84static const gdb_byte *
85sh_sw_breakpoint_from_kind (int kind, int *size)
86{
87 *size = sh_breakpoint_len;
88 return (const gdb_byte *) &sh_breakpoint;
89}
90
0d62e5e8
DJ
91static int
92sh_breakpoint_at (CORE_ADDR where)
93{
94 unsigned short insn;
95
52405d85 96 the_target->read_memory (where, (unsigned char *) &insn, 2);
0d62e5e8
DJ
97 if (insn == sh_breakpoint)
98 return 1;
99
100 /* If necessary, recognize more trap instructions here. GDB only uses the
101 one. */
102 return 0;
103}
104
7d00775e
AT
105/* Support for hardware single step. */
106
107static int
108sh_supports_hardware_single_step (void)
109{
110 return 1;
111}
112
0d37add9
DJ
113/* Provide only a fill function for the general register set. ps_lgetregs
114 will use this for NPTL support. */
115
442ea881 116static void sh_fill_gregset (struct regcache *regcache, void *buf)
0d37add9
DJ
117{
118 int i;
119
120 for (i = 0; i < 23; i++)
121 if (sh_regmap[i] != -1)
442ea881 122 collect_register (regcache, i, (char *) buf + sh_regmap[i]);
0d37add9
DJ
123}
124
3aee8918 125static struct regset_info sh_regsets[] = {
1570b33e 126 { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL },
50bc912a 127 NULL_REGSET
0d37add9
DJ
128};
129
3aee8918
PA
130static struct regsets_info sh_regsets_info =
131 {
132 sh_regsets, /* regsets */
133 0, /* num_regsets */
134 NULL, /* disabled_regsets */
135 };
136
137static struct usrregs_info sh_usrregs_info =
138 {
139 sh_num_regs,
140 sh_regmap,
141 };
142
aa8d21c9 143static struct regs_info myregs_info =
3aee8918
PA
144 {
145 NULL, /* regset_bitmap */
146 &sh_usrregs_info,
147 &sh_regsets_info
148 };
149
aa8d21c9
TBA
150const regs_info *
151sh_target::get_regs_info ()
3aee8918 152{
aa8d21c9 153 return &myregs_info;
3aee8918
PA
154}
155
797bcff5
TBA
156void
157sh_target::low_arch_setup ()
3aee8918
PA
158{
159 current_process ()->tdesc = tdesc_sh;
160}
161
2ec06d2e 162struct linux_target_ops the_low_target = {
2ec06d2e
DJ
163 sh_cannot_fetch_register,
164 sh_cannot_store_register,
c14dfd32 165 NULL, /* fetch_register */
276d4552
YQ
166 linux_get_pc_32bit,
167 linux_set_pc_32bit,
dd373349
AT
168 NULL, /* breakpoint_kind_from_pc */
169 sh_sw_breakpoint_from_kind,
0d62e5e8
DJ
170 NULL,
171 0,
172 sh_breakpoint_at,
7d00775e
AT
173 NULL, /* supports_z_point_type */
174 NULL, /* insert_point */
175 NULL, /* remove_point */
176 NULL, /* stopped_by_watchpoint */
177 NULL, /* stopped_data_address */
178 NULL, /* collect_ptrace_register */
179 NULL, /* supply_ptrace_register */
180 NULL, /* siginfo_fixup */
181 NULL, /* new_process */
04ec7890 182 NULL, /* delete_process */
7d00775e 183 NULL, /* new_thread */
466eecee 184 NULL, /* delete_thread */
7d00775e
AT
185 NULL, /* new_fork */
186 NULL, /* prepare_to_resume */
187 NULL, /* process_qsupported */
188 NULL, /* supports_tracepoints */
189 NULL, /* get_thread_area */
190 NULL, /* install_fast_tracepoint_jump_pad */
191 NULL, /* emit_ops */
192 NULL, /* get_min_fast_tracepoint_insn_len */
193 NULL, /* supports_range_stepping */
194 NULL, /* breakpoint_kind_from_current_state */
195 sh_supports_hardware_single_step,
2ec06d2e 196};
3aee8918 197
ef0478f6
TBA
198/* The linux target ops object. */
199
200linux_process_target *the_linux_target = &the_sh_target;
201
3aee8918
PA
202void
203initialize_low_arch (void)
204{
205 init_registers_sh ();
206
207 initialize_regsets_info (&sh_regsets_info);
208}
This page took 2.337982 seconds and 4 git commands to generate.