示例#1
0
    CNamedEvent* Context::FindNamedEventTemplate(const CTagObject::MethodsContainer& methods, const char* eventName)
    {
        CStringID eventID(eventName);

        //reverse, so the event in the derived class can override the one in the base class
        for (CTagObject::MethodsContainer::const_reverse_iterator it = methods.rbegin(); it != methods.rend(); ++it)
        {
            const CMethodBase* pMethod = *it;

            const char* methodName = pMethod->GetName();
            CStringID methodID(methodName);

            if (methodID == eventID && pMethod->IsNamedEvent())
            {
                CNamedEvent* pNamedMethod = (CNamedEvent*)pMethod;

                if (pNamedMethod->IsStatic())
                {
                    InsertEventGlobal(pNamedMethod->GetClassNameString(), pNamedMethod);
                    return pNamedMethod;
                }

                return pNamedMethod;
            }
        }

        return 0;
    }
示例#2
0
	std::wstring render(bool propper, std::wstring syntax, std::wstring date_format = DATE_FORMAT, DWORD langId = 0) const {
		if (propper) {
			// To obtain the appropriate message string from the message file, load the message file with the LoadLibrary function and use the FormatMessage function
			strEx::replace(syntax, _T("%message%"), render_message(langId));
		} else {
			strEx::replace(syntax, _T("%message%"), _T("%message% needs the descriptions flag set!"));
		}

		strEx::replace(syntax, _T("%source%"), get_source());
		strEx::replace(syntax, _T("%computer%"), get_computer());
		strEx::replace(syntax, _T("%generated%"), strEx::format_date(get_time_generated(), date_format));
		strEx::replace(syntax, _T("%written%"), strEx::format_date(get_time_written(), date_format));
		strEx::replace(syntax, _T("%generated-raw%"), strEx::itos(pevlr_->TimeGenerated));
		strEx::replace(syntax, _T("%written-raw%"), strEx::itos(pevlr_->TimeWritten));
		strEx::replace(syntax, _T("%type%"), translateType(eventType()));
		strEx::replace(syntax, _T("%category%"), strEx::itos(pevlr_->EventCategory));
		strEx::replace(syntax, _T("%facility%"), strEx::itos(facility()));
		strEx::replace(syntax, _T("%qualifier%"), strEx::itos(facility()));
		strEx::replace(syntax, _T("%customer%"), strEx::itos(customer()));
		strEx::replace(syntax, _T("%rawid%"), strEx::itos(raw_id()));
		strEx::replace(syntax, _T("%severity%"), translateSeverity(severity()));
		strEx::replace(syntax, _T("%strings%"), enumStrings());
		strEx::replace(syntax, _T("%log%"), file_);
		strEx::replace(syntax, _T("%file%"), file_);
		strEx::replace(syntax, _T("%id%"), strEx::itos(eventID()));
		strEx::replace(syntax, _T("%user%"), userSID());
		return syntax;
	}
示例#3
0
	std::wstring render_message(const int truncate_message, DWORD dwLang = 0) const {
		std::vector<std::wstring> args;
		std::wstring ret;
		std::wstring file;
		if (!get_dll(file)) {
			return file;
		}
		strEx::splitList dlls = strEx::splitEx(file, _T(";"));
		for (strEx::splitList::const_iterator cit = dlls.begin(); cit != dlls.end(); ++cit) {
			//std::wstring msg = error::format::message::from_module((*cit), eventID(), _sz);
			std::wstring msg;
			try {
				HMODULE hDLL = LoadLibraryEx((*cit).c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES);
				if (hDLL == NULL) {
					msg = _T("failed to load: ") + (*cit) + _T(", reason: ") + strEx::itos(GetLastError());
					continue;
				}
				if (dwLang == 0)
					dwLang = MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT);
				boost::tuple<DWORD,std::wstring> formated_data = safe_format(hDLL, dwLang);
				if (formated_data.get<0>() != 0) {
					FreeLibrary(hDLL);
					if (formated_data.get<0>() == 15100) {
						// Invalid MUI file (wrong language)
						msg = _T("");
						continue;
					}
					if (formated_data.get<0>() == 317) {
						// Missing message
						msg = _T("");
						continue;
					}
					msg = _T("failed to lookup error code: ") + strEx::itos(eventID()) + _T(" from DLL: ") + (*cit) + _T("( reason: ") + strEx::itos(formated_data.get<0>()) + _T(")");
					continue;
				}
				FreeLibrary(hDLL);
				msg = formated_data.get<1>();
			} catch (...) {
				msg = _T("Unknown exception getting message");
			}
			strEx::replace(msg, _T("\n"), _T(" "));
			strEx::replace(msg, _T("\t"), _T(" "));
			std::string::size_type pos = msg.find_last_not_of(_T("\n\t "));
			if (pos != std::string::npos) {
				msg = msg.substr(0,pos);
			}
			if (!msg.empty()) {
				if (!ret.empty())
					ret += _T(", ");
				ret += msg;
			}
		}
		if (truncate_message > 0 && ret.length() > truncate_message)
			ret = ret.substr(0, truncate_message);
		return ret;
	}
