Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | /* Copyright (C) 2007-2020 Free Software Foundation, Inc. |
68070c10 PA |
2 | |
3 | This file is part of GDB. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 7 | the Free Software Foundation; either version 3 of the License, or |
68070c10 PA |
8 | (at your option) any later version. |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
68070c10 PA |
17 | |
18 | #include "server.h" | |
19 | #include "win32-low.h" | |
20 | ||
4834dad0 TT |
21 | using namespace windows_nat; |
22 | ||
34b34921 PA |
23 | #ifndef CONTEXT_FLOATING_POINT |
24 | #define CONTEXT_FLOATING_POINT 0 | |
25 | #endif | |
26 | ||
d05b4ac3 UW |
27 | /* Defined in auto-generated file reg-arm.c. */ |
28 | void init_registers_arm (void); | |
3aee8918 | 29 | extern const struct target_desc *tdesc_arm; |
d05b4ac3 | 30 | |
68070c10 | 31 | static void |
e56f8ccb | 32 | arm_get_thread_context (windows_thread_info *th) |
68070c10 | 33 | { |
34b34921 PA |
34 | th->context.ContextFlags = \ |
35 | CONTEXT_FULL | \ | |
36 | CONTEXT_FLOATING_POINT; | |
37 | ||
38 | GetThreadContext (th->h, &th->context); | |
39 | } | |
40 | ||
68070c10 PA |
41 | #define context_offset(x) ((int)&(((CONTEXT *)NULL)->x)) |
42 | static const int mappings[] = { | |
43 | context_offset (R0), | |
44 | context_offset (R1), | |
45 | context_offset (R2), | |
46 | context_offset (R3), | |
47 | context_offset (R4), | |
48 | context_offset (R5), | |
49 | context_offset (R6), | |
50 | context_offset (R7), | |
51 | context_offset (R8), | |
52 | context_offset (R9), | |
53 | context_offset (R10), | |
54 | context_offset (R11), | |
55 | context_offset (R12), | |
56 | context_offset (Sp), | |
57 | context_offset (Lr), | |
58 | context_offset (Pc), | |
59 | -1, /* f0 */ | |
60 | -1, /* f1 */ | |
61 | -1, /* f2 */ | |
62 | -1, /* f3 */ | |
63 | -1, /* f4 */ | |
64 | -1, /* f5 */ | |
65 | -1, /* f6 */ | |
66 | -1, /* f7 */ | |
67 | -1, /* fps */ | |
68 | context_offset (Psr), | |
69 | }; | |
70 | #undef context_offset | |
71 | ||
34b34921 PA |
72 | /* Return a pointer into a CONTEXT field indexed by gdb register number. |
73 | Return a pointer to an dummy register holding zero if there is no | |
74 | corresponding CONTEXT field for the given register number. */ | |
75 | static char * | |
76 | regptr (CONTEXT* c, int r) | |
77 | { | |
78 | if (mappings[r] < 0) | |
79 | { | |
80 | static ULONG zero; | |
81 | /* Always force value to zero, in case the user tried to write | |
82 | to this register before. */ | |
83 | zero = 0; | |
84 | return (char *) &zero; | |
85 | } | |
86 | else | |
87 | return (char *) c + mappings[r]; | |
88 | } | |
89 | ||
90 | /* Fetch register from gdbserver regcache data. */ | |
91 | static void | |
442ea881 | 92 | arm_fetch_inferior_register (struct regcache *regcache, |
e56f8ccb | 93 | windows_thread_info *th, int r) |
34b34921 PA |
94 | { |
95 | char *context_offset = regptr (&th->context, r); | |
442ea881 | 96 | supply_register (regcache, r, context_offset); |
34b34921 PA |
97 | } |
98 | ||
99 | /* Store a new register value into the thread context of TH. */ | |
100 | static void | |
442ea881 | 101 | arm_store_inferior_register (struct regcache *regcache, |
e56f8ccb | 102 | windows_thread_info *th, int r) |
34b34921 | 103 | { |
442ea881 | 104 | collect_register (regcache, r, regptr (&th->context, r)); |
34b34921 PA |
105 | } |
106 | ||
3aee8918 PA |
107 | static void |
108 | arm_arch_setup (void) | |
109 | { | |
110 | init_registers_arm (); | |
111 | win32_tdesc = tdesc_arm; | |
112 | } | |
113 | ||
7d186bc0 HD |
114 | /* Implement win32_target_ops "num_regs" method. */ |
115 | ||
116 | static int | |
117 | arm_num_regs (void) | |
118 | { | |
119 | return sizeof (mappings) / sizeof (mappings[0]), | |
120 | } | |
121 | ||
34b34921 | 122 | /* Correct in either endianness. We do not support Thumb yet. */ |
c5674cf1 | 123 | static const unsigned long arm_wince_breakpoint = 0xe6000010; |
34b34921 | 124 | #define arm_wince_breakpoint_len 4 |
68070c10 | 125 | |
d6225aff TT |
126 | /* Implement win32_target_ops "get_pc" method. */ |
127 | ||
128 | static CORE_ADDR | |
129 | arm_win32_get_pc (struct regcache *regcache) | |
130 | { | |
131 | uint32_t pc; | |
132 | ||
133 | collect_register_by_name (regcache, "pc", &pc); | |
134 | return (CORE_ADDR) pc; | |
135 | } | |
136 | ||
137 | /* Implement win32_target_ops "set_pc" method. */ | |
138 | ||
139 | static void | |
140 | arm_win32_set_pc (struct regcache *regcache, CORE_ADDR pc) | |
141 | { | |
142 | uint32_t newpc = pc; | |
143 | ||
144 | supply_register_by_name (regcache, "pc", &newpc); | |
145 | } | |
146 | ||
68070c10 | 147 | struct win32_target_ops the_low_target = { |
3aee8918 | 148 | arm_arch_setup, |
7d186bc0 | 149 | arm_num_regs, |
68070c10 | 150 | NULL, /* initial_stuff */ |
34b34921 | 151 | arm_get_thread_context, |
a2abc7de | 152 | NULL, /* prepare_to_resume */ |
34b34921 PA |
153 | NULL, /* thread_added */ |
154 | arm_fetch_inferior_register, | |
155 | arm_store_inferior_register, | |
68070c10 | 156 | NULL, /* single_step */ |
34b34921 PA |
157 | (const unsigned char *) &arm_wince_breakpoint, |
158 | arm_wince_breakpoint_len, | |
e54e5929 | 159 | 0, |
d6225aff TT |
160 | arm_win32_get_pc, |
161 | arm_win32_set_pc, | |
aa5ca48f | 162 | /* Watchpoint related functions. See target.h for comments. */ |
802e8e6d | 163 | NULL, /* supports_z_point_type */ |
aa5ca48f DE |
164 | NULL, /* insert_point */ |
165 | NULL, /* remove_point */ | |
166 | NULL, /* stopped_by_watchpoint */ | |
167 | NULL /* stopped_data_address */ | |
68070c10 | 168 | }; |