GDB (xrefs)
Loading...
Searching...
No Matches
arm-wince-tdep.c
Go to the documentation of this file.
1/* Target-dependent code for Windows CE running on ARM processors,
2 for GDB.
3
4 Copyright (C) 2007-2023 Free Software Foundation, Inc.
5
6 This file is part of GDB.
7
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.
12
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.
17
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/>. */
20
21#include "defs.h"
22#include "osabi.h"
23#include "gdbcore.h"
24#include "target.h"
25#include "frame.h"
26
27#include "arch/arm.h"
28#include "arm-tdep.h"
29#include "windows-tdep.h"
30
31static const gdb_byte arm_wince_le_breakpoint[] = { 0x10, 0x00, 0x00, 0xe6 };
32static const gdb_byte arm_wince_thumb_le_breakpoint[] = { 0xfe, 0xdf };
33
34/* Description of the longjmp buffer. */
35#define ARM_WINCE_JB_ELEMENT_SIZE ARM_INT_REGISTER_SIZE
36#define ARM_WINCE_JB_PC 10
37
38static CORE_ADDR
40{
41 struct gdbarch *gdbarch = get_frame_arch (frame);
42 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
43 ULONGEST indirect;
44 struct bound_minimal_symbol indsym;
45 const char *symname;
46 CORE_ADDR next_pc;
47
48 /* The format of an ARM DLL trampoline is:
49
50 ldr ip, [pc]
51 ldr pc, [ip]
52 .dw __imp_<func>
53
54 */
55
56 if (pc == 0
57 || read_memory_unsigned_integer (pc + 0, 4, byte_order) != 0xe59fc000
58 || read_memory_unsigned_integer (pc + 4, 4, byte_order) != 0xe59cf000)
59 return 0;
60
61 indirect = read_memory_unsigned_integer (pc + 8, 4, byte_order);
62 if (indirect == 0)
63 return 0;
64
65 indsym = lookup_minimal_symbol_by_pc (indirect);
66 if (indsym.minsym == NULL)
67 return 0;
68
69 symname = indsym.minsym->linkage_name ();
70 if (symname == NULL || !startswith (symname, "__imp_"))
71 return 0;
72
73 next_pc = read_memory_unsigned_integer (indirect, 4, byte_order);
74 if (next_pc != 0)
75 return next_pc;
76
77 /* Check with the default arm gdbarch_skip_trampoline. */
78 return arm_skip_stub (frame, pc);
79}
80
81/* GCC emits a call to __gccmain in the prologue of main.
82
83 The function below examines the code pointed at by PC and checks to
84 see if it corresponds to a call to __gccmain. If so, it returns
85 the address of the instruction following that call. Otherwise, it
86 simply returns PC. */
87
88static CORE_ADDR
90{
91 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
92 ULONGEST this_instr;
93
94 this_instr = read_memory_unsigned_integer (pc, 4, byte_order);
95
96 /* bl offset <__gccmain> */
97 if ((this_instr & 0xfff00000) == 0xeb000000)
98 {
99#define sign_extend(V, N) \
100 (((long) (V) ^ (1L << ((N) - 1))) - (1L << ((N) - 1)))
101
102 long offset = sign_extend (this_instr & 0x000fffff, 23) << 2;
103 CORE_ADDR call_dest = (pc + 8 + offset) & 0xffffffffU;
105
106 if (s.minsym != NULL
107 && s.minsym->linkage_name () != NULL
108 && strcmp (s.minsym->linkage_name (), "__gccmain") == 0)
109 pc += 4;
110 }
111
112 return pc;
113}
114
115static void
117{
118 arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
119
121
126 tdep->struct_return = pcc_struct_return;
127
128 tdep->fp_model = ARM_FLOAT_SOFT_VFP;
129
130 tdep->jb_pc = ARM_WINCE_JB_PC;
132
133 /* On ARM WinCE char defaults to signed. */
135
136 /* Shared library handling. */
138
139 /* Single stepping. */
141
142 /* Skip call to __gccmain that gcc places in main. */
144}
145
146static enum gdb_osabi
148{
149 const char *target_name = bfd_get_target (abfd);
150
151 if (strcmp (target_name, "pei-arm-wince-little") == 0)
152 return GDB_OSABI_WINCE;
153
154 return GDB_OSABI_UNKNOWN;
155}
156
158void
160{
161 gdbarch_register_osabi_sniffer (bfd_arch_arm, bfd_target_coff_flavour,
163
164 gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_WINCE,
166}
std::vector< CORE_ADDR > arm_software_single_step(struct regcache *regcache)
Definition arm-tdep.c:7283
CORE_ADDR arm_skip_stub(frame_info_ptr frame, CORE_ADDR pc)
Definition arm-tdep.c:9399
@ pcc_struct_return
Definition arm-tdep.h:85
@ ARM_FLOAT_SOFT_VFP
Definition arm-tdep.h:67
static const gdb_byte arm_wince_thumb_le_breakpoint[]
void _initialize_arm_wince_tdep()
#define sign_extend(V, N)
static CORE_ADDR arm_wince_skip_main_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
static enum gdb_osabi arm_wince_osabi_sniffer(bfd *abfd)
#define ARM_WINCE_JB_ELEMENT_SIZE
static CORE_ADDR arm_pe_skip_trampoline_code(frame_info_ptr frame, CORE_ADDR pc)
static void arm_wince_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
#define ARM_WINCE_JB_PC
static const gdb_byte arm_wince_le_breakpoint[]
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition corefile.c:306
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:3027
void set_gdbarch_char_signed(struct gdbarch *gdbarch, int char_signed)
Definition gdbarch.c:1786
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition gdbarch.c:1396
void set_gdbarch_software_single_step(struct gdbarch *gdbarch, gdbarch_software_single_step_ftype *software_single_step)
void set_gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype *skip_trampoline_code)
void set_gdbarch_skip_main_prologue(struct gdbarch *gdbarch, gdbarch_skip_main_prologue_ftype *skip_main_prologue)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
Definition minsyms.c:996
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition osabi.c:146
void gdbarch_register_osabi_sniffer(enum bfd_architecture arch, enum bfd_flavour flavour, enum gdb_osabi(*sniffer_fn)(bfd *))
Definition osabi.c:220
gdb_osabi
Definition osabi.h:25
@ GDB_OSABI_WINCE
Definition osabi.h:36
@ GDB_OSABI_UNKNOWN
Definition osabi.h:26
const gdb_byte * thumb_breakpoint
Definition arm-tdep.h:146
size_t jb_elt_size
Definition arm-tdep.h:159
const gdb_byte * arm_breakpoint
Definition arm-tdep.h:144
int arm_breakpoint_size
Definition arm-tdep.h:145
int thumb_breakpoint_size
Definition arm-tdep.h:147
struct minimal_symbol * minsym
Definition minsyms.h:49
const char * linkage_name() const
Definition symtab.h:460
const char target_name[]
Definition version.c:4
void windows_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)