GDBserver
|
00001 /* Copyright (C) 2007-2013 Free Software Foundation, Inc. 00002 00003 This file is part of GDB. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00017 00018 #include "server.h" 00019 #include "win32-low.h" 00020 00021 #ifndef CONTEXT_FLOATING_POINT 00022 #define CONTEXT_FLOATING_POINT 0 00023 #endif 00024 00025 /* Defined in auto-generated file reg-arm.c. */ 00026 void init_registers_arm (void); 00027 extern const struct target_desc *tdesc_arm; 00028 00029 static void 00030 arm_get_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event) 00031 { 00032 th->context.ContextFlags = \ 00033 CONTEXT_FULL | \ 00034 CONTEXT_FLOATING_POINT; 00035 00036 GetThreadContext (th->h, &th->context); 00037 } 00038 00039 static void 00040 arm_set_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event) 00041 { 00042 SetThreadContext (th->h, &th->context); 00043 } 00044 00045 #define context_offset(x) ((int)&(((CONTEXT *)NULL)->x)) 00046 static const int mappings[] = { 00047 context_offset (R0), 00048 context_offset (R1), 00049 context_offset (R2), 00050 context_offset (R3), 00051 context_offset (R4), 00052 context_offset (R5), 00053 context_offset (R6), 00054 context_offset (R7), 00055 context_offset (R8), 00056 context_offset (R9), 00057 context_offset (R10), 00058 context_offset (R11), 00059 context_offset (R12), 00060 context_offset (Sp), 00061 context_offset (Lr), 00062 context_offset (Pc), 00063 -1, /* f0 */ 00064 -1, /* f1 */ 00065 -1, /* f2 */ 00066 -1, /* f3 */ 00067 -1, /* f4 */ 00068 -1, /* f5 */ 00069 -1, /* f6 */ 00070 -1, /* f7 */ 00071 -1, /* fps */ 00072 context_offset (Psr), 00073 }; 00074 #undef context_offset 00075 00076 /* Return a pointer into a CONTEXT field indexed by gdb register number. 00077 Return a pointer to an dummy register holding zero if there is no 00078 corresponding CONTEXT field for the given register number. */ 00079 static char * 00080 regptr (CONTEXT* c, int r) 00081 { 00082 if (mappings[r] < 0) 00083 { 00084 static ULONG zero; 00085 /* Always force value to zero, in case the user tried to write 00086 to this register before. */ 00087 zero = 0; 00088 return (char *) &zero; 00089 } 00090 else 00091 return (char *) c + mappings[r]; 00092 } 00093 00094 /* Fetch register from gdbserver regcache data. */ 00095 static void 00096 arm_fetch_inferior_register (struct regcache *regcache, 00097 win32_thread_info *th, int r) 00098 { 00099 char *context_offset = regptr (&th->context, r); 00100 supply_register (regcache, r, context_offset); 00101 } 00102 00103 /* Store a new register value into the thread context of TH. */ 00104 static void 00105 arm_store_inferior_register (struct regcache *regcache, 00106 win32_thread_info *th, int r) 00107 { 00108 collect_register (regcache, r, regptr (&th->context, r)); 00109 } 00110 00111 static void 00112 arm_arch_setup (void) 00113 { 00114 init_registers_arm (); 00115 win32_tdesc = tdesc_arm; 00116 } 00117 00118 /* Correct in either endianness. We do not support Thumb yet. */ 00119 static const unsigned long arm_wince_breakpoint = 0xe6000010; 00120 #define arm_wince_breakpoint_len 4 00121 00122 struct win32_target_ops the_low_target = { 00123 arm_arch_setup, 00124 sizeof (mappings) / sizeof (mappings[0]), 00125 NULL, /* initial_stuff */ 00126 arm_get_thread_context, 00127 arm_set_thread_context, 00128 NULL, /* thread_added */ 00129 arm_fetch_inferior_register, 00130 arm_store_inferior_register, 00131 NULL, /* single_step */ 00132 (const unsigned char *) &arm_wince_breakpoint, 00133 arm_wince_breakpoint_len, 00134 /* Watchpoint related functions. See target.h for comments. */ 00135 NULL, /* insert_point */ 00136 NULL, /* remove_point */ 00137 NULL, /* stopped_by_watchpoint */ 00138 NULL /* stopped_data_address */ 00139 };