1 /* Target-dependent code for Windows CE running on ARM processors,
4 Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 #include "solib-target.h"
29 #include "gdb_string.h"
33 static const char arm_wince_le_breakpoint
[] = { 0x10, 0x00, 0x00, 0xe6 };
34 static const char arm_wince_thumb_le_breakpoint
[] = { 0xfe, 0xdf };
36 /* Description of the longjmp buffer. */
37 #define ARM_WINCE_JB_ELEMENT_SIZE INT_REGISTER_SIZE
38 #define ARM_WINCE_JB_PC 10
41 arm_pe_skip_trampoline_code (struct frame_info
*frame
, CORE_ADDR pc
)
43 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
44 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
46 struct minimal_symbol
*indsym
;
50 /* The format of an ARM DLL trampoline is:
56 || read_memory_unsigned_integer (pc
+ 0, 4, byte_order
) != 0xe59fc000
57 || read_memory_unsigned_integer (pc
+ 4, 4, byte_order
) != 0xe59cf000)
60 indirect
= read_memory_unsigned_integer (pc
+ 8, 4, byte_order
);
64 indsym
= lookup_minimal_symbol_by_pc (indirect
);
68 symname
= SYMBOL_LINKAGE_NAME (indsym
);
69 if (symname
== NULL
|| strncmp (symname
, "__imp_", 6) != 0)
72 next_pc
= read_memory_unsigned_integer (indirect
, 4, byte_order
);
76 /* Check with the default arm gdbarch_skip_trampoline. */
77 return arm_skip_stub (frame
, pc
);
80 /* GCC emits a call to __gccmain in the prologue of main.
82 The function below examines the code pointed at by PC and checks to
83 see if it corresponds to a call to __gccmain. If so, it returns
84 the address of the instruction following that call. Otherwise, it
88 arm_wince_skip_main_prologue (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
90 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
93 this_instr
= read_memory_unsigned_integer (pc
, 4, byte_order
);
95 /* bl offset <__gccmain> */
96 if ((this_instr
& 0xfff00000) == 0xeb000000)
98 #define sign_extend(V, N) \
99 (((long) (V) ^ (1L << ((N) - 1))) - (1L << ((N) - 1)))
101 long offset
= sign_extend (this_instr
& 0x000fffff, 23) << 2;
102 CORE_ADDR call_dest
= (pc
+ 8 + offset
) & 0xffffffffU
;
103 struct minimal_symbol
*s
= lookup_minimal_symbol_by_pc (call_dest
);
106 && SYMBOL_LINKAGE_NAME (s
) != NULL
107 && strcmp (SYMBOL_LINKAGE_NAME (s
), "__gccmain") == 0)
115 arm_wince_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
117 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
119 tdep
->arm_breakpoint
= arm_wince_le_breakpoint
;
120 tdep
->arm_breakpoint_size
= sizeof (arm_wince_le_breakpoint
);
121 tdep
->thumb_breakpoint
= arm_wince_thumb_le_breakpoint
;
122 tdep
->thumb_breakpoint_size
= sizeof (arm_wince_thumb_le_breakpoint
);
123 tdep
->struct_return
= pcc_struct_return
;
125 tdep
->fp_model
= ARM_FLOAT_SOFT_VFP
;
127 tdep
->jb_pc
= ARM_WINCE_JB_PC
;
128 tdep
->jb_elt_size
= ARM_WINCE_JB_ELEMENT_SIZE
;
130 /* On ARM WinCE char defaults to signed. */
131 set_gdbarch_char_signed (gdbarch
, 1);
133 /* Shared library handling. */
134 set_solib_ops (gdbarch
, &solib_target_so_ops
);
135 set_gdbarch_skip_trampoline_code (gdbarch
, arm_pe_skip_trampoline_code
);
137 /* Single stepping. */
138 set_gdbarch_software_single_step (gdbarch
, arm_software_single_step
);
140 /* Skip call to __gccmain that gcc places in main. */
141 set_gdbarch_skip_main_prologue (gdbarch
, arm_wince_skip_main_prologue
);
143 /* Canonical paths on this target look like `\Windows\coredll.dll',
145 set_gdbarch_has_dos_based_file_system (gdbarch
, 1);
148 static enum gdb_osabi
149 arm_wince_osabi_sniffer (bfd
*abfd
)
151 const char *target_name
= bfd_get_target (abfd
);
153 if (strcmp (target_name
, "pei-arm-wince-little") == 0)
154 return GDB_OSABI_WINCE
;
156 return GDB_OSABI_UNKNOWN
;
159 /* Provide a prototype to silence -Wmissing-prototypes. */
160 void _initialize_arm_wince_tdep (void);
163 _initialize_arm_wince_tdep (void)
165 gdbarch_register_osabi_sniffer (bfd_arch_arm
, bfd_target_coff_flavour
,
166 arm_wince_osabi_sniffer
);
168 gdbarch_register_osabi (bfd_arch_arm
, 0, GDB_OSABI_WINCE
,