GDBserver
win32-arm-low.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2015 Free Software Foundation, Inc.
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
7  the Free Software Foundation; either version 3 of the License, or
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
16  along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 
18 #include "server.h"
19 #include "win32-low.h"
20 
21 #ifndef CONTEXT_FLOATING_POINT
22 #define CONTEXT_FLOATING_POINT 0
23 #endif
24 
25 /* Defined in auto-generated file reg-arm.c. */
26 void init_registers_arm (void);
27 extern const struct target_desc *tdesc_arm;
28 
29 static void
31 {
32  th->context.ContextFlags = \
33  CONTEXT_FULL | \
34  CONTEXT_FLOATING_POINT;
35 
36  GetThreadContext (th->h, &th->context);
37 }
38 
39 #define context_offset(x) ((int)&(((CONTEXT *)NULL)->x))
40 static const int mappings[] = {
41  context_offset (R0),
42  context_offset (R1),
43  context_offset (R2),
44  context_offset (R3),
45  context_offset (R4),
46  context_offset (R5),
47  context_offset (R6),
48  context_offset (R7),
49  context_offset (R8),
50  context_offset (R9),
51  context_offset (R10),
52  context_offset (R11),
53  context_offset (R12),
54  context_offset (Sp),
55  context_offset (Lr),
56  context_offset (Pc),
57  -1, /* f0 */
58  -1, /* f1 */
59  -1, /* f2 */
60  -1, /* f3 */
61  -1, /* f4 */
62  -1, /* f5 */
63  -1, /* f6 */
64  -1, /* f7 */
65  -1, /* fps */
66  context_offset (Psr),
67 };
68 #undef context_offset
69 
70 /* Return a pointer into a CONTEXT field indexed by gdb register number.
71  Return a pointer to an dummy register holding zero if there is no
72  corresponding CONTEXT field for the given register number. */
73 static char *
74 regptr (CONTEXT* c, int r)
75 {
76  if (mappings[r] < 0)
77  {
78  static ULONG zero;
79  /* Always force value to zero, in case the user tried to write
80  to this register before. */
81  zero = 0;
82  return (char *) &zero;
83  }
84  else
85  return (char *) c + mappings[r];
86 }
87 
88 /* Fetch register from gdbserver regcache data. */
89 static void
91  win32_thread_info *th, int r)
92 {
93  char *context_offset = regptr (&th->context, r);
94  supply_register (regcache, r, context_offset);
95 }
96 
97 /* Store a new register value into the thread context of TH. */
98 static void
100  win32_thread_info *th, int r)
101 {
102  collect_register (regcache, r, regptr (&th->context, r));
103 }
104 
105 static void
107 {
110 }
111 
112 /* Correct in either endianness. We do not support Thumb yet. */
113 static const unsigned long arm_wince_breakpoint = 0xe6000010;
114 #define arm_wince_breakpoint_len 4
115 
116 struct win32_target_ops the_low_target = {
118  sizeof (mappings) / sizeof (mappings[0]),
119  NULL, /* initial_stuff */
121  NULL, /* prepare_to_resume */
122  NULL, /* thread_added */
125  NULL, /* single_step */
126  (const unsigned char *) &arm_wince_breakpoint,
128  /* Watchpoint related functions. See target.h for comments. */
129  NULL, /* supports_z_point_type */
130  NULL, /* insert_point */
131  NULL, /* remove_point */
132  NULL, /* stopped_by_watchpoint */
133  NULL /* stopped_data_address */
134 };
void collect_register(struct regcache *regcache, int n, void *buf)
Definition: regcache.c:414
#define arm_wince_breakpoint_len
static void arm_fetch_inferior_register(struct regcache *regcache, win32_thread_info *th, int r)
Definition: win32-arm-low.c:90
static const unsigned long arm_wince_breakpoint
static char * regptr(CONTEXT *c, int r)
Definition: win32-arm-low.c:74
static const int mappings[]
Definition: win32-arm-low.c:40
#define context_offset(x)
Definition: win32-arm-low.c:39
static void arm_get_thread_context(win32_thread_info *th)
Definition: win32-arm-low.c:30
static void arm_arch_setup(void)
static void arm_store_inferior_register(struct regcache *regcache, win32_thread_info *th, int r)
Definition: win32-arm-low.c:99
void init_registers_arm(void)
const struct target_desc * win32_tdesc
Definition: win32-low.c:93
CONTEXT context
Definition: win32-low.h:49
const struct target_desc * tdesc_arm
void supply_register(struct regcache *regcache, int n, const void *buf)
Definition: regcache.c:330