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