Esempio n. 1
0
    virtual bool
    DoExecute (lldb::SBDebugger debugger,
               char** arguments,
               lldb::SBCommandReturnObject &result)
    {
        LLDBServices* services = new LLDBServices(debugger, result);
        LoadSos(services);

        if (m_sosHandle)
        {
            const char* sosCommand = m_command;
            if (sosCommand == NULL) 
            {
                if (arguments == NULL || *arguments == NULL) {
                    sosCommand = "Help";
                }
                else
                {
                    sosCommand = *arguments++;
                }
            }
            CommandFunc commandFunc = (CommandFunc)dlsym(m_sosHandle, sosCommand);
            if (commandFunc)
            {
                std::string str;
                if (arguments != NULL)
                {
                    for (const char* arg = *arguments; arg; arg = *(++arguments))
                    {
                        str.append(arg);
                        str.append(" ");
                    }
                }
                const char* sosArgs = str.c_str();
                HRESULT hr = commandFunc(services, sosArgs);
                if (hr != S_OK)
                {
                    services->Output(DEBUG_OUTPUT_ERROR, "%s %s failed\n", sosCommand, sosArgs);
                }
            }
            else
            {
                services->Output(DEBUG_OUTPUT_ERROR, "SOS command '%s' not found %s\n", sosCommand, dlerror());
            }
        }

        services->Release();
        return result.Succeeded();
    }
Esempio n. 2
0
int CSapStack::LoadConfig(const char* pConfig)
{
    SS_XLOG(XLOG_DEBUG,"CSapStack::LoadConfig\n");
    CXmlConfigParser oConfig;
    if(oConfig.ParseFile(pConfig)!=0)
    {
        SS_XLOG(XLOG_ERROR, "CSapStack::%s,parse config error:%s\n", __FUNCTION__,
                oConfig.GetErrorMessage().c_str());
        return -1;
    }    
	
    /*read soc basic*/
    Init(oConfig.GetParameter("IsAuthSoc", 0),
        oConfig.GetParameter("IsVerifySocSignature", 0),
        oConfig.GetParameter("IsSocEnc", 0),
        oConfig.GetParameter("LocalKey", "snda123@sdo456"));

	/*temp config*/
	isAsc=oConfig.GetParameter("IsAsc", 1);

    nLogType = oConfig.GetParameter("LogType", 0);

    /*read sos config*/
    vector<SSosStruct> vecSos;
    vector<string> vecSosStri=oConfig.GetParameters("SosList");
    vector<string>::iterator itrSosStr;
    for(itrSosStr=vecSosStri.begin();itrSosStr!=vecSosStri.end();++itrSosStr)
    {
        string strDetail=*itrSosStr;
        CXmlConfigParser oDetailConfig;
        oDetailConfig.ParseDetailBuffer(strDetail.c_str());

        SSosStruct oSos;
		string strServiceId=oDetailConfig.GetParameter("ServiceId","0");
		string strServiceIdMessageId=oDetailConfig.GetParameter("ServiceIdMessageId","0");
		vector<string> vecService;
		boost::algorithm::split( vecService, strServiceId, boost::algorithm::is_any_of(","), boost::algorithm::token_compress_on); 
		for (vector<string>::iterator istr = vecService.begin(); 
			istr != vecService.end(); ++istr)
		{
            unsigned serviceId = atoi(istr->c_str());
			oSos.vecServiceId.push_back(serviceId);

            m_minDataServiceId = serviceId > m_minDataServiceId ? 
                serviceId + 10000 - ((serviceId + 10000) % 10000) : m_minDataServiceId;
		}
		sort(oSos.vecServiceId.begin(),oSos.vecServiceId.end());
        oSos.vecAddr=oDetailConfig.GetParameters("ServerAddr");
        sort(oSos.vecAddr.begin(),oSos.vecAddr.end());
		if (strcmp(strServiceIdMessageId.c_str(),"0")!=0)
		{
			vector<string> vecServiceMessage;
			boost::algorithm::split( vecServiceMessage, strServiceIdMessageId, boost::algorithm::is_any_of(","), boost::algorithm::token_compress_on); 
			for (vector<string>::iterator istr = vecServiceMessage.begin(); istr != vecServiceMessage.end(); ++istr)
			{
				vector<string> vecs;
				boost::algorithm::split( vecs, *istr, boost::algorithm::is_any_of("_"), boost::algorithm::token_compress_on); 
				if (vecs.size()!=2)
					continue;
				unsigned int serviceId = atoi(vecs[0].c_str());
				unsigned int messageId = atoi(vecs[1].c_str());
				TServiceIdMessageId sm;
				sm.dwServiceId = serviceId;
				sm.dwMessageId = messageId;
				oSos.vecServiceIdMessageId.push_back(sm);
			}
		}
        vecSos.push_back(oSos);
    }

    /*read data server sos config*/
    vecSosStri = oConfig.GetParameters("DataServerList");
    for(itrSosStr=vecSosStri.begin();itrSosStr!=vecSosStri.end();++itrSosStr)
    {
        string strDetail=*itrSosStr;
        CXmlConfigParser oDetailConfig;
        oDetailConfig.ParseDetailBuffer(strDetail.c_str());

        SSosStruct oSos;
        string strServiceId=oDetailConfig.GetParameter("DataServerId","0");
        vector<string> vecService;
        boost::algorithm::split( vecService, strServiceId, boost::algorithm::is_any_of(","), boost::algorithm::token_compress_on); 
        for (vector<string>::iterator istr = vecService.begin(); 
            istr != vecService.end(); ++istr)
        {
            unsigned serviceId = atoi(istr->c_str()) + m_minDataServiceId;
            oSos.vecServiceId.push_back(serviceId);
        }
        sort(oSos.vecServiceId.begin(),oSos.vecServiceId.end());
        oSos.vecAddr=oDetailConfig.GetParameters("ServerAddr");
        sort(oSos.vecAddr.begin(),oSos.vecAddr.end());
        vecSos.push_back(oSos);
    }

    for (vector<SSosStruct>::const_iterator itr = vecSos.begin(); itr != vecSos.end(); ++itr)
    {
        SS_XLOG(XLOG_DEBUG,"id[%u]  address[%s]\n",itr->vecServiceId[0], itr->vecAddr[0].c_str());
    }

    LoadSos(vecSos);

    /*read soc config*/
    LoadSuperSoc(oConfig.GetParameters("SuperList/Addr"),oConfig.GetParameters("SuperPrivilege/Privilege"));
    /*if (CTriggerConfig::Instance()->LoadConfig("./trigger_config.xml")!=0||
        CKeyConfig::Instance()->LoadConfig("./key_config.xml") !=0)
    {
        SS_XLOG(XLOG_ERROR, "load trigger or key config error\n"); 
        return -1;
    }*/

    if (CTriggerConfig::Instance()->LoadConfig("./trigger_config.xml")!=0)
    {
        SS_XLOG(XLOG_ERROR, "load trigger config error\n"); 
        return -1;
    }
    return 0;
}