2 * Debugger break-points handling
4 * Copyright 1994 Martin von Loewis
5 * Copyright 1995 Alexandre Julliard
6 * Copyright 1999,2000 Eric Pouech
14 #define DR7_CONTROL_SHIFT 16
15 #define DR7_CONTROL_SIZE 4
17 #define DR7_RW_EXECUTE (0x0)
18 #define DR7_RW_WRITE (0x1)
19 #define DR7_RW_READ (0x3)
21 #define DR7_LEN_1 (0x0)
22 #define DR7_LEN_2 (0x4)
23 #define DR7_LEN_4 (0xC)
25 #define DR7_LOCAL_ENABLE_SHIFT 0
26 #define DR7_GLOBAL_ENABLE_SHIFT 1
27 #define DR7_ENABLE_SIZE 2
29 #define DR7_LOCAL_ENABLE_MASK (0x55)
30 #define DR7_GLOBAL_ENABLE_MASK (0xAA)
32 #define DR7_CONTROL_RESERVED (0xFC00)
33 #define DR7_LOCAL_SLOWDOWN (0x100)
34 #define DR7_GLOBAL_SLOWDOWN (0x200)
36 #define DR7_ENABLE_MASK(dr) (1<<(DR7_LOCAL_ENABLE_SHIFT+DR7_ENABLE_SIZE*(dr)))
37 #define IS_DR7_SET(ctrl,dr) ((ctrl)&DR7_ENABLE_MASK(dr))
38 #define INT3 0xcc /* int 3 opcode */
41 #define MAX_BREAKPOINTS 100
43 static BREAKPOINT breakpoints
[MAX_BREAKPOINTS
];
45 static int next_bp
= 1; /* breakpoint 0 is reserved for step-over */
47 /***********************************************************************
48 * DEBUG_IsStepOverInstr
50 * Determine if the instruction at CS:EIP is an instruction that
51 * we need to step over (like a call or a repetitive string move).
53 static BOOL
DEBUG_IsStepOverInstr(void)
60 addr
.seg
= DEBUG_context
.SegCs
;
61 addr
.off
= DEBUG_context
.Eip
;
62 /* FIXME: old code was using V86BASE(DEBUG_context)
63 * instead of passing thru DOSMEM_MemoryBase
65 instr
= (BYTE
*)DEBUG_ToLinear(&addr
);
69 if (!DEBUG_READ_MEM(instr
, &ch
, sizeof(ch
)))
74 /* Skip all prefixes */
82 case 0x66: /* opcode size prefix */
83 case 0x67: /* addr size prefix */
85 case 0xf2: /* repne */
90 /* Handle call instructions */
92 case 0xcd: /* int <intno> */
93 case 0xe8: /* call <offset> */
94 case 0x9a: /* lcall <seg>:<off> */
97 case 0xff: /* call <regmodrm> */
98 if (!DEBUG_READ_MEM(instr
+ 1, &ch
, sizeof(ch
)))
100 return (((ch
& 0x38) == 0x10) || ((ch
& 0x38) == 0x18));
102 /* Handle string instructions */
104 case 0x6c: /* insb */
105 case 0x6d: /* insw */
106 case 0x6e: /* outsb */
107 case 0x6f: /* outsw */
108 case 0xa4: /* movsb */
109 case 0xa5: /* movsw */
110 case 0xa6: /* cmpsb */
111 case 0xa7: /* cmpsw */
112 case 0xaa: /* stosb */
113 case 0xab: /* stosw */
114 case 0xac: /* lodsb */
115 case 0xad: /* lodsw */
116 case 0xae: /* scasb */
117 case 0xaf: /* scasw */
130 /***********************************************************************
133 * Determine if the instruction at CS:EIP is an instruction that
134 * is a function return.
136 BOOL
DEBUG_IsFctReturn(void)
143 addr
.seg
= DEBUG_context
.SegCs
;
144 addr
.off
= DEBUG_context
.Eip
;
145 /* FIXME: old code was using V86BASE(DEBUG_context)
146 * instead of passing thru DOSMEM_MemoryBase
148 instr
= (BYTE
*)DEBUG_ToLinear(&addr
);
150 if (!DEBUG_READ_MEM(instr
, &ch
, sizeof(ch
)))
153 return (ch
== 0xc2) || (ch
== 0xc3);
160 /***********************************************************************
161 * DEBUG_SetBreakpoints
163 * Set or remove all the breakpoints.
165 void DEBUG_SetBreakpoints( BOOL set
)
170 DEBUG_context
.Dr7
&= ~DR7_LOCAL_ENABLE_MASK
;
173 for (i
= 0; i
< next_bp
; i
++)
175 if (!(breakpoints
[i
].refcount
&& breakpoints
[i
].enabled
))
178 switch (breakpoints
[i
].type
) {
182 char ch
= set
? INT3
: breakpoints
[i
].u
.opcode
;
185 if (!DEBUG_WRITE_MEM( (void*)DEBUG_ToLinear(&breakpoints
[i
].addr
),
188 fprintf(stderr
, "Invalid address for breakpoint %d, disabling it\n", i
);
189 breakpoints
[i
].enabled
= FALSE
;
198 int reg
= breakpoints
[i
].u
.w
.reg
;
203 case 0: lpdr
= &DEBUG_context
.Dr0
; break;
204 case 1: lpdr
= &DEBUG_context
.Dr1
; break;
205 case 2: lpdr
= &DEBUG_context
.Dr2
; break;
206 case 3: lpdr
= &DEBUG_context
.Dr3
; break;
207 default: RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
210 *lpdr
= DEBUG_ToLinear(&breakpoints
[i
].addr
);
211 bits
= (breakpoints
[i
].u
.w
.rw
) ? DR7_RW_WRITE
: DR7_RW_READ
;
212 switch (breakpoints
[i
].u
.w
.len
+ 1)
214 case 4: bits
|= DR7_LEN_4
; break;
215 case 2: bits
|= DR7_LEN_2
; break;
216 case 1: bits
|= DR7_LEN_1
; break;
217 default: RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
220 DEBUG_context
.Dr7
&= ~(0x0F << (DR7_CONTROL_SHIFT
+ DR7_CONTROL_SIZE
* reg
));
221 DEBUG_context
.Dr7
|= bits
<< (DR7_CONTROL_SHIFT
+ DR7_CONTROL_SIZE
* reg
);
222 DEBUG_context
.Dr7
|= DR7_ENABLE_MASK(reg
) | DR7_LOCAL_SLOWDOWN
;
230 /***********************************************************************
231 * DEBUG_FindBreakpoint
233 * Find the breakpoint for a given address. Return the breakpoint
234 * number or -1 if none.
235 * If type is DBG_BREAKPOINT, addr is a complete addr
236 * If type is DBG_WATCHPOINT, only addr.off is meaningful and contains
239 static int DEBUG_FindBreakpoint( const DBG_ADDR
*addr
, int type
)
243 for (i
= 0; i
< next_bp
; i
++)
245 if (breakpoints
[i
].refcount
&& breakpoints
[i
].enabled
&&
246 breakpoints
[i
].type
== type
)
248 if ((type
== DBG_BREAK
&&
249 breakpoints
[i
].addr
.seg
== addr
->seg
&&
250 breakpoints
[i
].addr
.off
== addr
->off
) ||
251 (type
== DBG_WATCH
&&
252 DEBUG_ToLinear(&breakpoints
[i
].addr
) == addr
->off
))
259 /***********************************************************************
262 * Find an empty slot in BP table to add a new break/watch point
264 static int DEBUG_InitXPoint(int type
, DBG_ADDR
* addr
)
268 for (num
= (next_bp
< MAX_BREAKPOINTS
) ? next_bp
++ : 1;
269 num
< MAX_BREAKPOINTS
; num
++)
271 if (breakpoints
[num
].refcount
== 0)
273 breakpoints
[num
].refcount
= 1;
274 breakpoints
[num
].enabled
= TRUE
;
275 breakpoints
[num
].type
= type
;
276 breakpoints
[num
].skipcount
= 0;
277 breakpoints
[num
].addr
= *addr
;
278 breakpoints
[num
].is32
= 1;
282 switch (DEBUG_GetSelectorType( addr
->seg
))
285 case 16: breakpoints
[num
].is32
= 0; break;
286 default: RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
294 fprintf( stderr
, "Too many breakpoints. Please delete some.\n" );
298 /***********************************************************************
299 * DEBUG_GetWatchedValue
301 * Returns the value watched by watch point 'num'.
303 static BOOL
DEBUG_GetWatchedValue( int num
, LPDWORD val
)
307 if (!DEBUG_READ_MEM((void*)DEBUG_ToLinear(&breakpoints
[num
].addr
),
308 buf
, breakpoints
[num
].u
.w
.len
+ 1))
311 switch (breakpoints
[num
].u
.w
.len
+ 1)
313 case 4: *val
= *(DWORD
*)buf
; break;
314 case 2: *val
= *(WORD
*)buf
; break;
315 case 1: *val
= *(BYTE
*)buf
; break;
316 default: RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
321 /***********************************************************************
322 * DEBUG_AddBreakpoint
326 void DEBUG_AddBreakpoint( const DBG_VALUE
*_value
)
328 DBG_VALUE value
= *_value
;
333 assert(_value
->cookie
== DV_TARGET
|| _value
->cookie
== DV_HOST
);
335 DEBUG_FixAddress( &value
.addr
, DEBUG_context
.SegCs
);
337 if( value
.type
!= NULL
&& value
.type
== DEBUG_TypeIntConst
)
340 * We know that we have the actual offset stored somewhere
341 * else in 32-bit space. Grab it, and we
344 seg2
= value
.addr
.seg
;
346 value
.addr
.off
= DEBUG_GetExprValue(&value
, NULL
);
347 value
.addr
.seg
= seg2
;
350 if ((num
= DEBUG_FindBreakpoint(&value
.addr
, DBG_BREAK
)) >= 1)
352 breakpoints
[num
].refcount
++;
356 if (!DEBUG_READ_MEM_VERBOSE((void*)DEBUG_ToLinear( &value
.addr
), &ch
, sizeof(ch
)))
359 if ((num
= DEBUG_InitXPoint(DBG_BREAK
, &value
.addr
)) == -1)
362 breakpoints
[num
].u
.opcode
= ch
;
364 fprintf( stderr
, "Breakpoint %d at ", num
);
365 DEBUG_PrintAddress( &breakpoints
[num
].addr
, breakpoints
[num
].is32
? 32 : 16,
367 fprintf( stderr
, "\n" );
371 /***********************************************************************
372 * DEBUG_AddWatchpoint
376 void DEBUG_AddWatchpoint( const DBG_VALUE
*_value
, BOOL is_write
)
378 DBG_VALUE value
= *_value
;
383 assert(_value
->cookie
== DV_TARGET
|| _value
->cookie
== DV_HOST
);
385 DEBUG_FixAddress( &value
.addr
, CS_reg(&DEBUG_context
) );
387 if ( value
.type
!= NULL
&& value
.type
== DEBUG_TypeIntConst
)
390 * We know that we have the actual offset stored somewhere
391 * else in 32-bit space. Grab it, and we
394 seg2
= value
.addr
.seg
;
396 value
.addr
.off
= DEBUG_GetExprValue(&value
, NULL
);
397 value
.addr
.seg
= seg2
;
400 for (num
= 1; num
< next_bp
; num
++)
402 if (breakpoints
[num
].refcount
&& breakpoints
[num
].enabled
&&
403 breakpoints
[num
].type
== DBG_WATCH
) {
404 mask
|= (1 << breakpoints
[num
].u
.w
.reg
);
408 for (reg
= 0; reg
< 4 && (mask
& (1 << reg
)); reg
++);
411 fprintf(stderr
, "All i386 hardware watchpoints have been set. Delete some\n");
416 if ((num
= DEBUG_InitXPoint(DBG_WATCH
, &value
.addr
)) == -1)
419 breakpoints
[num
].u
.w
.len
= 4 - 1;
420 if (_value
->type
&& DEBUG_GetObjectSize(_value
->type
) < 4)
421 breakpoints
[num
].u
.w
.len
= 2 - 1;
423 if (!DEBUG_GetWatchedValue( num
, &breakpoints
[num
].u
.w
.oldval
))
425 fprintf(stderr
, "Bad address. Watchpoint not set\n");
426 breakpoints
[num
].refcount
= 0;
429 breakpoints
[num
].u
.w
.rw
= (is_write
) ? TRUE
: FALSE
;
430 breakpoints
[reg
].u
.w
.reg
= reg
;
432 fprintf( stderr
, "Watchpoint %d at ", num
);
433 DEBUG_PrintAddress( &breakpoints
[num
].addr
, breakpoints
[num
].is32
? 32:16, TRUE
);
434 fprintf( stderr
, "\n" );
437 /***********************************************************************
438 * DEBUG_DelBreakpoint
440 * Delete a breakpoint.
442 void DEBUG_DelBreakpoint( int num
)
444 if ((num
<= 0) || (num
>= next_bp
) || breakpoints
[num
].refcount
== 0)
446 fprintf( stderr
, "Invalid breakpoint number %d\n", num
);
450 if (--breakpoints
[num
].refcount
> 0)
453 if( breakpoints
[num
].condition
!= NULL
)
455 DEBUG_FreeExpr(breakpoints
[num
].condition
);
456 breakpoints
[num
].condition
= NULL
;
459 breakpoints
[num
].enabled
= FALSE
;
460 breakpoints
[num
].refcount
= 0;
461 breakpoints
[num
].skipcount
= 0;
464 /***********************************************************************
465 * DEBUG_EnableBreakpoint
467 * Enable or disable a break point.
469 void DEBUG_EnableBreakpoint( int num
, BOOL enable
)
471 if ((num
<= 0) || (num
>= next_bp
) || breakpoints
[num
].refcount
== 0)
473 fprintf( stderr
, "Invalid breakpoint number %d\n", num
);
476 breakpoints
[num
].enabled
= (enable
) ? TRUE
: FALSE
;
477 breakpoints
[num
].skipcount
= 0;
481 /***********************************************************************
482 * DEBUG_FindTriggeredWatchpoint
484 * Lookup the watchpoints to see if one has been triggered
485 * Return >= (watch point index) if one is found and *oldval is set to
486 * the value watched before the TRAP
487 * Return -1 if none found (*oldval is undetermined)
489 * Unfortunately, Linux does *NOT* (A REAL PITA) report with ptrace
490 * the DR6 register value, so we have to look with our own need the
494 static int DEBUG_FindTriggeredWatchpoint(LPDWORD oldval
)
500 /* Method 1 => get triggered watchpoint from context (doesn't work on Linux
503 for (i
= 0; i
< next_bp
; i
++)
506 if (breakpoints
[i
].refcount
&& breakpoints
[i
].enabled
&&
507 breakpoints
[i
].type
== DBG_WATCH
&&
508 (DEBUG_context
.Dr6
& (1 << breakpoints
[i
].u
.w
.reg
)))
510 DEBUG_context
.Dr6
&= ~(1 << breakpoints
[i
].u
.w
.reg
);
512 *oldval
= breakpoints
[i
].u
.w
.oldval
;
513 if (DEBUG_GetWatchedValue(i
, &val
)) {
514 breakpoints
[i
].u
.w
.oldval
= val
;
521 /* Method 1 failed, trying method2 */
523 /* Method 2 => check if value has changed among registered watchpoints
524 * this really sucks, but this is how gdb 4.18 works on my linux box
527 for (i
= 0; i
< next_bp
; i
++)
530 if (breakpoints
[i
].refcount
&& breakpoints
[i
].enabled
&&
531 breakpoints
[i
].type
== DBG_WATCH
&&
532 DEBUG_GetWatchedValue(i
, &val
))
534 *oldval
= breakpoints
[i
].u
.w
.oldval
;
537 DEBUG_context
.Dr6
&= ~(1 << breakpoints
[i
].u
.w
.reg
);
538 breakpoints
[i
].u
.w
.oldval
= val
;
540 /* cannot break, because two watch points may have been triggered on
542 * only one will be reported to the user (FIXME ?)
551 /***********************************************************************
552 * DEBUG_InfoBreakpoints
554 * Display break points information.
556 void DEBUG_InfoBreakpoints(void)
560 fprintf( stderr
, "Breakpoints:\n" );
561 for (i
= 1; i
< next_bp
; i
++)
563 if (breakpoints
[i
].refcount
&& breakpoints
[i
].type
== DBG_BREAK
)
565 fprintf( stderr
, "%d: %c ", i
, breakpoints
[i
].enabled
? 'y' : 'n');
566 DEBUG_PrintAddress( &breakpoints
[i
].addr
,
567 breakpoints
[i
].is32
? 32 : 16, TRUE
);
568 fprintf( stderr
, " (%u)\n", breakpoints
[i
].refcount
);
569 if( breakpoints
[i
].condition
!= NULL
)
571 fprintf(stderr
, "\t\tstop when ");
572 DEBUG_DisplayExpr(breakpoints
[i
].condition
);
573 fprintf(stderr
, "\n");
577 fprintf( stderr
, "Watchpoints:\n" );
578 for (i
= 1; i
< next_bp
; i
++)
580 if (breakpoints
[i
].refcount
&& breakpoints
[i
].type
== DBG_WATCH
)
582 fprintf( stderr
, "%d: %c ", i
, breakpoints
[i
].enabled
? 'y' : 'n');
583 DEBUG_PrintAddress( &breakpoints
[i
].addr
,
584 breakpoints
[i
].is32
? 32 : 16, TRUE
);
585 fprintf( stderr
, " on %d byte%s (%c)\n",
586 breakpoints
[i
].u
.w
.len
+ 1,
587 breakpoints
[i
].u
.w
.len
> 0 ? "s" : "",
588 breakpoints
[i
].u
.w
.rw
? 'W' : 'R');
589 if( breakpoints
[i
].condition
!= NULL
)
591 fprintf(stderr
, "\t\tstop when ");
592 DEBUG_DisplayExpr(breakpoints
[i
].condition
);
593 fprintf(stderr
, "\n");
599 /***********************************************************************
602 * Check whether or not the condition (bp / skipcount) of a break/watch
605 static BOOL
DEBUG_ShallBreak( int bpnum
)
607 if ( breakpoints
[bpnum
].condition
!= NULL
)
609 DBG_VALUE value
= DEBUG_EvalExpr(breakpoints
[bpnum
].condition
);
611 if ( value
.type
== NULL
)
614 * Something wrong - unable to evaluate this expression.
616 fprintf(stderr
, "Unable to evaluate expression ");
617 DEBUG_DisplayExpr(breakpoints
[bpnum
].condition
);
618 fprintf(stderr
, "\nTurning off condition\n");
619 DEBUG_AddBPCondition(bpnum
, NULL
);
621 else if( !DEBUG_GetExprValue( &value
, NULL
) )
627 if ( breakpoints
[bpnum
].skipcount
> 0 && --breakpoints
[bpnum
].skipcount
> 0 )
633 /***********************************************************************
634 * DEBUG_ShouldContinue
636 * Determine if we should continue execution after a SIGTRAP signal when
637 * executing in the given mode.
639 BOOL
DEBUG_ShouldContinue( DWORD code
, enum exec_mode mode
, int * count
)
645 struct symbol_info syminfo
;
648 /* If not single-stepping, back up over the int3 instruction */
649 if (code
== EXCEPTION_BREAKPOINT
)
653 DEBUG_GetCurrentAddress( &addr
);
654 bpnum
= DEBUG_FindBreakpoint( &addr
, DBG_BREAK
);
655 breakpoints
[0].enabled
= FALSE
; /* disable the step-over breakpoint */
657 if ((bpnum
!= 0) && (bpnum
!= -1))
659 if (!DEBUG_ShallBreak(bpnum
)) return TRUE
;
661 fprintf( stderr
, "Stopped on breakpoint %d at ", bpnum
);
662 syminfo
= DEBUG_PrintAddress( &breakpoints
[bpnum
].addr
,
663 breakpoints
[bpnum
].is32
? 32 : 16, TRUE
);
664 fprintf( stderr
, "\n" );
666 if( syminfo
.list
.sourcefile
!= NULL
)
667 DEBUG_List(&syminfo
.list
, NULL
, 0);
671 wpnum
= DEBUG_FindTriggeredWatchpoint(&oldval
);
672 if ((wpnum
!= 0) && (wpnum
!= -1))
674 /* If not single-stepping, do not back up over the int3 instruction */
675 if (code
== EXCEPTION_BREAKPOINT
)
677 EIP_reg(&DEBUG_context
)++;
680 if (!DEBUG_ShallBreak(wpnum
)) return TRUE
;
682 fprintf(stderr
, "Stopped on watchpoint %d at ", wpnum
);
683 syminfo
= DEBUG_PrintAddress( &addr
, !addr
.seg
? 32 :
684 DEBUG_GetSelectorType( addr
.seg
), TRUE
);
686 fprintf(stderr
, " values: old=%lu new=%lu\n",
687 oldval
, breakpoints
[wpnum
].u
.w
.oldval
);
688 if (syminfo
.list
.sourcefile
!= NULL
)
689 DEBUG_List(&syminfo
.list
, NULL
, 0);
694 * If our mode indicates that we are stepping line numbers,
695 * get the current function, and figure out if we are exactly
696 * on a line number or not.
698 if( mode
== EXEC_STEP_OVER
|| mode
== EXEC_STEP_INSTR
)
700 if( DEBUG_CheckLinenoStatus(&addr
) == AT_LINENUMBER
)
705 else if( mode
== EXEC_STEPI_OVER
|| mode
== EXEC_STEPI_INSTR
)
710 if( *count
> 0 || mode
== EXEC_FINISH
)
713 * We still need to execute more instructions.
719 * If we are about to stop, then print out the source line if we
722 if (mode
!= EXEC_CONT
&& mode
!= EXEC_PASS
&& mode
!= EXEC_FINISH
)
724 DEBUG_FindNearestSymbol( &addr
, TRUE
, NULL
, 0, &syminfo
.list
);
725 if( syminfo
.list
.sourcefile
!= NULL
)
727 DEBUG_List(&syminfo
.list
, NULL
, 0);
732 /* If there's no breakpoint and we are not single-stepping, then we */
733 /* must have encountered an int3 in the Windows program; let's skip it. */
734 if ((bpnum
== -1) && code
== EXCEPTION_BREAKPOINT
)
738 /* no breakpoint, continue if in continuous mode */
739 return (mode
== EXEC_CONT
|| mode
== EXEC_PASS
|| mode
== EXEC_FINISH
);
742 /***********************************************************************
743 * DEBUG_RestartExecution
745 * Remove all breakpoints before entering the debug loop
747 void DEBUG_SuspendExecution( void )
749 DEBUG_SetBreakpoints( FALSE
);
750 breakpoints
[0] = DEBUG_CurrThread
->stepOverBP
;
753 /***********************************************************************
754 * DEBUG_RestartExecution
756 * Set the breakpoints to the correct state to restart execution
759 enum exec_mode
DEBUG_RestartExecution( enum exec_mode mode
, int count
)
766 enum exec_mode ret_mode
;
770 DEBUG_GetCurrentAddress( &addr
);
773 * This is the mode we will be running in after we finish. We would like
774 * to be able to modify this in certain cases.
778 bp
= DEBUG_FindBreakpoint( &addr
, DBG_BREAK
);
779 if ( bp
!= -1 && bp
!= 0)
782 * If we have set a new value, then save it in the BP number.
784 if( count
!= 0 && mode
== EXEC_CONT
)
786 breakpoints
[bp
].skipcount
= count
;
788 mode
= EXEC_STEPI_INSTR
; /* If there's a breakpoint, skip it */
792 if( mode
== EXEC_CONT
&& count
> 1 )
794 fprintf(stderr
, "Not stopped at any breakpoint; argument ignored.\n");
798 if( mode
== EXEC_FINISH
&& DEBUG_IsFctReturn() )
800 mode
= ret_mode
= EXEC_STEPI_INSTR
;
803 instr
= DEBUG_ToLinear( &addr
);
804 DEBUG_READ_MEM((void*)instr
, &ch
, sizeof(ch
));
806 * See if the function we are stepping into has debug info
807 * and line numbers. If not, then we step over it instead.
808 * FIXME - we need to check for things like thunks or trampolines,
809 * as the actual function may in fact have debug info.
813 DEBUG_READ_MEM((void*)(instr
+ 1), &delta
, sizeof(delta
));
815 DEBUG_Disasm(&addr2
, FALSE
);
818 status
= DEBUG_CheckLinenoStatus(&addr2
);
820 * Anytime we have a trampoline, step over it.
822 if( ((mode
== EXEC_STEP_OVER
) || (mode
== EXEC_STEPI_OVER
))
823 && status
== FUNC_IS_TRAMPOLINE
)
826 fprintf(stderr
, "Not stepping into trampoline at %x (no lines)\n",
829 mode
= EXEC_STEP_OVER_TRAMPOLINE
;
832 if( mode
== EXEC_STEP_INSTR
&& status
== FUNC_HAS_NO_LINES
)
835 fprintf(stderr
, "Not stepping into function at %x (no lines)\n",
838 mode
= EXEC_STEP_OVER
;
843 if( mode
== EXEC_STEP_INSTR
)
845 if( DEBUG_CheckLinenoStatus(&addr
) == FUNC_HAS_NO_LINES
)
847 fprintf(stderr
, "Single stepping until exit from function, \n");
848 fprintf(stderr
, "which has no line number information.\n");
850 ret_mode
= mode
= EXEC_FINISH
;
856 case EXEC_CONT
: /* Continuous execution */
857 case EXEC_PASS
: /* Continue, passing exception */
859 DEBUG_context
.EFlags
&= ~STEP_FLAG
;
861 DEBUG_SetBreakpoints( TRUE
);
864 case EXEC_STEP_OVER_TRAMPOLINE
:
866 * This is the means by which we step over our conversion stubs
867 * in callfrom*.s and callto*.s. We dig the appropriate address
868 * off the stack, and we set the breakpoint there instead of the
869 * address just after the call.
872 DEBUG_READ_MEM((void*)(DEBUG_context
.Esp
+
873 2 * sizeof(unsigned int)),
874 &addr
.off
, sizeof(addr
.off
));
875 DEBUG_context
.EFlags
&= ~STEP_FLAG
;
877 breakpoints
[0].addr
= addr
;
878 breakpoints
[0].enabled
= TRUE
;
879 breakpoints
[0].refcount
= 1;
880 breakpoints
[0].skipcount
= 0;
881 DEBUG_READ_MEM((void*)DEBUG_ToLinear( &addr
), &breakpoints
[0].u
.opcode
,
883 DEBUG_SetBreakpoints( TRUE
);
887 case EXEC_STEPI_OVER
: /* Stepping over a call */
888 case EXEC_STEP_OVER
: /* Stepping over a call */
889 if (DEBUG_IsStepOverInstr())
892 DEBUG_context
.EFlags
&= ~STEP_FLAG
;
894 DEBUG_Disasm(&addr
, FALSE
);
895 breakpoints
[0].addr
= addr
;
896 breakpoints
[0].enabled
= TRUE
;
897 breakpoints
[0].refcount
= 1;
898 breakpoints
[0].skipcount
= 0;
899 DEBUG_READ_MEM((void*)DEBUG_ToLinear( &addr
), &breakpoints
[0].u
.opcode
,
901 DEBUG_SetBreakpoints( TRUE
);
904 /* else fall through to single-stepping */
906 case EXEC_STEP_INSTR
: /* Single-stepping an instruction */
907 case EXEC_STEPI_INSTR
: /* Single-stepping an instruction */
909 DEBUG_context
.EFlags
|= STEP_FLAG
;
913 RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
915 DEBUG_CurrThread
->stepOverBP
= breakpoints
[0];
920 DEBUG_AddBPCondition(int num
, struct expr
* exp
)
922 if ((num
<= 0) || (num
>= next_bp
) || !breakpoints
[num
].refcount
)
924 fprintf( stderr
, "Invalid breakpoint number %d\n", num
);
928 if( breakpoints
[num
].condition
!= NULL
)
930 DEBUG_FreeExpr(breakpoints
[num
].condition
);
931 breakpoints
[num
].condition
= NULL
;
936 breakpoints
[num
].condition
= DEBUG_CloneExpr(exp
);