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