logical DLInterpreter :: SETBREAK ( )
{
  logical                 term = NO;
BEGINSEQ
  if ( !GetOption('h') )
    if ( Parm(0) )
      SetBreakPoint(Parm(0));   
    else   
      SetBreakPoint(YES);   
  else
  {
//                                 :   
    Output("set break point        : SetBreak|dsb [proc_name]\n");
    if ( !GetOption('d') )                           LEAVESEQ

//                   1         2         3         4         5         6         7         8
//          12345678901234567890123456789012345678901234567890123456789012345678901234567890   
    Output("  The command sets a break point at the current position.\n");
    Output("  \n");
//                        -
    Output("  proc_name   - A procedure name containing a list of commands to be executed\n");
    Output("                when reaching the breakpoint. The Commandlist must be loaded \n");
    Output("                from the calling environment, e.g. the calling OShell.\n");
    Output("  \n");
    Output("Examples\n");
//                              :
    Output("  dsb bp10          : set breakpont at current line and call procedure bp10 \n"); 
    Output("                      always when reaching the breakpoint.\n"); 
  }

ENDSEQ
  return(term);
}
示例#2
0
bool CODebugger::InstallBreakPoint(DEBUGGER_BREAKPOINT& bp,bool bNoSearch)
{
	DEBUGGER_BREAKPOINT* p_debugger_breakpoint = 0;
	if(bNoSearch)
	{
		//添加一个新断点
		p_debugger_breakpoint = m_breakPointListUser.Add(bp);
	}
	else
	{
		p_debugger_breakpoint = m_breakPointListUser.Search(bp.m_uiAddress);
		if(p_debugger_breakpoint)
		{
			p_debugger_breakpoint->m_bIsSingleLineBP = bp.m_bIsSingleLineBP;

			//断点已经被安装
			if(p_debugger_breakpoint->m_bInstalled)
			{
				return true;	
			}
		}
		else
		{
			//没有找到指定地址的断点就添加一个断点
			p_debugger_breakpoint = m_breakPointListUser.Add(bp);
		}	
	}	

	return SetBreakPoint(p_debugger_breakpoint);
}
logical OPSynCase :: CreateStatements ( )
{
  BNFData                *oper;
  int32                   index = 0;
  logical                 term = NO;
BEGINSEQ
// case_stmt  := [debug_opt] _case simple_op ':' statement(*)
// other_stmt := [debug_opt] _default ':' statement(*)
  
  if ( operand_bnf->GetElement(0)->IsSymbol("debug_opt") )
  {
    SetBreakPoint(operand_bnf->GetElement(0));
    index = 1;
  }
  
  oper = operand_bnf->GetElement(index);
  switch ( oper->GetSymbolCode("_default","_case") )
  {
    case 1 : block_type = CB_DefaultBlock;
             break;
    case 2 : block_type = CB_CaseBlock;
             if ( ProvideSimpleOp(operand_bnf->GetElement(index+1)) )
                                                     ERROR
             break;
    default: OQLSERR(99)
  }
  if ( ProvideBlock(operand_bnf,block_type) )        ERROR

RECOVER
  term = YES;
ENDSEQ
  return(term);
}
示例#4
0
void CODebugger::InstallAllSingleLineBreakPoint()
{
	DEBUGGER_BREAKPOINT* p_debugger_breakpoint = 0;
	for(m_breakPointListUser.GetFirstElement();!m_breakPointListUser.isEnd();m_breakPointListUser.GetNextElement())
	{
		p_debugger_breakpoint = m_breakPointListUser.GetCurBreakPoint();
		if( (p_debugger_breakpoint->m_bIsSingleLineBP)    && 
			(p_debugger_breakpoint->m_bInstalled == false) && 
			(p_debugger_breakpoint->m_uiAddress != GetCurBreakPointAddr()))
		{
			SetBreakPoint(p_debugger_breakpoint);
		}
	}
}
logical DLInterpreter :: RESETBREAK ( )
{
  logical                 term = NO;
BEGINSEQ
  if ( !GetOption('h') )
    SetBreakPoint(NO);      
  else
  {
//                                 :   
    Output("reset break point      : ResetBreak|drb \n");
    if ( !GetOption('d') )                           LEAVESEQ

//                   1         2         3         4         5         6         7         8
//          12345678901234567890123456789012345678901234567890123456789012345678901234567890   
    Output("  The command sets a break point at the current position.\n");
    Output("  \n");
//                        -
  }

ENDSEQ
  return(term);
}
示例#6
0
// 中断处理程序
BOOL CODebugger::OnDebugException(DEBUG_EVENT& deDebugEvent)
{
	unsigned long ulAddress = (unsigned long)deDebugEvent.u.Exception.ExceptionRecord.ExceptionAddress;

	//处理异常
	switch (deDebugEvent.u.Exception.ExceptionRecord.ExceptionCode) 
	{ 
		//断点异常
	case EXCEPTION_BREAKPOINT:
		{			
			//发生断点异常的地址			
			DEBUGGER_BREAKPOINT* pBreakPoint = m_breakPointListUser.Search(ulAddress); //搜索断点
			if(pBreakPoint == NULL) //断点不在断点列表内
			{
				break;
			}

			m_ulCurBreakPointAddr = ulAddress;

			//断点发生
			E_Breakpoint(&deDebugEvent);
			if(bpfunc != NULL)
			{
				(*bpfunc)(&deDebugEvent);
			}

			//得到线程
			HANDLE hThread = m_debuggerThread.Search(deDebugEvent.dwThreadId)->m_hThread;

			CONTEXT ct;
			//得到线程上下文
			ct.ContextFlags = CONTEXT_FULL;
			if(hThread && GetThreadContext(hThread, &ct))
			{
				//将原来的代码写回
				RestoreBreakPoint(pBreakPoint);
				
				//暂停所有其他线程,保证单步执行不被其他线程中断
				SuspendAllThread(hThread);

				//Eip指针减1,指向原来代码的运行处
				ct.Eip--;

				//设置单步运行
				ct.EFlags |= EFLAGS_TRAP;

				//添加单步执行
				if(pBreakPoint->m_bIsSingleLineBP == false)
				{
					DEBUGGER_SINGLE_STEP singleStep;
					singleStep.m_uiAddress = ulAddress;
					singleStep.m_uiThreadID = deDebugEvent.dwThreadId;
					m_singleStepList.Add(singleStep);
				}
				
				//设置线程的上下文信息
				SetThreadContext(hThread, &ct);

				return true;
			}
			
			break;
		}

		//单步异常
	case EXCEPTION_SINGLE_STEP:
		{
			E_SingleStep(&deDebugEvent);

			//得到单步断点的指针
			DEBUGGER_SINGLE_STEP* pSingleStep = NULL;
			pSingleStep = m_singleStepList.SearchThread(deDebugEvent.dwThreadId);
			if(pSingleStep)
			{
				//重新设置断点
				DEBUGGER_BREAKPOINT* pDbp = m_breakPointListUser.Search(pSingleStep->m_uiAddress);
				if(pDbp && (pDbp->m_bIsSingleLineBP == false))
				{
					SetBreakPoint(pDbp);
				}

				m_singleStepList.RemoveData(pSingleStep);

				ResumeAllThread(deDebugEvent.dwThreadId);
			}

			break;
		}

		//
		//下面的异常事件不关心,按默认处理
		//

		//违规访问
	case EXCEPTION_ACCESS_VIOLATION:
		{
			E_AccessViolation(&deDebugEvent);
			if (deDebugEvent.u.Exception.dwFirstChance) 
			{
				if(unhfunc != NULL)
				{
					(*unhfunc)(&deDebugEvent); 
				}
				else
				{
					default_unhandled(&deDebugEvent);
				}
			}

			break;
		}

	case EXCEPTION_PRIV_INSTRUCTION: 				
		{
			if ((deDebugEvent.u.Exception.dwFirstChance == 0) || 
				(deDebugEvent.u.Exception.ExceptionRecord.ExceptionFlags == EXCEPTION_NONCONTINUABLE) ) 
			{						
				if(unhfunc != NULL)
				{
					(*unhfunc)(&deDebugEvent); 
				}
				else
				{
					default_unhandled(&deDebugEvent);
				}
			}

			break;
		}

		/*
		case EXCEPTION_DATATYPE_MISALIGNMENT: 	
		//按Ctrl+C 键
		case DBG_CONTROL_C:
		case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
		case EXCEPTION_ILLEGAL_INSTRUCTION:
		case EXCEPTION_IN_PAGE_ERROR:
		case EXCEPTION_INT_DIVIDE_BY_ZERO:
		case EXCEPTION_INT_OVERFLOW:			
		case EXCEPTION_STACK_OVERFLOW:
		*/
	default:
		{
			if(deDebugEvent.u.Exception.dwFirstChance == 0) 
			{				
				if(unhfunc != NULL)
				{
					(*unhfunc)(&deDebugEvent); 
				}
				else
				{
					default_unhandled(&deDebugEvent);
				}
			}
			
			return FALSE;
		}
	} 

	return TRUE;
}