static int ClearDebugRegs( int trap ) { long dr6; int i; if( Flags.DRsOn ) { out( "tr=" ); out( hex( trap ) ); out( " dr6=" ); out( hex( GetDR6() ) ); out( "\r\n" ); if( trap == TRAP_WATCH_POINT ) { /* could be a 386 break point */ dr6 = GetDR6(); if( ( ( dr6 & DR6_B0 ) && IsBreak[0] ) || ( ( dr6 & DR6_B1 ) && IsBreak[1] ) || ( ( dr6 & DR6_B2 ) && IsBreak[2] ) || ( ( dr6 & DR6_B3 ) && IsBreak[3] ) ) { trap = TRAP_BREAK_POINT; } } for( i = 0; i < 4; ++i ) { IsBreak[ i ] = FALSE; } SetDR6( 0 ); SetDR7( 0 ); } return( trap ); }
/* * runProg: * * - we turn on the T-bit for single_step mode, and set the debug registers * for watch points (if we can). * - we then switch to the debuggee, and wait for a fault to occur. * - after the fault, we record information about it and return * */ static unsigned runProg( bool single_step ) { private_msg pmsg; BOOL watch386; BOOL dowatch; BOOL ton; restart_opts restart_option; prog_go_ret *ret; ret = GetOutPtr( 0 ); if( DebugeeTask == NULL ) { ret->conditions = COND_TERMINATE; return( sizeof( *ret ) ); } IntResult.EFlags &= ~TRACE_BIT; dowatch = FALSE; watch386 = FALSE; UnLockInput(); if( single_step ) { SingleStepMode(); } else if( WPCount != 0 ) { dowatch = TRUE; watch386 = SetDebugRegs(); } ret->conditions = 0; restart_option = RESTART_APP; while( DebugeeTask != NULL ) { if( dowatch && !watch386 ) { SingleStepMode(); } ton = TraceOn; pmsg = DebuggerWaitForMessage( RUNNING_DEBUGEE, TaskAtFault, restart_option ); TraceOn = FALSE; if( pmsg == FAULT_HIT ) { switch( IntResult.InterruptNumber ) { case INT_1: ret->conditions = COND_TRACE; if( watch386 ) { if( GetDR6() & 0xf ) { ret->conditions = COND_WATCH; if( DebugDebugeeOnly ) { if( !CheckWatchPoints() ) { restart_option = CHAIN; continue; } } } break; } if( !ton && DebugDebugeeOnly ) { restart_option = CHAIN; continue; } if( dowatch ) { if( CheckWatchPoints() ) { ret->conditions = COND_WATCH; } else { restart_option = RESTART_APP; continue; } } break; case INT_3: if( DebugDebugeeOnly ) { if( !IsOurBreakpoint( IntResult.CS, IntResult.EIP ) ) { IntResult.EIP++; restart_option = CHAIN; continue; } } ret->conditions = COND_BREAK; break; default: if( DebugDebugeeOnly ) { if( TaskAtFault != DebugeeTask ) { restart_option = CHAIN; continue; } } ret->conditions = COND_EXCEPTION; break; } break; } else if( pmsg == TASK_ENDED ) { ret->conditions = COND_TERMINATE; DebugeeTask = NULL; IntResult.CS = TerminateCSIP >> 16; IntResult.EIP = (DWORD) (WORD) TerminateCSIP; break; } else if( pmsg == GET_CHAR ) {