2 * Debugger i386 specific functions
4 * Copyright 2004 Eric Pouech
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(winedbg
);
28 /* debugger/db_disasm.c */
29 extern void be_i386_disasm_one_insn(ADDRESS
* addr
, int display
);
31 #define STEP_FLAG 0x00000100 /* single step flag */
32 #define V86_FLAG 0x00020000
34 #define IS_VM86_MODE(ctx) (ctx->EFlags & V86_FLAG)
36 static ADDRESS_MODE
get_selector_type(HANDLE hThread
, const CONTEXT
* ctx
, WORD sel
)
40 if (IS_VM86_MODE(ctx
)) return AddrModeReal
;
41 /* null or system selector */
42 if (!(sel
& 4) || ((sel
>> 3) < 17)) return AddrModeFlat
;
43 if (GetThreadSelectorEntry(hThread
, sel
, &le
))
44 return le
.HighWord
.Bits
.Default_Big
? AddrMode1632
: AddrMode1616
;
45 /* selector doesn't exist */
49 static void* be_i386_linearize(HANDLE hThread
, const ADDRESS
* addr
)
56 return (void*)((DWORD
)(LOWORD(addr
->Segment
) << 4) + addr
->Offset
);
58 if (!(addr
->Segment
& 4) || ((addr
->Segment
>> 3) < 17))
59 return (void*)addr
->Offset
;
62 if (!GetThreadSelectorEntry(hThread
, addr
->Segment
, &le
)) return NULL
;
63 return (void*)((le
.HighWord
.Bits
.BaseHi
<< 24) +
64 (le
.HighWord
.Bits
.BaseMid
<< 16) + le
.BaseLow
+ addr
->Offset
);
67 return (void*)addr
->Offset
;
72 static unsigned be_i386_build_addr(HANDLE hThread
, const CONTEXT
* ctx
, ADDRESS
* addr
,
73 unsigned seg
, unsigned long offset
)
75 addr
->Mode
= AddrModeFlat
;
77 addr
->Offset
= offset
;
80 addr
->Mode
= get_selector_type(hThread
, ctx
, seg
);
85 addr
->Offset
&= 0xffff;
98 static unsigned be_i386_get_addr(HANDLE hThread
, const CONTEXT
* ctx
,
99 enum be_cpu_addr bca
, ADDRESS
* addr
)
104 return be_i386_build_addr(hThread
, ctx
, addr
, ctx
->SegCs
, ctx
->Eip
);
105 case be_cpu_addr_stack
:
106 return be_i386_build_addr(hThread
, ctx
, addr
, ctx
->SegSs
, ctx
->Esp
);
107 case be_cpu_addr_frame
:
108 return be_i386_build_addr(hThread
, ctx
, addr
, ctx
->SegSs
, ctx
->Ebp
);
113 static void be_i386_single_step(CONTEXT
* ctx
, unsigned enable
)
115 if (enable
) ctx
->EFlags
|= STEP_FLAG
;
116 else ctx
->EFlags
&= ~STEP_FLAG
;
119 static void be_i386_all_print_context(HANDLE hThread
, const CONTEXT
* ctx
)
121 long double ST
[8]; /* These are for floating regs */
124 /* Break out the FPU state and the floating point registers */
125 dbg_printf("Floating Point Unit status:\n");
126 dbg_printf(" FLCW:%04x ", LOWORD(ctx
->FloatSave
.ControlWord
));
127 dbg_printf(" FLTW:%04x ", LOWORD(ctx
->FloatSave
.TagWord
));
128 dbg_printf(" FLEO:%08x ", (unsigned int) ctx
->FloatSave
.ErrorOffset
);
129 dbg_printf(" FLSW:%04x", LOWORD(ctx
->FloatSave
.StatusWord
));
131 /* Isolate the condition code bits - note they are not contiguous */
132 dbg_printf("(CC:%ld%ld%ld%ld", (ctx
->FloatSave
.StatusWord
& 0x00004000) >> 14,
133 (ctx
->FloatSave
.StatusWord
& 0x00000400) >> 10,
134 (ctx
->FloatSave
.StatusWord
& 0x00000200) >> 9,
135 (ctx
->FloatSave
.StatusWord
& 0x00000100) >> 8);
137 /* Now pull out hte 3 bit of the TOP stack pointer */
138 dbg_printf(" TOP:%01x", (unsigned int) (ctx
->FloatSave
.StatusWord
& 0x00003800) >> 11);
140 /* Lets analyse the error bits and indicate the status
141 * the Invalid Op flag has sub status which is tested as follows */
142 if (ctx
->FloatSave
.StatusWord
& 0x00000001) { /* Invalid Fl OP */
143 if (ctx
->FloatSave
.StatusWord
& 0x00000040) { /* Stack Fault */
144 if (ctx
->FloatSave
.StatusWord
& 0x00000200) /* C1 says Overflow */
145 dbg_printf(" #IE(Stack Overflow)");
147 dbg_printf(" #IE(Stack Underflow)"); /* Underflow */
149 else dbg_printf(" #IE(Arthimetic error)"); /* Invalid Fl OP */
152 if (ctx
->FloatSave
.StatusWord
& 0x00000002) dbg_printf(" #DE"); /* Denormalised OP */
153 if (ctx
->FloatSave
.StatusWord
& 0x00000004) dbg_printf(" #ZE"); /* Zero Divide */
154 if (ctx
->FloatSave
.StatusWord
& 0x00000008) dbg_printf(" #OE"); /* Overflow */
155 if (ctx
->FloatSave
.StatusWord
& 0x00000010) dbg_printf(" #UE"); /* Underflow */
156 if (ctx
->FloatSave
.StatusWord
& 0x00000020) dbg_printf(" #PE"); /* Precision error */
157 if (ctx
->FloatSave
.StatusWord
& 0x00000040)
158 if (!(ctx
->FloatSave
.StatusWord
& 0x00000001))
159 dbg_printf(" #SE"); /* Stack Fault (don't think this can occur) */
160 if (ctx
->FloatSave
.StatusWord
& 0x00000080) dbg_printf(" #ES"); /* Error Summary */
161 if (ctx
->FloatSave
.StatusWord
& 0x00008000) dbg_printf(" #FB"); /* FPU Busy */
164 /* Here are the rest of the registers */
165 dbg_printf(" FLES:%08x ", (unsigned int) ctx
->FloatSave
.ErrorSelector
);
166 dbg_printf(" FLDO:%08x ", (unsigned int) ctx
->FloatSave
.DataOffset
);
167 dbg_printf(" FLDS:%08x ", (unsigned int) ctx
->FloatSave
.DataSelector
);
168 dbg_printf(" FLCNS:%08x \n", (unsigned int) ctx
->FloatSave
.Cr0NpxState
);
170 /* Now for the floating point registers */
171 dbg_printf("Floating Point Registers:\n");
172 for (cnt
= 0; cnt
< 4; cnt
++)
174 memcpy(&ST
[cnt
], &ctx
->FloatSave
.RegisterArea
[cnt
* 10], 10);
175 dbg_printf(" ST%d:%Lf ", cnt
, ST
[cnt
]);
178 for (cnt
= 4; cnt
< 8; cnt
++)
180 memcpy(&ST
[cnt
], &ctx
->FloatSave
.RegisterArea
[cnt
* 10], 10);
181 dbg_printf(" ST%d:%Lf ", cnt
, ST
[cnt
]);
186 static void be_i386_print_context(HANDLE hThread
, const CONTEXT
* ctx
, int all_regs
)
191 dbg_printf("Register dump:\n");
193 /* First get the segment registers out of the way */
194 dbg_printf(" CS:%04x SS:%04x DS:%04x ES:%04x FS:%04x GS:%04x",
195 (WORD
)ctx
->SegCs
, (WORD
)ctx
->SegSs
,
196 (WORD
)ctx
->SegDs
, (WORD
)ctx
->SegEs
,
197 (WORD
)ctx
->SegFs
, (WORD
)ctx
->SegGs
);
199 strcpy(buf
, " - 00 - - - ");
200 pt
= buf
+ strlen(buf
) - 1;
201 if (ctx
->EFlags
& 0x00000001) *pt
-- = 'C'; /* Carry Flag */
202 if (ctx
->EFlags
& 0x00000002) *pt
-- = '1';
203 if (ctx
->EFlags
& 0x00000004) *pt
-- = 'P'; /* Parity Flag */
204 if (ctx
->EFlags
& 0x00000008) *pt
-- = '-';
205 if (ctx
->EFlags
& 0x00000010) *pt
-- = 'A'; /* Auxiliary Carry Flag */
206 if (ctx
->EFlags
& 0x00000020) *pt
-- = '-';
207 if (ctx
->EFlags
& 0x00000040) *pt
-- = 'Z'; /* Zero Flag */
208 if (ctx
->EFlags
& 0x00000080) *pt
-- = 'S'; /* Sign Flag */
209 if (ctx
->EFlags
& 0x00000100) *pt
-- = 'T'; /* Trap/Trace Flag */
210 if (ctx
->EFlags
& 0x00000200) *pt
-- = 'I'; /* Interupt Enable Flag */
211 if (ctx
->EFlags
& 0x00000400) *pt
-- = 'D'; /* Direction Indicator */
212 if (ctx
->EFlags
& 0x00000800) *pt
-- = 'O'; /* Overflow flags */
213 if (ctx
->EFlags
& 0x00001000) *pt
-- = '1'; /* I/O Privilege Level */
214 if (ctx
->EFlags
& 0x00002000) *pt
-- = '1'; /* I/O Privilege Level */
215 if (ctx
->EFlags
& 0x00004000) *pt
-- = 'N'; /* Nested Task Flag */
216 if (ctx
->EFlags
& 0x00008000) *pt
-- = '-';
217 if (ctx
->EFlags
& 0x00010000) *pt
-- = 'R'; /* Resume Flag */
218 if (ctx
->EFlags
& 0x00020000) *pt
-- = 'V'; /* Vritual Mode Flag */
219 if (ctx
->EFlags
& 0x00040000) *pt
-- = 'a'; /* Alignment Check Flag */
221 switch (get_selector_type(hThread
, ctx
, ctx
->SegCs
))
225 dbg_printf("\n IP:%04x SP:%04x BP:%04x FLAGS:%04x(%s)\n",
226 LOWORD(ctx
->Eip
), LOWORD(ctx
->Esp
),
227 LOWORD(ctx
->Ebp
), LOWORD(ctx
->EFlags
), buf
);
228 dbg_printf(" AX:%04x BX:%04x CX:%04x DX:%04x SI:%04x DI:%04x\n",
229 LOWORD(ctx
->Eax
), LOWORD(ctx
->Ebx
),
230 LOWORD(ctx
->Ecx
), LOWORD(ctx
->Edx
),
231 LOWORD(ctx
->Esi
), LOWORD(ctx
->Edi
));
235 dbg_printf("\n EIP:%08lx ESP:%08lx EBP:%08lx EFLAGS:%08lx(%s)\n",
236 ctx
->Eip
, ctx
->Esp
, ctx
->Ebp
, ctx
->EFlags
, buf
);
237 dbg_printf(" EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n",
238 ctx
->Eax
, ctx
->Ebx
, ctx
->Ecx
, ctx
->Edx
);
239 dbg_printf(" ESI:%08lx EDI:%08lx\n",
244 if (all_regs
) be_i386_all_print_context(hThread
, ctx
); /* print floating regs */
248 static void be_i386_print_segment_info(HANDLE hThread
, const CONTEXT
* ctx
)
250 if (get_selector_type(hThread
, ctx
, ctx
->SegCs
) == AddrMode1616
)
252 info_win32_segments(ctx
->SegDs
>> 3, 1);
253 if (ctx
->SegEs
!= ctx
->SegDs
) info_win32_segments(ctx
->SegEs
>> 3, 1);
255 info_win32_segments(ctx
->SegFs
>> 3, 1);
258 static struct dbg_internal_var be_i386_ctx
[] =
260 {CV_REG_AL
, "AL", (DWORD
*)FIELD_OFFSET(CONTEXT
, Eax
), dbg_itype_unsigned_char_int
},
261 {CV_REG_CL
, "CL", (DWORD
*)FIELD_OFFSET(CONTEXT
, Ecx
), dbg_itype_unsigned_char_int
},
262 {CV_REG_DL
, "DL", (DWORD
*)FIELD_OFFSET(CONTEXT
, Edx
), dbg_itype_unsigned_char_int
},
263 {CV_REG_BL
, "BL", (DWORD
*)FIELD_OFFSET(CONTEXT
, Ebx
), dbg_itype_unsigned_char_int
},
264 {CV_REG_AH
, "AH", (DWORD
*)(FIELD_OFFSET(CONTEXT
, Eax
)+1), dbg_itype_unsigned_char_int
},
265 {CV_REG_CH
, "CH", (DWORD
*)(FIELD_OFFSET(CONTEXT
, Ecx
)+1), dbg_itype_unsigned_char_int
},
266 {CV_REG_DH
, "DH", (DWORD
*)(FIELD_OFFSET(CONTEXT
, Edx
)+1), dbg_itype_unsigned_char_int
},
267 {CV_REG_BH
, "BH", (DWORD
*)(FIELD_OFFSET(CONTEXT
, Ebx
)+1), dbg_itype_unsigned_char_int
},
268 {CV_REG_AX
, "AX", (DWORD
*)FIELD_OFFSET(CONTEXT
, Eax
), dbg_itype_unsigned_short_int
},
269 {CV_REG_CX
, "CX", (DWORD
*)FIELD_OFFSET(CONTEXT
, Ecx
), dbg_itype_unsigned_short_int
},
270 {CV_REG_DX
, "DX", (DWORD
*)FIELD_OFFSET(CONTEXT
, Edx
), dbg_itype_unsigned_short_int
},
271 {CV_REG_BX
, "BX", (DWORD
*)FIELD_OFFSET(CONTEXT
, Ebx
), dbg_itype_unsigned_short_int
},
272 {CV_REG_SP
, "SP", (DWORD
*)FIELD_OFFSET(CONTEXT
, Esp
), dbg_itype_unsigned_short_int
},
273 {CV_REG_BP
, "BP", (DWORD
*)FIELD_OFFSET(CONTEXT
, Ebp
), dbg_itype_unsigned_short_int
},
274 {CV_REG_SI
, "SI", (DWORD
*)FIELD_OFFSET(CONTEXT
, Esi
), dbg_itype_unsigned_short_int
},
275 {CV_REG_DI
, "DI", (DWORD
*)FIELD_OFFSET(CONTEXT
, Edi
), dbg_itype_unsigned_short_int
},
276 {CV_REG_EAX
, "EAX", (DWORD
*)FIELD_OFFSET(CONTEXT
, Eax
), dbg_itype_unsigned_int
},
277 {CV_REG_ECX
, "ECX", (DWORD
*)FIELD_OFFSET(CONTEXT
, Ecx
), dbg_itype_unsigned_int
},
278 {CV_REG_EDX
, "EDX", (DWORD
*)FIELD_OFFSET(CONTEXT
, Edx
), dbg_itype_unsigned_int
},
279 {CV_REG_EBX
, "EBX", (DWORD
*)FIELD_OFFSET(CONTEXT
, Ebx
), dbg_itype_unsigned_int
},
280 {CV_REG_ESP
, "ESP", (DWORD
*)FIELD_OFFSET(CONTEXT
, Esp
), dbg_itype_unsigned_int
},
281 {CV_REG_EBP
, "EBP", (DWORD
*)FIELD_OFFSET(CONTEXT
, Ebp
), dbg_itype_unsigned_int
},
282 {CV_REG_ESI
, "ESI", (DWORD
*)FIELD_OFFSET(CONTEXT
, Esi
), dbg_itype_unsigned_int
},
283 {CV_REG_EDI
, "EDI", (DWORD
*)FIELD_OFFSET(CONTEXT
, Edi
), dbg_itype_unsigned_int
},
284 {CV_REG_ES
, "ES", (DWORD
*)FIELD_OFFSET(CONTEXT
, SegEs
), dbg_itype_unsigned_short_int
},
285 {CV_REG_CS
, "CS", (DWORD
*)FIELD_OFFSET(CONTEXT
, SegCs
), dbg_itype_unsigned_short_int
},
286 {CV_REG_SS
, "SS", (DWORD
*)FIELD_OFFSET(CONTEXT
, SegSs
), dbg_itype_unsigned_short_int
},
287 {CV_REG_DS
, "DS", (DWORD
*)FIELD_OFFSET(CONTEXT
, SegDs
), dbg_itype_unsigned_short_int
},
288 {CV_REG_FS
, "FS", (DWORD
*)FIELD_OFFSET(CONTEXT
, SegFs
), dbg_itype_unsigned_short_int
},
289 {CV_REG_GS
, "GS", (DWORD
*)FIELD_OFFSET(CONTEXT
, SegGs
), dbg_itype_unsigned_short_int
},
290 {CV_REG_IP
, "IP", (DWORD
*)FIELD_OFFSET(CONTEXT
, Eip
), dbg_itype_unsigned_short_int
},
291 {CV_REG_FLAGS
, "FLAGS", (DWORD
*)FIELD_OFFSET(CONTEXT
, EFlags
), dbg_itype_unsigned_short_int
},
292 {CV_REG_EIP
, "EIP", (DWORD
*)FIELD_OFFSET(CONTEXT
, Eip
), dbg_itype_unsigned_int
},
293 {CV_REG_EFLAGS
, "EFLAGS", (DWORD
*)FIELD_OFFSET(CONTEXT
, EFlags
), dbg_itype_unsigned_int
},
294 {0, NULL
, 0, dbg_itype_none
}
297 static const struct dbg_internal_var
* be_i386_init_registers(CONTEXT
* ctx
)
299 struct dbg_internal_var
* div
;
301 for (div
= be_i386_ctx
; div
->name
; div
++)
302 div
->pval
= (DWORD
*)((char*)ctx
+ (DWORD
)div
->pval
);
306 static unsigned be_i386_is_step_over_insn(const void* insn
)
312 if (!dbg_read_memory(insn
, &ch
, sizeof(ch
))) return FALSE
;
316 /* Skip all prefixes */
323 case 0x66: /* opcode size prefix */
324 case 0x67: /* addr size prefix */
325 case 0xf0: /* lock */
326 case 0xf2: /* repne */
327 case 0xf3: /* repe */
328 insn
= (const char*)insn
+ 1;
331 /* Handle call instructions */
332 case 0xcd: /* int <intno> */
333 case 0xe8: /* call <offset> */
334 case 0x9a: /* lcall <seg>:<off> */
337 case 0xff: /* call <regmodrm> */
338 if (!dbg_read_memory((const char*)insn
+ 1, &ch
, sizeof(ch
)))
340 return (((ch
& 0x38) == 0x10) || ((ch
& 0x38) == 0x18));
342 /* Handle string instructions */
343 case 0x6c: /* insb */
344 case 0x6d: /* insw */
345 case 0x6e: /* outsb */
346 case 0x6f: /* outsw */
347 case 0xa4: /* movsb */
348 case 0xa5: /* movsw */
349 case 0xa6: /* cmpsb */
350 case 0xa7: /* cmpsw */
351 case 0xaa: /* stosb */
352 case 0xab: /* stosw */
353 case 0xac: /* lodsb */
354 case 0xad: /* lodsw */
355 case 0xae: /* scasb */
356 case 0xaf: /* scasw */
365 static unsigned be_i386_is_function_return(const void* insn
)
369 if (!dbg_read_memory(insn
, &ch
, sizeof(ch
))) return FALSE
;
370 return (ch
== 0xC2) || (ch
== 0xC3);
373 static unsigned be_i386_is_break_insn(const void* insn
)
377 if (!dbg_read_memory(insn
, &c
, sizeof(c
))) return FALSE
;
381 static unsigned be_i386_is_func_call(const void* insn
, ADDRESS
* callee
)
386 if (!dbg_read_memory(insn
, &ch
, sizeof(ch
))) return FALSE
;
390 dbg_read_memory((const char*)insn
+ 1, &delta
, sizeof(delta
));
392 callee
->Mode
= AddrModeFlat
;
393 callee
->Offset
= (DWORD
)insn
;
394 be_i386_disasm_one_insn(callee
, FALSE
);
395 callee
->Offset
+= delta
;
399 if (!dbg_read_memory((const char*)insn
+ 1, &ch
, sizeof(ch
)))
402 if (ch
!= 0x10 && ch
!= 0x18) return FALSE
;
406 WINE_FIXME("Unsupported yet call insn (0x%02x) at %p\n", ch
, insn
);
413 #define DR7_CONTROL_SHIFT 16
414 #define DR7_CONTROL_SIZE 4
416 #define DR7_RW_EXECUTE (0x0)
417 #define DR7_RW_WRITE (0x1)
418 #define DR7_RW_READ (0x3)
420 #define DR7_LEN_1 (0x0)
421 #define DR7_LEN_2 (0x4)
422 #define DR7_LEN_4 (0xC)
424 #define DR7_LOCAL_ENABLE_SHIFT 0
425 #define DR7_GLOBAL_ENABLE_SHIFT 1
426 #define DR7_ENABLE_SIZE 2
428 #define DR7_LOCAL_ENABLE_MASK (0x55)
429 #define DR7_GLOBAL_ENABLE_MASK (0xAA)
431 #define DR7_CONTROL_RESERVED (0xFC00)
432 #define DR7_LOCAL_SLOWDOWN (0x100)
433 #define DR7_GLOBAL_SLOWDOWN (0x200)
435 #define DR7_ENABLE_MASK(dr) (1<<(DR7_LOCAL_ENABLE_SHIFT+DR7_ENABLE_SIZE*(dr)))
436 #define IS_DR7_SET(ctrl,dr) ((ctrl)&DR7_ENABLE_MASK(dr))
438 static inline int be_i386_get_unused_DR(CONTEXT
* ctx
, unsigned long** r
)
440 if (!IS_DR7_SET(ctx
->Dr7
, 0))
445 if (!IS_DR7_SET(ctx
->Dr7
, 1))
450 if (!IS_DR7_SET(ctx
->Dr7
, 2))
455 if (!IS_DR7_SET(ctx
->Dr7
, 3))
460 dbg_printf("All hardware registers have been used\n");
465 static unsigned be_i386_insert_Xpoint(HANDLE hProcess
, const struct be_process_io
* pio
,
466 CONTEXT
* ctx
, enum be_xpoint_type type
,
467 void* addr
, unsigned long* val
, unsigned size
)
477 case be_xpoint_break
:
478 if (size
!= 0) return 0;
479 if (!pio
->read(hProcess
, addr
, &ch
, 1, &sz
) || sz
!= 1) return 0;
482 if (!pio
->write(hProcess
, addr
, &ch
, 1, &sz
) || sz
!= 1) return 0;
484 case be_xpoint_watch_exec
:
485 bits
= DR7_RW_EXECUTE
;
487 case be_xpoint_watch_read
:
490 case be_xpoint_watch_write
:
493 if ((reg
= be_i386_get_unused_DR(ctx
, &pr
)) == -1) return 0;
494 *pr
= (unsigned long)addr
;
495 if (type
!= be_xpoint_watch_exec
) switch (size
)
497 case 4: bits
|= DR7_LEN_4
; break;
498 case 2: bits
|= DR7_LEN_2
; break;
499 case 1: bits
|= DR7_LEN_1
; break;
503 /* clear old values */
504 ctx
->Dr7
&= ~(0x0F << (DR7_CONTROL_SHIFT
+ DR7_CONTROL_SIZE
* reg
));
505 /* set the correct ones */
506 ctx
->Dr7
|= bits
<< (DR7_CONTROL_SHIFT
+ DR7_CONTROL_SIZE
* reg
);
507 ctx
->Dr7
|= DR7_ENABLE_MASK(reg
) | DR7_LOCAL_SLOWDOWN
;
510 dbg_printf("Unknown bp type %c\n", type
);
516 static unsigned be_i386_remove_Xpoint(HANDLE hProcess
, const struct be_process_io
* pio
,
517 CONTEXT
* ctx
, enum be_xpoint_type type
,
518 void* addr
, unsigned long val
, unsigned size
)
525 case be_xpoint_break
:
526 if (size
!= 0) return 0;
527 if (!pio
->read(hProcess
, addr
, &ch
, 1, &sz
) || sz
!= 1) return 0;
528 if (ch
!= (unsigned char)0xCC)
529 WINE_FIXME("Cannot get back %02x instead of 0xCC at %08lx\n",
530 ch
, (unsigned long)addr
);
531 ch
= (unsigned char)val
;
532 if (!pio
->write(hProcess
, addr
, &ch
, 1, &sz
) || sz
!= 1) return 0;
534 case be_xpoint_watch_exec
:
535 case be_xpoint_watch_read
:
536 case be_xpoint_watch_write
:
537 /* simply disable the entry */
538 ctx
->Dr7
&= ~DR7_ENABLE_MASK(val
);
541 dbg_printf("Unknown bp type %c\n", type
);
547 static unsigned be_i386_is_watchpoint_set(const CONTEXT
* ctx
, unsigned idx
)
549 return ctx
->Dr6
& (1 << idx
);
552 static void be_i386_clear_watchpoint(CONTEXT
* ctx
, unsigned idx
)
554 ctx
->Dr6
&= ~(1 << idx
);
557 static int be_i386_adjust_pc_for_break(CONTEXT
* ctx
, BOOL way
)
568 static int be_i386_fetch_integer(const struct dbg_lvalue
* lvalue
, unsigned size
,
569 unsigned ext_sign
, LONGLONG
* ret
)
571 if (size
!= 1 && size
!= 2 && size
!= 4 && size
!= 8) return FALSE
;
573 memset(ret
, 0, sizeof(*ret
)); /* clear unread bytes */
574 /* FIXME: this assumes that debuggee and debugger use the same
575 * integral representation
577 if (!memory_read_value(lvalue
, size
, ret
)) return FALSE
;
579 /* propagate sign information */
580 if (ext_sign
&& size
< 8 && (*ret
>> (size
* 8 - 1)) != 0)
583 *ret
|= neg
<< (size
* 8);
588 static int be_i386_fetch_float(const struct dbg_lvalue
* lvalue
, unsigned size
,
593 /* FIXME: this assumes that debuggee and debugger use the same
594 * representation for reals
596 if (!memory_read_value(lvalue
, size
, tmp
)) return FALSE
;
598 /* float & double types have to be promoted to a long double */
601 case sizeof(float): *ret
= *(float*)tmp
; break;
602 case sizeof(double): *ret
= *(double*)tmp
; break;
603 case sizeof(long double): *ret
= *(long double*)tmp
; break;
604 default: return FALSE
;
609 struct backend_cpu be_i386
=
615 be_i386_print_context
,
616 be_i386_print_segment_info
,
617 be_i386_init_registers
,
618 be_i386_is_step_over_insn
,
619 be_i386_is_function_return
,
620 be_i386_is_break_insn
,
621 be_i386_is_func_call
,
622 be_i386_disasm_one_insn
,
623 be_i386_insert_Xpoint
,
624 be_i386_remove_Xpoint
,
625 be_i386_is_watchpoint_set
,
626 be_i386_clear_watchpoint
,
627 be_i386_adjust_pc_for_break
,
628 be_i386_fetch_integer
,