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
28 const regs_info
*get_regs_info () override
;
32 void low_arch_setup () override
;
34 bool low_cannot_fetch_register (int regno
) override
;
36 bool low_cannot_store_register (int regno
) override
;
38 bool low_supports_breakpoints () override
;
40 CORE_ADDR
low_get_pc (regcache
*regcache
) override
;
42 void low_set_pc (regcache
*regcache
, CORE_ADDR newpc
) override
;
45 /* The singleton target ops object. */
47 static sh_target the_sh_target
;
50 sh_target::low_supports_breakpoints ()
56 sh_target::low_get_pc (regcache
*regcache
)
58 return linux_get_pc_32bit (regcache
);
62 sh_target::low_set_pc (regcache
*regcache
, CORE_ADDR pc
)
64 linux_set_pc_32bit (regcache
, pc
);
67 /* Defined in auto-generated file reg-sh.c. */
68 void init_registers_sh (void);
69 extern const struct target_desc
*tdesc_sh
;
75 #include <asm/ptrace.h>
77 #define sh_num_regs 41
79 /* Currently, don't check/send MQ. */
80 static int sh_regmap
[] = {
81 0, 4, 8, 12, 16, 20, 24, 28,
82 32, 36, 40, 44, 48, 52, 56, 60,
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,
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,
95 sh_target::low_cannot_store_register (int regno
)
101 sh_target::low_cannot_fetch_register (int regno
)
106 /* Correct in either endianness, obviously. */
107 static const unsigned short sh_breakpoint
= 0xc3c3;
108 #define sh_breakpoint_len 2
110 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
112 static const gdb_byte
*
113 sh_sw_breakpoint_from_kind (int kind
, int *size
)
115 *size
= sh_breakpoint_len
;
116 return (const gdb_byte
*) &sh_breakpoint
;
120 sh_breakpoint_at (CORE_ADDR where
)
124 the_target
->read_memory (where
, (unsigned char *) &insn
, 2);
125 if (insn
== sh_breakpoint
)
128 /* If necessary, recognize more trap instructions here. GDB only uses the
133 /* Support for hardware single step. */
136 sh_supports_hardware_single_step (void)
141 /* Provide only a fill function for the general register set. ps_lgetregs
142 will use this for NPTL support. */
144 static void sh_fill_gregset (struct regcache
*regcache
, void *buf
)
148 for (i
= 0; i
< 23; i
++)
149 if (sh_regmap
[i
] != -1)
150 collect_register (regcache
, i
, (char *) buf
+ sh_regmap
[i
]);
153 static struct regset_info sh_regsets
[] = {
154 { 0, 0, 0, 0, GENERAL_REGS
, sh_fill_gregset
, NULL
},
158 static struct regsets_info sh_regsets_info
=
160 sh_regsets
, /* regsets */
162 NULL
, /* disabled_regsets */
165 static struct usrregs_info sh_usrregs_info
=
171 static struct regs_info myregs_info
=
173 NULL
, /* regset_bitmap */
179 sh_target::get_regs_info ()
185 sh_target::low_arch_setup ()
187 current_process ()->tdesc
= tdesc_sh
;
190 struct linux_target_ops the_low_target
= {
191 sh_sw_breakpoint_from_kind
,
195 NULL
, /* supports_z_point_type */
196 NULL
, /* insert_point */
197 NULL
, /* remove_point */
198 NULL
, /* stopped_by_watchpoint */
199 NULL
, /* stopped_data_address */
200 NULL
, /* collect_ptrace_register */
201 NULL
, /* supply_ptrace_register */
202 NULL
, /* siginfo_fixup */
203 NULL
, /* new_process */
204 NULL
, /* delete_process */
205 NULL
, /* new_thread */
206 NULL
, /* delete_thread */
208 NULL
, /* prepare_to_resume */
209 NULL
, /* process_qsupported */
210 NULL
, /* supports_tracepoints */
211 NULL
, /* get_thread_area */
212 NULL
, /* install_fast_tracepoint_jump_pad */
214 NULL
, /* get_min_fast_tracepoint_insn_len */
215 NULL
, /* supports_range_stepping */
216 sh_supports_hardware_single_step
,
219 /* The linux target ops object. */
221 linux_process_target
*the_linux_target
= &the_sh_target
;
224 initialize_low_arch (void)
226 init_registers_sh ();
228 initialize_regsets_info (&sh_regsets_info
);