GDBserver
linux-sh-low.c
Go to the documentation of this file.
1 /* GNU/Linux/SH specific low level interface, for the remote server for GDB.
2  Copyright (C) 1995-2018 Free Software Foundation, Inc.
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
8  the Free Software Foundation; either version 3 of the License, or
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
17  along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 
19 #include "server.h"
20 #include "linux-low.h"
21 
22 /* Defined in auto-generated file reg-sh.c. */
23 void init_registers_sh (void);
24 extern const struct target_desc *tdesc_sh;
25 
26 #ifdef HAVE_SYS_REG_H
27 #include <sys/reg.h>
28 #endif
29 
30 #include <asm/ptrace.h>
31 
32 #define sh_num_regs 41
33 
34 /* Currently, don't check/send MQ. */
35 static int sh_regmap[] = {
36  0, 4, 8, 12, 16, 20, 24, 28,
37  32, 36, 40, 44, 48, 52, 56, 60,
38 
39  REG_PC*4, REG_PR*4, REG_GBR*4, -1,
40  REG_MACH*4, REG_MACL*4, REG_SR*4,
41  REG_FPUL*4, REG_FPSCR*4,
42 
43  REG_FPREG0*4+0, REG_FPREG0*4+4, REG_FPREG0*4+8, REG_FPREG0*4+12,
44  REG_FPREG0*4+16, REG_FPREG0*4+20, REG_FPREG0*4+24, REG_FPREG0*4+28,
45  REG_FPREG0*4+32, REG_FPREG0*4+36, REG_FPREG0*4+40, REG_FPREG0*4+44,
46  REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60,
47 };
48 
49 static int
51 {
52  return 0;
53 }
54 
55 static int
57 {
58  return 0;
59 }
60 
61 /* Correct in either endianness, obviously. */
62 static const unsigned short sh_breakpoint = 0xc3c3;
63 #define sh_breakpoint_len 2
64 
65 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
66 
67 static const gdb_byte *
68 sh_sw_breakpoint_from_kind (int kind, int *size)
69 {
70  *size = sh_breakpoint_len;
71  return (const gdb_byte *) &sh_breakpoint;
72 }
73 
74 static int
76 {
77  unsigned short insn;
78 
79  (*the_target->read_memory) (where, (unsigned char *) &insn, 2);
80  if (insn == sh_breakpoint)
81  return 1;
82 
83  /* If necessary, recognize more trap instructions here. GDB only uses the
84  one. */
85  return 0;
86 }
87 
88 /* Support for hardware single step. */
89 
90 static int
92 {
93  return 1;
94 }
95 
96 /* Provide only a fill function for the general register set. ps_lgetregs
97  will use this for NPTL support. */
98 
99 static void sh_fill_gregset (struct regcache *regcache, void *buf)
100 {
101  int i;
102 
103  for (i = 0; i < 23; i++)
104  if (sh_regmap[i] != -1)
105  collect_register (regcache, i, (char *) buf + sh_regmap[i]);
106 }
107 
108 static struct regset_info sh_regsets[] = {
109  { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL },
110  NULL_REGSET
111 };
112 
113 static struct regsets_info sh_regsets_info =
114  {
115  sh_regsets, /* regsets */
116  0, /* num_regsets */
117  NULL, /* disabled_regsets */
118  };
119 
121  {
122  sh_num_regs,
123  sh_regmap,
124  };
125 
126 static struct regs_info regs_info =
127  {
128  NULL, /* regset_bitmap */
131  };
132 
133 static const struct regs_info *
135 {
136  return &regs_info;
137 }
138 
139 static void
141 {
143 }
144 
147  sh_regs_info,
150  NULL, /* fetch_register */
153  NULL, /* breakpoint_kind_from_pc */
155  NULL,
156  0,
158  NULL, /* supports_z_point_type */
159  NULL, /* insert_point */
160  NULL, /* remove_point */
161  NULL, /* stopped_by_watchpoint */
162  NULL, /* stopped_data_address */
163  NULL, /* collect_ptrace_register */
164  NULL, /* supply_ptrace_register */
165  NULL, /* siginfo_fixup */
166  NULL, /* new_process */
167  NULL, /* delete_process */
168  NULL, /* new_thread */
169  NULL, /* delete_thread */
170  NULL, /* new_fork */
171  NULL, /* prepare_to_resume */
172  NULL, /* process_qsupported */
173  NULL, /* supports_tracepoints */
174  NULL, /* get_thread_area */
175  NULL, /* install_fast_tracepoint_jump_pad */
176  NULL, /* emit_ops */
177  NULL, /* get_min_fast_tracepoint_insn_len */
178  NULL, /* supports_range_stepping */
179  NULL, /* breakpoint_kind_from_current_state */
181 };
182 
183 void
185 {
187 
188  initialize_regsets_info (&sh_regsets_info);
189 }
void collect_register(struct regcache *regcache, int n, void *buf)
Definition: regcache.c:402
void initialize_low_arch(void)
Definition: linux-sh-low.c:184
const struct target_desc * tdesc_sh
bfd_vma CORE_ADDR
Definition: common-types.h:41
static struct regset_info sh_regsets[]
Definition: linux-sh-low.c:108
static int sh_cannot_fetch_register(int regno)
Definition: linux-sh-low.c:56
static int sh_supports_hardware_single_step(void)
Definition: linux-sh-low.c:91
static void sh_arch_setup(void)
Definition: linux-sh-low.c:140
struct target_ops * the_target
Definition: target.c:24
const struct target_desc * tdesc
Definition: inferiors.h:67
struct linux_target_ops the_low_target
Definition: linux-sh-low.c:145
CORE_ADDR linux_get_pc_32bit(struct regcache *regcache)
Definition: linux-low.c:7411
static int sh_breakpoint_at(CORE_ADDR where)
Definition: linux-sh-low.c:75
static struct usrregs_info sh_usrregs_info
Definition: linux-sh-low.c:120
static const struct regs_info * sh_regs_info(void)
Definition: linux-sh-low.c:134
#define sh_num_regs
Definition: linux-sh-low.c:32
static int sh_regmap[]
Definition: linux-sh-low.c:35
static struct regs_info regs_info
Definition: linux-sh-low.c:126
#define sh_breakpoint_len
Definition: linux-sh-low.c:63
struct process_info * current_process(void)
Definition: inferiors.c:210
void linux_set_pc_32bit(struct regcache *regcache, CORE_ADDR pc)
Definition: linux-low.c:7400
bfd_byte gdb_byte
Definition: common-types.h:38
static const unsigned short sh_breakpoint
Definition: linux-sh-low.c:62
int(* read_memory)(CORE_ADDR memaddr, unsigned char *myaddr, int len)
Definition: target.h:166
static const gdb_byte * sh_sw_breakpoint_from_kind(int kind, int *size)
Definition: linux-sh-low.c:68
static void sh_fill_gregset(struct regcache *regcache, void *buf)
Definition: linux-sh-low.c:99
static struct regsets_info sh_regsets_info
Definition: linux-sh-low.c:113
void init_registers_sh(void)
static int sh_cannot_store_register(int regno)
Definition: linux-sh-low.c:50