2 * Debugger Power PC specific functions
4 * Copyright 2000-2003 Marcus Meissner
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #if defined(__powerpc__)
26 static BOOL
be_ppc_get_addr(HANDLE hThread
, const dbg_ctx_t
*ctx
,
27 enum be_cpu_addr bca
, ADDRESS64
* addr
)
32 return be_cpu_build_addr(hThread
, ctx
, addr
, 0, ctx
->ctx
.Iar
);
34 case be_cpu_addr_stack
:
35 case be_cpu_addr_frame
:
36 dbg_printf("not done\n");
41 static BOOL
be_ppc_get_register_info(int regno
, enum be_cpu_addr
* kind
)
43 dbg_printf("not done\n");
47 static void be_ppc_single_step(dbg_ctx_t
*ctx
, BOOL enable
)
50 # define MSR_SE (1<<10)
52 if (enable
) ctx
->ctx
.Msr
|= MSR_SE
;
53 else ctx
->ctx
.Msr
&= ~MSR_SE
;
56 static void be_ppc_print_context(HANDLE hThread
, const dbg_ctx_t
*ctx
, int all_regs
)
58 dbg_printf("Context printing for PPC not done yet\n");
61 static void be_ppc_print_segment_info(HANDLE hThread
, const dbg_ctx_t
*ctx
)
65 static struct dbg_internal_var be_ppc_ctx
[] =
67 {0, NULL
, 0, dbg_itype_none
}
70 static BOOL
be_ppc_is_step_over_insn(const void* insn
)
72 dbg_printf("not done\n");
76 static BOOL
be_ppc_is_function_return(const void* insn
)
78 dbg_printf("not done\n");
82 static BOOL
be_ppc_is_break_insn(const void* insn
)
84 dbg_printf("not done\n");
88 static BOOL
be_ppc_is_func_call(const void* insn
, ADDRESS64
* callee
)
93 static BOOL
be_ppc_is_jump(const void* insn
, ADDRESS64
* jumpee
)
98 static void be_ppc_disasm_one_insn(ADDRESS64
* addr
, int display
)
101 dbg_printf("Disasm NIY\n");
104 static BOOL
be_ppc_insert_Xpoint(HANDLE hProcess
, const struct be_process_io
* pio
,
105 dbg_ctx_t
*ctx
, enum be_xpoint_type type
,
106 void* addr
, unsigned long* val
, unsigned size
)
113 case be_xpoint_break
:
114 if (!size
) return FALSE
;
115 if (!pio
->read(hProcess
, addr
, val
, 4, &sz
) || sz
!= 4) return FALSE
;
116 xbp
= 0x7d821008; /* 7d 82 10 08 ... in big endian */
117 if (!pio
->write(hProcess
, addr
, &xbp
, 4, &sz
) || sz
!= 4) return FALSE
;
120 dbg_printf("Unknown/unsupported bp type %c\n", type
);
126 static BOOL
be_ppc_remove_Xpoint(HANDLE hProcess
, const struct be_process_io
* pio
,
127 dbg_ctx_t
*ctx
, enum be_xpoint_type type
,
128 void* addr
, unsigned long val
, unsigned size
)
134 case be_xpoint_break
:
135 if (!size
) return FALSE
;
136 if (!pio
->write(hProcess
, addr
, &val
, 4, &sz
) || sz
== 4) return FALSE
;
139 dbg_printf("Unknown/unsupported bp type %c\n", type
);
145 static BOOL
be_ppc_is_watchpoint_set(const dbg_ctx_t
*ctx
, unsigned idx
)
147 dbg_printf("not done\n");
151 static void be_ppc_clear_watchpoint(dbg_ctx_t
*ctx
, unsigned idx
)
153 dbg_printf("not done\n");
156 static int be_ppc_adjust_pc_for_break(dbg_ctx_t
*ctx
, BOOL way
)
158 dbg_printf("not done\n");
162 static BOOL
be_ppc_fetch_integer(const struct dbg_lvalue
* lvalue
, unsigned size
,
163 BOOL is_signed
, LONGLONG
* ret
)
165 dbg_printf("not done\n");
169 static BOOL
be_ppc_fetch_float(const struct dbg_lvalue
* lvalue
, unsigned size
,
172 dbg_printf("not done\n");
176 static BOOL
be_ppc_store_integer(const struct dbg_lvalue
* lvalue
, unsigned size
,
177 BOOL is_signed
, LONGLONG val
)
179 dbg_printf("be_ppc_store_integer: not done\n");
183 static BOOL
be_ppc_get_context(HANDLE thread
, dbg_ctx_t
*ctx
)
185 ctx
->ctx
.ContextFlags
= CONTEXT_ALL
;
186 return GetThreadContext(thread
, &ctx
->ctx
);
189 static BOOL
be_ppc_set_context(HANDLE thread
, const dbg_ctx_t
*ctx
)
191 return SetThreadContext(thread
, &ctx
->ctx
);
194 #define REG(f,n,t,r) {f, n, t, FIELD_OFFSET(CONTEXT, r), sizeof(((CONTEXT*)NULL)->r)}
196 static struct gdb_register be_ppc_gdb_register_map
[] = {
197 REG("core", "r0", NULL
, Gpr0
),
198 REG(NULL
, "r1", NULL
, Gpr1
),
199 REG(NULL
, "r2", NULL
, Gpr2
),
200 REG(NULL
, "r3", NULL
, Gpr3
),
201 REG(NULL
, "r4", NULL
, Gpr4
),
202 REG(NULL
, "r5", NULL
, Gpr5
),
203 REG(NULL
, "r6", NULL
, Gpr6
),
204 REG(NULL
, "r7", NULL
, Gpr7
),
205 REG(NULL
, "r8", NULL
, Gpr8
),
206 REG(NULL
, "r9", NULL
, Gpr9
),
207 REG(NULL
, "r10", NULL
, Gpr10
),
208 REG(NULL
, "r11", NULL
, Gpr11
),
209 REG(NULL
, "r12", NULL
, Gpr12
),
210 REG(NULL
, "r13", NULL
, Gpr13
),
211 REG(NULL
, "r14", NULL
, Gpr14
),
212 REG(NULL
, "r15", NULL
, Gpr15
),
213 REG(NULL
, "r16", NULL
, Gpr16
),
214 REG(NULL
, "r17", NULL
, Gpr17
),
215 REG(NULL
, "r18", NULL
, Gpr18
),
216 REG(NULL
, "r19", NULL
, Gpr19
),
217 REG(NULL
, "r20", NULL
, Gpr20
),
218 REG(NULL
, "r21", NULL
, Gpr21
),
219 REG(NULL
, "r22", NULL
, Gpr22
),
220 REG(NULL
, "r23", NULL
, Gpr23
),
221 REG(NULL
, "r24", NULL
, Gpr24
),
222 REG(NULL
, "r25", NULL
, Gpr25
),
223 REG(NULL
, "r26", NULL
, Gpr26
),
224 REG(NULL
, "r27", NULL
, Gpr27
),
225 REG(NULL
, "r28", NULL
, Gpr28
),
226 REG(NULL
, "r29", NULL
, Gpr29
),
227 REG(NULL
, "r30", NULL
, Gpr30
),
228 REG(NULL
, "r31", NULL
, Gpr31
),
229 REG(NULL
, "pc", "code_ptr", Iar
),
230 REG(NULL
, "msr", NULL
, Msr
),
231 REG(NULL
, "cr", NULL
, Cr
),
232 REG(NULL
, "lr", "code_ptr", Lr
),
233 REG(NULL
, "ctr", NULL
, Ctr
),
234 REG(NULL
, "xer", NULL
, Xer
),
236 REG("fpu", "f0", "ieee_single", Fpr0
, 4),
237 REG(NULL
, "f1", "ieee_single", Fpr1
, 4),
238 REG(NULL
, "f2", "ieee_single", Fpr2
, 4),
239 REG(NULL
, "f3", "ieee_single", Fpr3
, 4),
240 REG(NULL
, "f4", "ieee_single", Fpr4
, 4),
241 REG(NULL
, "f5", "ieee_single", Fpr5
, 4),
242 REG(NULL
, "f6", "ieee_single", Fpr6
, 4),
243 REG(NULL
, "f7", "ieee_single", Fpr7
, 4),
244 REG(NULL
, "f8", "ieee_single", Fpr8
, 4),
245 REG(NULL
, "f9", "ieee_single", Fpr9
, 4),
246 REG(NULL
, "f10", "ieee_single", Fpr10
, 4),
247 REG(NULL
, "f11", "ieee_single", Fpr11
, 4),
248 REG(NULL
, "f12", "ieee_single", Fpr12
, 4),
249 REG(NULL
, "f13", "ieee_single", Fpr13
, 4),
250 REG(NULL
, "f14", "ieee_single", Fpr14
, 4),
251 REG(NULL
, "f15", "ieee_single", Fpr15
, 4),
252 REG(NULL
, "f16", "ieee_single", Fpr16
, 4),
253 REG(NULL
, "f17", "ieee_single", Fpr17
, 4),
254 REG(NULL
, "f18", "ieee_single", Fpr18
, 4),
255 REG(NULL
, "f19", "ieee_single", Fpr19
, 4),
256 REG(NULL
, "f20", "ieee_single", Fpr20
, 4),
257 REG(NULL
, "f21", "ieee_single", Fpr21
, 4),
258 REG(NULL
, "f22", "ieee_single", Fpr22
, 4),
259 REG(NULL
, "f23", "ieee_single", Fpr23
, 4),
260 REG(NULL
, "f24", "ieee_single", Fpr24
, 4),
261 REG(NULL
, "f25", "ieee_single", Fpr25
, 4),
262 REG(NULL
, "f26", "ieee_single", Fpr26
, 4),
263 REG(NULL
, "f27", "ieee_single", Fpr27
, 4),
264 REG(NULL
, "f28", "ieee_single", Fpr28
, 4),
265 REG(NULL
, "f29", "ieee_single", Fpr29
, 4),
266 REG(NULL
, "f30", "ieee_single", Fpr30
, 4),
267 REG(NULL
, "f31", "ieee_single", Fpr31
, 4),
268 REG(NULL
, "fpscr", NULL
, Fpscr
, 4),
270 /* FIXME: MQ is missing? FIELD_OFFSET(CONTEXT, Mq), */
271 /* see gdb/nlm/ppc.c */
274 struct backend_cpu be_ppc
=
276 IMAGE_FILE_MACHINE_POWERPC
,
281 be_ppc_get_register_info
,
283 be_ppc_print_context
,
284 be_ppc_print_segment_info
,
286 be_ppc_is_step_over_insn
,
287 be_ppc_is_function_return
,
288 be_ppc_is_break_insn
,
291 be_ppc_disasm_one_insn
,
292 be_ppc_insert_Xpoint
,
293 be_ppc_remove_Xpoint
,
294 be_ppc_is_watchpoint_set
,
295 be_ppc_clear_watchpoint
,
296 be_ppc_adjust_pc_for_break
,
297 be_ppc_fetch_integer
,
299 be_ppc_store_integer
,
302 be_ppc_gdb_register_map
,
303 ARRAY_SIZE(be_ppc_gdb_register_map
),