1 /* GNU/Linux/SH specific low level interface, for the remote server for GDB.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
4 This file is part of GDB.
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
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "linux-low.h"
22 /* Linux target op definitions for the SH architecture. */
24 class sh_target
: public linux_process_target
30 /* The singleton target ops object. */
32 static sh_target the_sh_target
;
34 /* Defined in auto-generated file reg-sh.c. */
35 void init_registers_sh (void);
36 extern const struct target_desc
*tdesc_sh
;
42 #include <asm/ptrace.h>
44 #define sh_num_regs 41
46 /* Currently, don't check/send MQ. */
47 static int sh_regmap
[] = {
48 0, 4, 8, 12, 16, 20, 24, 28,
49 32, 36, 40, 44, 48, 52, 56, 60,
51 REG_PC
*4, REG_PR
*4, REG_GBR
*4, -1,
52 REG_MACH
*4, REG_MACL
*4, REG_SR
*4,
53 REG_FPUL
*4, REG_FPSCR
*4,
55 REG_FPREG0
*4+0, REG_FPREG0
*4+4, REG_FPREG0
*4+8, REG_FPREG0
*4+12,
56 REG_FPREG0
*4+16, REG_FPREG0
*4+20, REG_FPREG0
*4+24, REG_FPREG0
*4+28,
57 REG_FPREG0
*4+32, REG_FPREG0
*4+36, REG_FPREG0
*4+40, REG_FPREG0
*4+44,
58 REG_FPREG0
*4+48, REG_FPREG0
*4+52, REG_FPREG0
*4+56, REG_FPREG0
*4+60,
62 sh_cannot_store_register (int regno
)
68 sh_cannot_fetch_register (int regno
)
73 /* Correct in either endianness, obviously. */
74 static const unsigned short sh_breakpoint
= 0xc3c3;
75 #define sh_breakpoint_len 2
77 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
79 static const gdb_byte
*
80 sh_sw_breakpoint_from_kind (int kind
, int *size
)
82 *size
= sh_breakpoint_len
;
83 return (const gdb_byte
*) &sh_breakpoint
;
87 sh_breakpoint_at (CORE_ADDR where
)
91 the_target
->read_memory (where
, (unsigned char *) &insn
, 2);
92 if (insn
== sh_breakpoint
)
95 /* If necessary, recognize more trap instructions here. GDB only uses the
100 /* Support for hardware single step. */
103 sh_supports_hardware_single_step (void)
108 /* Provide only a fill function for the general register set. ps_lgetregs
109 will use this for NPTL support. */
111 static void sh_fill_gregset (struct regcache
*regcache
, void *buf
)
115 for (i
= 0; i
< 23; i
++)
116 if (sh_regmap
[i
] != -1)
117 collect_register (regcache
, i
, (char *) buf
+ sh_regmap
[i
]);
120 static struct regset_info sh_regsets
[] = {
121 { 0, 0, 0, 0, GENERAL_REGS
, sh_fill_gregset
, NULL
},
125 static struct regsets_info sh_regsets_info
=
127 sh_regsets
, /* regsets */
129 NULL
, /* disabled_regsets */
132 static struct usrregs_info sh_usrregs_info
=
138 static struct regs_info regs_info
=
140 NULL
, /* regset_bitmap */
145 static const struct regs_info
*
154 current_process ()->tdesc
= tdesc_sh
;
157 struct linux_target_ops the_low_target
= {
160 sh_cannot_fetch_register
,
161 sh_cannot_store_register
,
162 NULL
, /* fetch_register */
165 NULL
, /* breakpoint_kind_from_pc */
166 sh_sw_breakpoint_from_kind
,
170 NULL
, /* supports_z_point_type */
171 NULL
, /* insert_point */
172 NULL
, /* remove_point */
173 NULL
, /* stopped_by_watchpoint */
174 NULL
, /* stopped_data_address */
175 NULL
, /* collect_ptrace_register */
176 NULL
, /* supply_ptrace_register */
177 NULL
, /* siginfo_fixup */
178 NULL
, /* new_process */
179 NULL
, /* delete_process */
180 NULL
, /* new_thread */
181 NULL
, /* delete_thread */
183 NULL
, /* prepare_to_resume */
184 NULL
, /* process_qsupported */
185 NULL
, /* supports_tracepoints */
186 NULL
, /* get_thread_area */
187 NULL
, /* install_fast_tracepoint_jump_pad */
189 NULL
, /* get_min_fast_tracepoint_insn_len */
190 NULL
, /* supports_range_stepping */
191 NULL
, /* breakpoint_kind_from_current_state */
192 sh_supports_hardware_single_step
,
195 /* The linux target ops object. */
197 linux_process_target
*the_linux_target
= &the_sh_target
;
200 initialize_low_arch (void)
202 init_registers_sh ();
204 initialize_regsets_info (&sh_regsets_info
);