Commit | Line | Data |
---|---|---|
0a30fbc4 | 1 | /* GNU/Linux/SH specific low level interface, for the remote server for GDB. |
28e7fd62 | 2 | Copyright (C) 1995-2013 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 | |
d05b4ac3 UW |
22 | /* Defined in auto-generated file reg-sh.c. */ |
23 | void init_registers_sh (void); | |
24 | ||
0a30fbc4 DJ |
25 | #ifdef HAVE_SYS_REG_H |
26 | #include <sys/reg.h> | |
27 | #endif | |
28 | ||
29 | #include <asm/ptrace.h> | |
30 | ||
2ec06d2e | 31 | #define sh_num_regs 41 |
0a30fbc4 DJ |
32 | |
33 | /* Currently, don't check/send MQ. */ | |
2ec06d2e | 34 | static int sh_regmap[] = { |
0a30fbc4 DJ |
35 | 0, 4, 8, 12, 16, 20, 24, 28, |
36 | 32, 36, 40, 44, 48, 52, 56, 60, | |
37 | ||
38 | REG_PC*4, REG_PR*4, REG_GBR*4, -1, | |
39 | REG_MACH*4, REG_MACL*4, REG_SR*4, | |
40 | REG_FPUL*4, REG_FPSCR*4, | |
41 | ||
c8a86edf DJ |
42 | REG_FPREG0*4+0, REG_FPREG0*4+4, REG_FPREG0*4+8, REG_FPREG0*4+12, |
43 | REG_FPREG0*4+16, REG_FPREG0*4+20, REG_FPREG0*4+24, REG_FPREG0*4+28, | |
44 | REG_FPREG0*4+32, REG_FPREG0*4+36, REG_FPREG0*4+40, REG_FPREG0*4+44, | |
45 | REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60, | |
0a30fbc4 DJ |
46 | }; |
47 | ||
2ec06d2e DJ |
48 | static int |
49 | sh_cannot_store_register (int regno) | |
0a30fbc4 DJ |
50 | { |
51 | return 0; | |
52 | } | |
53 | ||
2ec06d2e DJ |
54 | static int |
55 | sh_cannot_fetch_register (int regno) | |
0a30fbc4 DJ |
56 | { |
57 | return 0; | |
58 | } | |
59 | ||
0d62e5e8 | 60 | static CORE_ADDR |
442ea881 | 61 | sh_get_pc (struct regcache *regcache) |
0d62e5e8 DJ |
62 | { |
63 | unsigned long pc; | |
442ea881 | 64 | collect_register_by_name (regcache, "pc", &pc); |
0d62e5e8 DJ |
65 | return pc; |
66 | } | |
67 | ||
68 | static void | |
442ea881 | 69 | sh_set_pc (struct regcache *regcache, CORE_ADDR pc) |
0d62e5e8 DJ |
70 | { |
71 | unsigned long newpc = pc; | |
442ea881 | 72 | supply_register_by_name (regcache, "pc", &newpc); |
0d62e5e8 DJ |
73 | } |
74 | ||
75 | /* Correct in either endianness, obviously. */ | |
76 | static const unsigned short sh_breakpoint = 0xc3c3; | |
77 | #define sh_breakpoint_len 2 | |
78 | ||
79 | static int | |
80 | sh_breakpoint_at (CORE_ADDR where) | |
81 | { | |
82 | unsigned short insn; | |
83 | ||
f450004a | 84 | (*the_target->read_memory) (where, (unsigned char *) &insn, 2); |
0d62e5e8 DJ |
85 | if (insn == sh_breakpoint) |
86 | return 1; | |
87 | ||
88 | /* If necessary, recognize more trap instructions here. GDB only uses the | |
89 | one. */ | |
90 | return 0; | |
91 | } | |
92 | ||
0d37add9 DJ |
93 | /* Provide only a fill function for the general register set. ps_lgetregs |
94 | will use this for NPTL support. */ | |
95 | ||
442ea881 | 96 | static void sh_fill_gregset (struct regcache *regcache, void *buf) |
0d37add9 DJ |
97 | { |
98 | int i; | |
99 | ||
100 | for (i = 0; i < 23; i++) | |
101 | if (sh_regmap[i] != -1) | |
442ea881 | 102 | collect_register (regcache, i, (char *) buf + sh_regmap[i]); |
0d37add9 DJ |
103 | } |
104 | ||
105 | struct regset_info target_regsets[] = { | |
1570b33e L |
106 | { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL }, |
107 | { 0, 0, 0, -1, -1, NULL, NULL } | |
0d37add9 DJ |
108 | }; |
109 | ||
2ec06d2e | 110 | struct linux_target_ops the_low_target = { |
d05b4ac3 | 111 | init_registers_sh, |
2ec06d2e DJ |
112 | sh_num_regs, |
113 | sh_regmap, | |
1faeff08 | 114 | NULL, |
2ec06d2e DJ |
115 | sh_cannot_fetch_register, |
116 | sh_cannot_store_register, | |
c14dfd32 | 117 | NULL, /* fetch_register */ |
0d62e5e8 DJ |
118 | sh_get_pc, |
119 | sh_set_pc, | |
f450004a | 120 | (const unsigned char *) &sh_breakpoint, |
0d62e5e8 DJ |
121 | sh_breakpoint_len, |
122 | NULL, | |
123 | 0, | |
124 | sh_breakpoint_at, | |
2ec06d2e | 125 | }; |