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-2015 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 static CORE_ADDR
63 {
64  unsigned long pc;
65  collect_register_by_name (regcache, "pc", &pc);
66  return pc;
67 }
68 
69 static void
71 {
72  unsigned long newpc = pc;
73  supply_register_by_name (regcache, "pc", &newpc);
74 }
75 
76 /* Correct in either endianness, obviously. */
77 static const unsigned short sh_breakpoint = 0xc3c3;
78 #define sh_breakpoint_len 2
79 
80 static int
82 {
83  unsigned short insn;
84 
85  (*the_target->read_memory) (where, (unsigned char *) &insn, 2);
86  if (insn == sh_breakpoint)
87  return 1;
88 
89  /* If necessary, recognize more trap instructions here. GDB only uses the
90  one. */
91  return 0;
92 }
93 
94 /* Provide only a fill function for the general register set. ps_lgetregs
95  will use this for NPTL support. */
96 
97 static void sh_fill_gregset (struct regcache *regcache, void *buf)
98 {
99  int i;
100 
101  for (i = 0; i < 23; i++)
102  if (sh_regmap[i] != -1)
103  collect_register (regcache, i, (char *) buf + sh_regmap[i]);
104 }
105 
106 static struct regset_info sh_regsets[] = {
107  { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL },
108  { 0, 0, 0, -1, -1, NULL, NULL }
109 };
110 
111 static struct regsets_info sh_regsets_info =
112  {
113  sh_regsets, /* regsets */
114  0, /* num_regsets */
115  NULL, /* disabled_regsets */
116  };
117 
118 static struct usrregs_info sh_usrregs_info =
119  {
120  sh_num_regs,
121  sh_regmap,
122  };
123 
124 static struct regs_info regs_info =
125  {
126  NULL, /* regset_bitmap */
128  &sh_regsets_info
129  };
130 
131 static const struct regs_info *
133 {
134  return &regs_info;
135 }
136 
137 static void
139 {
141 }
142 
143 struct linux_target_ops the_low_target = {
145  sh_regs_info,
148  NULL, /* fetch_register */
149  sh_get_pc,
150  sh_set_pc,
151  (const unsigned char *) &sh_breakpoint,
153  NULL,
154  0,
156 };
157 
158 void
160 {
162 
163  initialize_regsets_info (&sh_regsets_info);
164 }
void collect_register(struct regcache *regcache, int n, void *buf)
Definition: regcache.c:414
void initialize_low_arch(void)
Definition: linux-sh-low.c:159
const struct target_desc * tdesc_sh
bfd_vma CORE_ADDR
Definition: common-types.h:41
void supply_register_by_name(struct regcache *regcache, const char *name, const void *buf)
Definition: regcache.c:405
static struct regset_info sh_regsets[]
Definition: linux-sh-low.c:106
static int sh_cannot_fetch_register(int regno)
Definition: linux-sh-low.c:56
static void sh_arch_setup(void)
Definition: linux-sh-low.c:138
struct target_ops * the_target
Definition: target.c:24
const struct target_desc * tdesc
Definition: inferiors.h:69
static int sh_breakpoint_at(CORE_ADDR where)
Definition: linux-sh-low.c:81
void collect_register_by_name(struct regcache *regcache, const char *name, void *buf)
Definition: regcache.c:430
static struct usrregs_info sh_usrregs_info
Definition: linux-sh-low.c:118
static const struct regs_info * sh_regs_info(void)
Definition: linux-sh-low.c:132
#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:124
#define sh_breakpoint_len
Definition: linux-sh-low.c:78
struct process_info * current_process(void)
Definition: inferiors.c:356
static CORE_ADDR sh_get_pc(struct regcache *regcache)
Definition: linux-sh-low.c:62
static void sh_set_pc(struct regcache *regcache, CORE_ADDR pc)
Definition: linux-sh-low.c:70
static const unsigned short sh_breakpoint
Definition: linux-sh-low.c:77
int(* read_memory)(CORE_ADDR memaddr, unsigned char *myaddr, int len)
Definition: target.h:160
static void sh_fill_gregset(struct regcache *regcache, void *buf)
Definition: linux-sh-low.c:97
static struct regsets_info sh_regsets_info
Definition: linux-sh-low.c:111
void init_registers_sh(void)
static int sh_cannot_store_register(int regno)
Definition: linux-sh-low.c:50