Browse Source
* arm-wince-tdep.c: New. * config/arm/wince.mt (DEPRECATED_TM_FILE): Use tm-arm.h. (MT_CFLAGS): Delete. (TM_CLIBS): Delete. (TDEPFILES): Add arm-wince-tdep.o, corelow.o, solib.o, solib-legacy.o, solib-svr4.o, and remove wince.o. * configure.tgt (arm*-*-mingw32ce*): Add. * signals/signals.c [HAVE_SIGNAL_H]: Check. (do_target_signal_to_host): Silence 'not used' warning. * config/arm/tm-wince.h: Remove. gdb/gdbserver/ * gdbserver/configure.ac: Add errno checking. (AC_CHECK_HEADERS): Add errno.h, fcntl.h, signal.h, sys/file.h and malloc.h. (AC_CHECK_DECLS): Add perror. (srv_mingwce): Handle. * gdbserver/configure.srv (i[34567]86-*-cygwin*): Add win32-i386-low.o to srv_tgtobj. (i[34567]86-*-mingw*): Likewise. (arm*-*-mingw32ce*): Add case. * gdbreplay.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_ERRNO_H, HAVE_MALLOC_H]: Check. [__MINGW32CE__] (strerror): New function. [__MINGW32CE__] (errno): Define to GetLastError. [__MINGW32CE__] (COUNTOF): New macro. (remote_open): Remove extra close call. * mem-break.c (delete_breakpoint_at): New function. * mem-break.h (delete_breakpoint_at): Declare. * remote-utils.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_UNISTD_H, HAVE_ERRNO_H]: Check. [USE_WIN32API] (read, write): Add char* casts. * server.c [HAVE_UNISTD_H, HAVE_SIGNAL_H]: Check. * server.h: Include wincecompat.h on Windows CE. [HAVE_ERRNO_H]: Check. (perror): Declare if not declared. * utils.c: Add stdlib.h, errno.h and malloc.h includes. (perror_with_name): Remove errno declaration. * wincecompat.h: New. * wincecompat.c: New. * win32-low.h: New. * win32-arm-low.c: New. * win32-i386-low.c: New. (win32-low.c): Include mem-break.h and win32-low.h, and winnt.h. (OUTMSG2): Make it safe. (_T): New macro. (COUNTOF): New macro. (NUM_REGS): Get it from the low target. (CONTEXT_EXTENDED_REGISTERS, CONTEXT_FLOATING_POINT, CONTEXT_DEBUG_REGISTERS): Add fallbacks to 0. (thread_rec): Let low target handle debug registers. (child_add_thread): Likewise. (child_init_thread_list): Likewise. (continue_one_thread): Likewise. (regptr): New. (do_child_fetch_inferior_registers): Move to ... * win32-i386-low.c: ... here, and rename to ... (do_fetch_inferior_registers): ... this. * win32-low.c (child_fetch_inferior_registers): Go through the low target. (do_child_store_inferior_registers): Use regptr. (strwinerror): New function. (win32_create_inferior): Handle Windows CE. Use strwinerror instead of strerror on Windows error codes. Add program to the error output. Don't close the main thread handle on Windows CE. (win32_attach): Use coredll.dll on Windows CE. (win32_kill): Close current process and current thread handles. (win32_detach): Use coredll.dll on Windows CE. (win32_resume): Let low target handle debug registers, and step request. (handle_exception): Add/Remove initial breakpoint. Avoid non-existant WSTOPSIG on Windows CE. (win32_read_inferior_memory): Cast to remove warning. (win32_arch_string): Go through the low target. (initialize_low): Call set_breakpoint_data with the low target's breakpoint. * win32-low.c (dr, FLAG_TRACE_BIT, FCS_REGNUM, FOP_REGNUM, mappings): Move to ... * win32-i386-low.c: ... here. * win32-low.c (win32_thread_info): Move to ... * win32-low.h: ... here. * Makefile.in (SFILES): Add win32-low.c, win32-i386-low.c, win32-arm-low.c and wincecompat.c. (all:): Add $EXEEXT. (install-only:): Likewise. (gdbserver:): Likewise. (gdbreplay:): Likewise. * config.in: Regenerate. * configure: Regenerate.drow-reverse-20070409-branch
23 changed files with 938 additions and 43 deletions
@ -0,0 +1,84 @@ |
|||
/* Target-dependent code for Windows CE running on ARM processors,
|
|||
for GDB. |
|||
|
|||
Copyright (C) 2007 Free Software Foundation, Inc. |
|||
|
|||
This file is part of GDB. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|||
Boston, MA 02110-1301, USA. */ |
|||
|
|||
#include "defs.h" |
|||
#include "osabi.h" |
|||
#include "solib-svr4.h" |
|||
#include "target.h" |
|||
|
|||
#include "gdb_string.h" |
|||
|
|||
#include "arm-tdep.h" |
|||
|
|||
static const char arm_wince_le_breakpoint[] = { 0x10, 0x00, 0x00, 0xe6 }; |
|||
|
|||
/* Description of the longjmp buffer. */ |
|||
#define ARM_WINCE_JB_ELEMENT_SIZE INT_REGISTER_SIZE |
|||
#define ARM_WINCE_JB_PC 21 |
|||
|
|||
static void |
|||
arm_wince_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
|||
{ |
|||
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
|||
|
|||
tdep->arm_breakpoint = arm_wince_le_breakpoint; |
|||
tdep->arm_breakpoint_size = sizeof (arm_wince_le_breakpoint); |
|||
tdep->struct_return = pcc_struct_return; |
|||
|
|||
tdep->fp_model = ARM_FLOAT_SOFT_VFP; |
|||
|
|||
tdep->jb_pc = ARM_WINCE_JB_PC; |
|||
tdep->jb_elt_size = ARM_WINCE_JB_ELEMENT_SIZE; |
|||
|
|||
/* On ARM WinCE char defaults to signed. */ |
|||
set_gdbarch_char_signed (gdbarch, 1); |
|||
|
|||
set_solib_svr4_fetch_link_map_offsets |
|||
(gdbarch, svr4_ilp32_fetch_link_map_offsets); |
|||
|
|||
/* Shared library handling. */ |
|||
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); |
|||
} |
|||
|
|||
static enum gdb_osabi |
|||
arm_wince_osabi_sniffer (bfd *abfd) |
|||
{ |
|||
const char *target_name = bfd_get_target (abfd); |
|||
|
|||
if (strcmp (target_name, "pei-arm-wince-little") == 0) |
|||
return GDB_OSABI_WINCE; |
|||
|
|||
return GDB_OSABI_UNKNOWN; |
|||
} |
|||
|
|||
/* Provide a prototype to silence -Wmissing-prototypes. */ |
|||
void _initialize_arm_wince_tdep (void); |
|||
|
|||
void |
|||
_initialize_arm_wince_tdep (void) |
|||
{ |
|||
gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_coff_flavour, |
|||
arm_wince_osabi_sniffer); |
|||
|
|||
gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_WINCE, |
|||
arm_wince_init_abi); |
|||
} |
|||
@ -1,5 +1,4 @@ |
|||
# Target: Acorn RISC machine (ARM) with simulator |
|||
TDEPFILES= arm-tdep.o wince.o |
|||
DEPRECATED_TM_FILE= tm-wince.h |
|||
MT_CFLAGS=-DARM -U_X86_ -U_M_IX86 -U__i386__ -U__i486__ -U__i586__ -U__i686__ -DUNICODE -D_WIN32_WCE -DWINCE_STUB='"${target_alias}-stub.exe"' |
|||
TM_CLIBS=-lrapi |
|||
# Target: ARM based machine running Windows CE (win32) |
|||
DEPRECATED_TM_FILE= tm-arm.h |
|||
TDEPFILES= arm-tdep.o arm-wince-tdep.o corelow.o \ |
|||
solib.o solib-legacy.o solib-svr4.o |
|||
|
|||
@ -0,0 +1,76 @@ |
|||
/* Copyright (C) 2007 Free Software Foundation, Inc.
|
|||
|
|||
This file is part of GDB. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|||
Boston, MA 02110-1301, USA. */ |
|||
|
|||
#include "server.h" |
|||
#include "win32-low.h" |
|||
|
|||
/* Fetch register(s) from gdbserver regcache data. */ |
|||
static void |
|||
do_fetch_inferior_registers (win32_thread_info *th, int r) |
|||
{ |
|||
char *context_offset = regptr (&th->context, r); |
|||
supply_register (r, context_offset); |
|||
} |
|||
|
|||
#define context_offset(x) ((int)&(((CONTEXT *)NULL)->x)) |
|||
static const int mappings[] = { |
|||
context_offset (R0), |
|||
context_offset (R1), |
|||
context_offset (R2), |
|||
context_offset (R3), |
|||
context_offset (R4), |
|||
context_offset (R5), |
|||
context_offset (R6), |
|||
context_offset (R7), |
|||
context_offset (R8), |
|||
context_offset (R9), |
|||
context_offset (R10), |
|||
context_offset (R11), |
|||
context_offset (R12), |
|||
context_offset (Sp), |
|||
context_offset (Lr), |
|||
context_offset (Pc), |
|||
-1, /* f0 */ |
|||
-1, /* f1 */ |
|||
-1, /* f2 */ |
|||
-1, /* f3 */ |
|||
-1, /* f4 */ |
|||
-1, /* f5 */ |
|||
-1, /* f6 */ |
|||
-1, /* f7 */ |
|||
-1, /* fps */ |
|||
context_offset (Psr), |
|||
}; |
|||
#undef context_offset |
|||
|
|||
static const unsigned char arm_wince_le_breakpoint[] = |
|||
{ 0x10, 0x00, 0x00, 0xe6 }; |
|||
|
|||
struct win32_target_ops the_low_target = { |
|||
mappings, |
|||
sizeof (mappings) / sizeof (mappings[0]), |
|||
NULL, /* initial_stuff */ |
|||
NULL, /* store_debug_registers */ |
|||
NULL, /* load_debug_registers */ |
|||
do_fetch_inferior_registers, |
|||
NULL, /* single_step */ |
|||
arm_wince_le_breakpoint, |
|||
sizeof (arm_wince_le_breakpoint) / sizeof (arm_wince_le_breakpoint[0]), |
|||
"arm" /* arch_string */ |
|||
}; |
|||
@ -0,0 +1,152 @@ |
|||
/* Copyright (C) 2007 Free Software Foundation, Inc.
|
|||
|
|||
This file is part of GDB. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|||
Boston, MA 02110-1301, USA. */ |
|||
|
|||
#include "server.h" |
|||
#include "win32-low.h" |
|||
|
|||
#define FCS_REGNUM 27 |
|||
#define FOP_REGNUM 31 |
|||
|
|||
#define FLAG_TRACE_BIT 0x100 |
|||
|
|||
static unsigned dr[8]; |
|||
|
|||
static void |
|||
initial_stuff (void) |
|||
{ |
|||
memset (&dr, 0, sizeof (dr)); |
|||
} |
|||
|
|||
static void |
|||
store_debug_registers (win32_thread_info *th) |
|||
{ |
|||
dr[0] = th->context.Dr0; |
|||
dr[1] = th->context.Dr1; |
|||
dr[2] = th->context.Dr2; |
|||
dr[3] = th->context.Dr3; |
|||
dr[6] = th->context.Dr6; |
|||
dr[7] = th->context.Dr7; |
|||
} |
|||
|
|||
static void |
|||
load_debug_registers (win32_thread_info *th) |
|||
{ |
|||
th->context.Dr0 = dr[0]; |
|||
th->context.Dr1 = dr[1]; |
|||
th->context.Dr2 = dr[2]; |
|||
th->context.Dr3 = dr[3]; |
|||
/* th->context.Dr6 = dr[6];
|
|||
FIXME: should we set dr6 also ?? */ |
|||
th->context.Dr7 = dr[7]; |
|||
} |
|||
|
|||
/* Fetch register(s) from gdbserver regcache data. */ |
|||
static void |
|||
do_fetch_inferior_registers (win32_thread_info *th, int r) |
|||
{ |
|||
char *context_offset = regptr (&th->context, r); |
|||
|
|||
long l; |
|||
if (r == FCS_REGNUM) |
|||
{ |
|||
l = *((long *) context_offset) & 0xffff; |
|||
supply_register (r, (char *) &l); |
|||
} |
|||
else if (r == FOP_REGNUM) |
|||
{ |
|||
l = (*((long *) context_offset) >> 16) & ((1 << 11) - 1); |
|||
supply_register (r, (char *) &l); |
|||
} |
|||
else |
|||
supply_register (r, context_offset); |
|||
} |
|||
|
|||
static void |
|||
single_step (win32_thread_info *th) |
|||
{ |
|||
th->context.EFlags |= FLAG_TRACE_BIT; |
|||
} |
|||
|
|||
/* An array of offset mappings into a Win32 Context structure.
|
|||
This is a one-to-one mapping which is indexed by gdb's register |
|||
numbers. It retrieves an offset into the context structure where |
|||
the 4 byte register is located. |
|||
An offset value of -1 indicates that Win32 does not provide this |
|||
register in it's CONTEXT structure. In this case regptr will return |
|||
a pointer into a dummy register. */ |
|||
#define context_offset(x) ((int)&(((CONTEXT *)NULL)->x)) |
|||
static const int mappings[] = { |
|||
context_offset (Eax), |
|||
context_offset (Ecx), |
|||
context_offset (Edx), |
|||
context_offset (Ebx), |
|||
context_offset (Esp), |
|||
context_offset (Ebp), |
|||
context_offset (Esi), |
|||
context_offset (Edi), |
|||
context_offset (Eip), |
|||
context_offset (EFlags), |
|||
context_offset (SegCs), |
|||
context_offset (SegSs), |
|||
context_offset (SegDs), |
|||
context_offset (SegEs), |
|||
context_offset (SegFs), |
|||
context_offset (SegGs), |
|||
context_offset (FloatSave.RegisterArea[0 * 10]), |
|||
context_offset (FloatSave.RegisterArea[1 * 10]), |
|||
context_offset (FloatSave.RegisterArea[2 * 10]), |
|||
context_offset (FloatSave.RegisterArea[3 * 10]), |
|||
context_offset (FloatSave.RegisterArea[4 * 10]), |
|||
context_offset (FloatSave.RegisterArea[5 * 10]), |
|||
context_offset (FloatSave.RegisterArea[6 * 10]), |
|||
context_offset (FloatSave.RegisterArea[7 * 10]), |
|||
context_offset (FloatSave.ControlWord), |
|||
context_offset (FloatSave.StatusWord), |
|||
context_offset (FloatSave.TagWord), |
|||
context_offset (FloatSave.ErrorSelector), |
|||
context_offset (FloatSave.ErrorOffset), |
|||
context_offset (FloatSave.DataSelector), |
|||
context_offset (FloatSave.DataOffset), |
|||
context_offset (FloatSave.ErrorSelector), |
|||
/* XMM0-7 */ |
|||
context_offset (ExtendedRegisters[10 * 16]), |
|||
context_offset (ExtendedRegisters[11 * 16]), |
|||
context_offset (ExtendedRegisters[12 * 16]), |
|||
context_offset (ExtendedRegisters[13 * 16]), |
|||
context_offset (ExtendedRegisters[14 * 16]), |
|||
context_offset (ExtendedRegisters[15 * 16]), |
|||
context_offset (ExtendedRegisters[16 * 16]), |
|||
context_offset (ExtendedRegisters[17 * 16]), |
|||
/* MXCSR */ |
|||
context_offset (ExtendedRegisters[24]) |
|||
}; |
|||
#undef context_offset |
|||
|
|||
struct win32_target_ops the_low_target = { |
|||
mappings, |
|||
sizeof (mappings) / sizeof (mappings[0]), |
|||
initial_stuff, |
|||
store_debug_registers, |
|||
load_debug_registers, |
|||
do_fetch_inferior_registers, |
|||
single_step, |
|||
(const char*)NULL, /* breakpoint */ |
|||
0, /* breakpoint_len */ |
|||
"i386" /* arch_string */ |
|||
}; |
|||
@ -0,0 +1,87 @@ |
|||
/* Internal interfaces for the Win32 specific target code for gdbserver.
|
|||
Copyright (C) 2007 Free Software Foundation, Inc. |
|||
|
|||
This file is part of GDB. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|||
Boston, MA 02110-1301, USA. */ |
|||
|
|||
#include <windows.h> |
|||
|
|||
/* Thread information structure used to track extra information about
|
|||
each thread. */ |
|||
typedef struct win32_thread_info |
|||
{ |
|||
DWORD tid; |
|||
HANDLE h; |
|||
int suspend_count; |
|||
CONTEXT context; |
|||
} win32_thread_info; |
|||
|
|||
struct win32_target_ops |
|||
{ |
|||
/* An array of offset mappings into a Win32 Context structure.
|
|||
This is a one-to-one mapping which is indexed by gdb's register |
|||
numbers. It retrieves an offset into the context structure where |
|||
the 4 byte register is located. |
|||
An offset value of -1 indicates that Win32 does not provide this |
|||
register in it's CONTEXT structure. In this case regptr will return |
|||
a pointer into a dummy register. */ |
|||
const int *regmap; |
|||
|
|||
/* The number of elements of regmap. */ |
|||
int num_regs; |
|||
|
|||
void (*initial_stuff) (void); |
|||
|
|||
void (*store_debug_registers) (win32_thread_info *); |
|||
void (*load_debug_registers) (win32_thread_info *); |
|||
|
|||
/* Fetch register(s) from gdbserver regcache data. */ |
|||
void (*fetch_inferior_registers) (win32_thread_info *th, int r); |
|||
|
|||
void (*single_step) (win32_thread_info *th); |
|||
|
|||
const unsigned char *breakpoint; |
|||
int breakpoint_len; |
|||
|
|||
/* What string to report to GDB when it asks for the architecture,
|
|||
or NULL not to answer. */ |
|||
const char *arch_string; |
|||
}; |
|||
|
|||
extern struct win32_target_ops the_low_target; |
|||
|
|||
/* in win32-low.c */ |
|||
|
|||
/* Return a pointer into a CONTEXT field indexed by gdb register number.
|
|||
Return a pointer to an dummy register holding zero if there is no |
|||
corresponding CONTEXT field for the given register number. */ |
|||
extern char * regptr (CONTEXT* c, int r); |
|||
|
|||
/* Map the Windows error number in ERROR to a locale-dependent error
|
|||
message string and return a pointer to it. Typically, the values |
|||
for ERROR come from GetLastError. |
|||
|
|||
The string pointed to shall not be modified by the application, |
|||
but may be overwritten by a subsequent call to strwinerror |
|||
|
|||
The strwinerror function does not change the current setting |
|||
of GetLastError. */ |
|||
extern char * strwinerror (DWORD error); |
|||
|
|||
/* in wincecompat.c */ |
|||
|
|||
extern void to_back_slashes (char *); |
|||
@ -0,0 +1,41 @@ |
|||
/* Compatibility routines for Windows CE.
|
|||
Copyright (C) 2007 Free Software Foundation, Inc. |
|||
|
|||
This file is part of GDB. |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|||
Boston, MA 02110-1301, USA. */ |
|||
|
|||
#include "server.h" |
|||
|
|||
#include <stdio.h> |
|||
#include <windows.h> |
|||
|
|||
void |
|||
perror (const char *s) |
|||
{ |
|||
if (s && *s) |
|||
fprintf (stderr, "%s: %s\n", s, strwinerror (GetLastError ())); |
|||
else |
|||
fprintf (stderr, "%s\n", strwinerror (GetLastError ())); |
|||
} |
|||
|
|||
void |
|||
to_back_slashes (char *path) |
|||
{ |
|||
for (; *path; ++path) |
|||
if ('/' == *path) |
|||
*path = '\\'; |
|||
} |
|||
Loading…
Reference in new issue