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