示例#4
0
    const CNamedEvent* Context::FindEventStatic(const char* eventName, const char* className)
    {
        AgentStaticEvents_t::iterator it = ms_eventInfosGlobal.find(className);

        if (it != ms_eventInfosGlobal.end())
        {
            AgentEvents_t& events = it->second;
            CStringID eventID(eventName);
            AgentEvents_t::iterator itevt = events.find(eventID);

            if (itevt != events.end())
            {
                CNamedEvent* pEvent = itevt->second;
                return pEvent;
            }
        }

        return 0;
    }
示例#5
0
文件: gvt.C 项目: davidheryanto/sc14
/// Basic Constructor
PVT::PVT() 
{
#ifdef VERBOSE_DEBUG
  CkPrintf("[%d] constructing PVT\n",CkMyPe());
#endif
  CpvInitialize(int, stateRecovery);
  CpvAccess(stateRecovery) = 0;
  CpvInitialize(eventID, theEventID);
  CpvAccess(theEventID)=eventID();
  //  CpvAccess(theEventID).dump();
  //LBTurnInstrumentOff();
  optGVT = POSE_UnsetTS; conGVT = POSE_UnsetTS;
  rdone=0;
  SRs=NULL;
#ifdef POSE_COMM_ON
  //com_debug = 1;
#endif
#ifndef CMK_OPTIMIZE
  localStats = (localStat *)CkLocalBranch(theLocalStats);
  if (pose_config.stats) {
    localStats->TimerStart(GVT_TIMER);
  }
#endif
#ifdef MEM_TEMPORAL
  localTimePool = (TimePool *)CkLocalBranch(TempMemID);
  CkPrintf("NOTE: Temporal memory manager is ON!\n");
#endif
  optPVT = conPVT = estGVT = POSE_UnsetTS;
  startPhaseActive = gvtTurn = simdone = 0;
  SendsAndRecvs = new SRtable();
  SendsAndRecvs->Initialize();
  specEventCount = eventCount = waitForFirst = 0;
  iterMin = POSE_UnsetTS;
  int P=CkNumPes(), N=CkMyPe();
  reportReduceTo =  -1;
  if ((N < P-2) && (N%2 == 1)) { //odd
    reportTo = N-1;
    reportsExpected = reportEnd = 0;
  }
  else if (N < P-2) { //even
    reportTo = N;
    reportsExpected = 2; 
    if (N == P-3)
      reportsExpected = 1;
    reportEnd = 0;
    if (N < (P-2)/2)
      reportReduceTo = P-2;
    else reportReduceTo = P-1;
  }
  if (N == P-2) {
    reportTo = N;
    reportEnd = 1;
    reportsExpected = 1 + (P-2)/4 + ((P-2)%4)/2;
  }
  else if (N == P-1) {
    reportTo = N;
    reportEnd = 1;
    if (P==1) reportsExpected = 1;
    else reportsExpected = 1 + (P-2)/4 + (P-2)%2;
  }
  //  CkPrintf("PE %d reports to %d, receives %d reports, reduces and sends to %d, and reports directly to GVT if %d = 1!\n", CkMyPe(), reportTo, reportsExpected, reportReduceTo, reportEnd);

  parCheckpointInProgress = 0;
  parLastCheckpointGVT = 0;
  parLastCheckpointTime = parStartTime = 0.0;
  parLBInProgress = 0;
  parLastLBGVT = 0;
  //  debugBufferLoc = debugBufferWrapped = debugBufferDumped = 0;
#ifndef CMK_OPTIMIZE
  if(pose_config.stats)
    localStats->TimerStop();
#endif

  LBDatabase::Object()->AddMigrationDoneFn(staticDoneLB, this);
}