OSDN Git Service

* win32-arm-low.c (arm_wince_breakpoint): Fix typo.
[pf3gnuchains/pf3gnuchains3x.git] / gdb / gdbserver / win32-arm-low.c
1 /* Copyright (C) 2007 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 2 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, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor,
18    Boston, MA 02110-1301, USA.  */
19
20 #include "server.h"
21 #include "win32-low.h"
22
23 #ifndef CONTEXT_FLOATING_POINT
24 #define CONTEXT_FLOATING_POINT 0
25 #endif
26
27 static void
28 arm_get_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event)
29 {
30   th->context.ContextFlags = \
31     CONTEXT_FULL | \
32     CONTEXT_FLOATING_POINT;
33
34   GetThreadContext (th->h, &th->context);
35 }
36
37 static void
38 arm_set_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event)
39 {
40   SetThreadContext (th->h, &th->context);
41 }
42
43 #define context_offset(x) ((int)&(((CONTEXT *)NULL)->x))
44 static const int mappings[] = {
45   context_offset (R0),
46   context_offset (R1),
47   context_offset (R2),
48   context_offset (R3),
49   context_offset (R4),
50   context_offset (R5),
51   context_offset (R6),
52   context_offset (R7),
53   context_offset (R8),
54   context_offset (R9),
55   context_offset (R10),
56   context_offset (R11),
57   context_offset (R12),
58   context_offset (Sp),
59   context_offset (Lr),
60   context_offset (Pc),
61   -1, /* f0 */
62   -1, /* f1 */
63   -1, /* f2 */
64   -1, /* f3 */
65   -1, /* f4 */
66   -1, /* f5 */
67   -1, /* f6 */
68   -1, /* f7 */
69   -1, /* fps */
70   context_offset (Psr),
71 };
72 #undef context_offset
73
74 /* Return a pointer into a CONTEXT field indexed by gdb register number.
75    Return a pointer to an dummy register holding zero if there is no
76    corresponding CONTEXT field for the given register number.  */
77 static char *
78 regptr (CONTEXT* c, int r)
79 {
80   if (mappings[r] < 0)
81   {
82     static ULONG zero;
83     /* Always force value to zero, in case the user tried to write
84        to this register before.  */
85     zero = 0;
86     return (char *) &zero;
87   }
88   else
89     return (char *) c + mappings[r];
90 }
91
92 /* Fetch register from gdbserver regcache data.  */
93 static void
94 arm_fetch_inferior_register (win32_thread_info *th, int r)
95 {
96   char *context_offset = regptr (&th->context, r);
97   supply_register (r, context_offset);
98 }
99
100 /* Store a new register value into the thread context of TH.  */
101 static void
102 arm_store_inferior_register (win32_thread_info *th, int r)
103 {
104   collect_register (r, regptr (&th->context, r));
105 }
106
107 /* Correct in either endianness.  We do not support Thumb yet.  */
108 static const unsigned long arm_wince_breakpoint = 0xe6000010;
109 #define arm_wince_breakpoint_len 4
110
111 struct win32_target_ops the_low_target = {
112   sizeof (mappings) / sizeof (mappings[0]),
113   NULL, /* initial_stuff */
114   arm_get_thread_context,
115   arm_set_thread_context,
116   NULL, /* thread_added */
117   arm_fetch_inferior_register,
118   arm_store_inferior_register,
119   NULL, /* single_step */
120   (const unsigned char *) &arm_wince_breakpoint,
121   arm_wince_breakpoint_len,
122   "arm" /* arch_string */
123 };