コード例 #1
0
ファイル: workspace.cpp プロジェクト: LacusCon/behaviac
    bool Workspace::HandleRequests()
    {
        bool bContinue = false;

#if !BEHAVIAC_RELEASE

        if (Config::IsSocketing())
        {
            behaviac::string command;

            if (Socket::ReadText(command))
            {
                const char* kBreakpoint = "[breakpoint]";
                const char* kProperty = "[property]";
                const char* kProfiling = "[profiling]";
                const char* kStart = "[start]";
                const char* kAppLogFilter = "[applogfilter]";
                const char* kContinue = "[continue]";
                const char* kCloseConnection = "[closeconnection]";

                behaviac::vector<behaviac::string> cs;
                behaviac::StringUtils::SplitIntoArray(command.c_str(), "\n", cs);

                for (behaviac::vector<behaviac::string>::iterator it = cs.begin(); it != cs.end(); ++it)
                {
                    behaviac::string& c = *it;

                    if (c.empty())
                    {
                        continue;
                    }

                    behaviac::vector<behaviac::string> tokens;
                    behaviac::StringUtils::SplitIntoArray(c.c_str(), " ", tokens);

                    if (tokens[0] == kBreakpoint)
                    {
                        ParseBreakpoint(tokens);
                    }
                    else if (tokens[0] == kProperty)
                    {
                        ParseProperty(tokens);
                    }
                    else if (tokens[0] == kProfiling)
                    {
                        ParseProfiling(tokens);
                    }
                    else if (tokens[0] == kStart)
                    {
                        m_breakpoints.clear();
                        bContinue = true;
                    }
                    else if (tokens[0] == kAppLogFilter)
                    {
                        ParseAppLogFilter(tokens);
                    }
                    else if (tokens[0] == kContinue)
                    {
                        bContinue = true;
                    }
                    else if (tokens[0] == kCloseConnection)
                    {
                        m_breakpoints.clear();
                        bContinue = true;
                    }
                    else
                    {
                        BEHAVIAC_ASSERT(0);
                    }
                }//end of for
            }//end of if (Socket::ReadText(command))

        }
        else
        {
            bContinue = true;
        }

#endif//BEHAVIAC_RELEASE

        return bContinue;
    }
コード例 #2
0
//ab Add Breakpoint
//rb Remove Breakpoint
//sp Suspend
void SQDbgServer::ParseMsg(const char *msg)
{
	
	switch(*((unsigned short *)msg)){
		case MSG_ID('a','b'): {
			BreakPoint bp;
			if(ParseBreakpoint(msg+3,bp)){
				AddBreakpoint(bp);
				scprintf(_SC("added bp %d %s\n"),bp._line,bp._src.c_str());
			}
			else
				scprintf(_SC("error parsing add breakpoint"));
							 }
			break;
		case MSG_ID('r','b'): {
			BreakPoint bp;
			if(ParseBreakpoint(msg+3,bp)){
				RemoveBreakpoint(bp);
				scprintf(_SC("removed bp %d %s\n"),bp._line,bp._src.c_str());
			}else
				scprintf(_SC("error parsing remove breakpoint"));
							}
			break;
		case MSG_ID('g','o'):
			if(_state!=eDBG_Running){
				_state=eDBG_Running;
				BeginDocument();
					BeginElement(_SC("resumed"));
					EndElement(_SC("resumed"));
				EndDocument();
//				Send(_SC("<resumed/>\r\n"));
				scprintf(_SC("go (execution resumed)\n"));
			}
			break;
		case MSG_ID('s','p'):
			if(_state!=eDBG_Suspended){
				_state=eDBG_Suspended;
				scprintf(_SC("suspend\n"));
			}
			break;
		case MSG_ID('s','o'):
			if(_state==eDBG_Suspended){
				_state=eDBG_StepOver;
			}
			break;
		case MSG_ID('s','i'):
			if(_state==eDBG_Suspended){
				_state=eDBG_StepInto;
				scprintf(_SC("step into\n"));
			}
			break;
		case MSG_ID('s','r'):
			if(_state==eDBG_Suspended){
				_state=eDBG_StepReturn;
				scprintf(_SC("step return\n"));
			}
			break;
		case MSG_ID('d','i'):
			if(_state!=eDBG_Disabled){
				_state=eDBG_Disabled;
				scprintf(_SC("disabled\n"));
			}
			break;
		case MSG_ID('a','w'): {
			Watch w;
			if(ParseWatch(msg+3,w))
			{
				AddWatch(w);
				scprintf(_SC("added watch %d %s\n"),w._id,w._exp.c_str());
			}
			else
				scprintf(_SC("error parsing add watch"));
								}
			break;
		case MSG_ID('r','w'): {
			int id;
			if(ParseRemoveWatch(msg+3,id))
			{
				RemoveWatch(id);
				scprintf(_SC("added watch %d\n"),id);
			}
			else
				scprintf(_SC("error parsing remove watch"));
								}
			break;
		case MSG_ID('t','r'):
			scprintf(_SC("terminate from user\n"));
			break;
		case MSG_ID('r','d'):
			scprintf(_SC("ready\n"));
			_ready=true;
			break;
		default:
			scprintf(_SC("unknown packet"));

	}
}