void ProfilerThread::run() { //------------------------------------------------------------------------ //load up the debug info for it // //there's a potential problem here - if a module is unloaded after this, //we won't know about it. likewise, modules could be loaded at the same //address at different points in time. perhaps ideally we may need to //hook LoadLibrary/FreeLibrary calls? I suspect it's not much of a problem //in practice though. (bear in mind we can't load symbols once the process //has exited, so we have to do it up front...) //------------------------------------------------------------------------ try { sym_info.loadSymbols(target_process); } catch(SymbolInfoExcep& e) { error("SymbolInfoExcep: " + e.what()); return; } DWORD startTick = GetTickCount(); try { sampleLoop(); } catch(ProfilerExcep& e) { // see if it's an actual error, or did the thread just finish naturally for(std::vector<Profiler>::const_iterator it = profilers.begin(); it != profilers.end(); ++it) { const Profiler& profiler(*it); if (!profiler.targetExited()) { error("ProfilerExcep: " + e.what()); return; } } numThreadsRunning = 0; } DWORD endTick = GetTickCount(); int diff = endTick - startTick; duration = diff / 1000.0; saveData(); symbolsPercent = 100; std::cout << "Profiling successfully completed." << std::endl; //::MessageBox(NULL, "Profiling successfully completed.", "Profiler", MB_OK); }
/* Function that runs the application */ INT CXBApplicationEx::Run() { CLog::Log(LOGNOTICE, "Running the application..." ); unsigned int lastFrameTime = 0; unsigned int frameTime = 0; const unsigned int noRenderFrameTime = 15; // Simulates ~66fps #ifdef XBMC_TRACK_EXCEPTIONS BYTE processExceptionCount = 0; BYTE frameMoveExceptionCount = 0; BYTE renderExceptionCount = 0; const BYTE MAX_EXCEPTION_COUNT = 10; #endif // Run xbmc while (!m_bStop) { #ifdef HAS_PERFORMANCE_SAMPLE CPerformanceSample sampleLoop("XBApplicationEx-loop"); #endif //----------------------------------------- // Animate and render a frame //----------------------------------------- #ifdef XBMC_TRACK_EXCEPTIONS try { #endif lastFrameTime = XbmcThreads::SystemClockMillis(); Process(); //reset exception count #ifdef XBMC_TRACK_EXCEPTIONS processExceptionCount = 0; } catch (const XbmcCommons::UncheckedException &e) { e.LogThrowMessage("CApplication::Process()"); processExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (processExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions"); throw; } } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::Process()"); processExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (processExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions"); throw; } } #endif // Frame move the scene #ifdef XBMC_TRACK_EXCEPTIONS try { #endif if (!m_bStop) FrameMove(true, m_renderGUI); //reset exception count #ifdef XBMC_TRACK_EXCEPTIONS frameMoveExceptionCount = 0; } catch (const XbmcCommons::UncheckedException &e) { e.LogThrowMessage("CApplication::FrameMove()"); frameMoveExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (frameMoveExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::FrameMove(), too many exceptions"); throw; } } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::FrameMove()"); frameMoveExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (frameMoveExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::FrameMove(), too many exceptions"); throw; } } #endif // Render the scene #ifdef XBMC_TRACK_EXCEPTIONS try { #endif if (m_renderGUI && !m_bStop) Render(); else if (!m_renderGUI) { frameTime = XbmcThreads::SystemClockMillis() - lastFrameTime; if(frameTime < noRenderFrameTime) Sleep(noRenderFrameTime - frameTime); } #ifdef XBMC_TRACK_EXCEPTIONS //reset exception count renderExceptionCount = 0; } catch (const XbmcCommons::UncheckedException &e) { e.LogThrowMessage("CApplication::Render()"); renderExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (renderExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::Render(), too many exceptions"); throw; } } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::Render()"); renderExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (renderExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::Render(), too many exceptions"); throw; } } #endif } // while (!m_bStop) Destroy(); CLog::Log(LOGNOTICE, "application stopped..." ); return m_ExitCode; }
/* Function that runs the application */ INT CXBApplicationEx::Run(CFileItemList &playlist) { CLog::Log(LOGNOTICE, "Running the application..." ); unsigned int lastFrameTime = 0; unsigned int frameTime = 0; const unsigned int noRenderFrameTime = 15; // Simulates ~66fps if (playlist.Size() > 0) { g_playlistPlayer.Add(0, playlist); g_playlistPlayer.SetCurrentPlaylist(0); KODI::MESSAGING::CApplicationMessenger::GetInstance().PostMsg(TMSG_PLAYLISTPLAYER_PLAY, -1); } // Run xbmc while (!m_bStop) { #ifdef HAS_PERFORMANCE_SAMPLE CPerformanceSample sampleLoop("XBApplicationEx-loop"); #endif //----------------------------------------- // Animate and render a frame //----------------------------------------- #ifdef XBMC_TRACK_EXCEPTIONS try { #endif lastFrameTime = XbmcThreads::SystemClockMillis(); Process(); //reset exception count #ifdef XBMC_TRACK_EXCEPTIONS } catch (const XbmcCommons::UncheckedException &e) { e.LogThrowMessage("CApplication::Process()"); throw; } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::Process()"); throw; } #endif // Frame move the scene #ifdef XBMC_TRACK_EXCEPTIONS try { #endif if (!m_bStop) { FrameMove(true, m_renderGUI); } //reset exception count #ifdef XBMC_TRACK_EXCEPTIONS } catch (const XbmcCommons::UncheckedException &e) { e.LogThrowMessage("CApplication::FrameMove()"); throw; } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::FrameMove()"); throw; } #endif // Render the scene #ifdef XBMC_TRACK_EXCEPTIONS try { #endif if (m_renderGUI && !m_bStop) { Render(); } else if (!m_renderGUI) { frameTime = XbmcThreads::SystemClockMillis() - lastFrameTime; if(frameTime < noRenderFrameTime) Sleep(noRenderFrameTime - frameTime); } #ifdef XBMC_TRACK_EXCEPTIONS } catch (const XbmcCommons::UncheckedException &e) { e.LogThrowMessage("CApplication::Render()"); throw; } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::Render()"); throw; } #endif } // while (!m_bStop) Destroy(); CLog::Log(LOGNOTICE, "application stopped..." ); return m_ExitCode; }
//----------------------------------------------------------------------------- // Name: Run() // Desc: //----------------------------------------------------------------------------- INT CXBApplicationEx::Run() { CLog::Log(LOGNOTICE, "Running the application..." ); // Get the frequency of the timer LARGE_INTEGER qwTicksPerSec; QueryPerformanceFrequency( &qwTicksPerSec ); FLOAT fSecsPerTick = 1.0f / (FLOAT)qwTicksPerSec.QuadPart; // Save the start time LARGE_INTEGER qwTime, qwLastTime, qwElapsedTime; QueryPerformanceCounter( &qwTime ); qwLastTime.QuadPart = qwTime.QuadPart; LARGE_INTEGER qwAppTime, qwElapsedAppTime; qwAppTime.QuadPart = 0; qwElapsedTime.QuadPart = 0; qwElapsedAppTime.QuadPart = 0; BYTE processExceptionCount = 0; BYTE frameMoveExceptionCount = 0; BYTE renderExceptionCount = 0; #ifndef _DEBUG const BYTE MAX_EXCEPTION_COUNT = 10; #endif // Run the game loop, animating and rendering frames while (!m_bStop) { #ifdef HAS_PERFORMANCE_SAMPLE CPerformanceSample sampleLoop("XBApplicationEx-loop"); #endif //----------------------------------------- // Perform app timing //----------------------------------------- // Check Start button #ifdef HAS_GAMEPAD if ( m_DefaultGamepad.wPressedButtons & XINPUT_GAMEPAD_START ) #endif m_bPaused = !m_bPaused; // Get the current time (keep in LARGE_INTEGER format for precision) QueryPerformanceCounter( &qwTime ); qwElapsedTime.QuadPart = qwTime.QuadPart - qwLastTime.QuadPart; qwLastTime.QuadPart = qwTime.QuadPart; if ( m_bPaused ) qwElapsedAppTime.QuadPart = 0; else qwElapsedAppTime.QuadPart = qwElapsedTime.QuadPart; qwAppTime.QuadPart += qwElapsedAppTime.QuadPart; // Store the current time values as floating point m_fTime = fSecsPerTick * ((FLOAT)(qwTime.QuadPart)); m_fElapsedTime = fSecsPerTick * ((FLOAT)(qwElapsedTime.QuadPart)); m_fAppTime = fSecsPerTick * ((FLOAT)(qwAppTime.QuadPart)); m_fElapsedAppTime = fSecsPerTick * ((FLOAT)(qwElapsedAppTime.QuadPart)); //----------------------------------------- // Animate and render a frame //----------------------------------------- #ifndef _DEBUG try { #endif Process(); //reset exception count processExceptionCount = 0; #ifndef _DEBUG } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::Process()"); processExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (processExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions"); throw; } } #endif // Frame move the scene #ifndef _DEBUG try { #endif if (!m_bStop) FrameMove(); //reset exception count frameMoveExceptionCount = 0; #ifndef _DEBUG } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::FrameMove()"); frameMoveExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (frameMoveExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::FrameMove(), too many exceptions"); throw; } } #endif // Render the scene #ifndef _DEBUG try { #endif if (!m_bStop) Render(); //reset exception count renderExceptionCount = 0; #ifndef _DEBUG } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::Render()"); renderExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (renderExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::Render(), too many exceptions"); throw; } } #endif } Destroy(); CLog::Log(LOGNOTICE, "application stopped..." ); return 0; }
/* Function that runs the application */ INT CXBApplicationEx::Run() { CLog::Log(LOGNOTICE, "Running the application..." ); BYTE processExceptionCount = 0; BYTE frameMoveExceptionCount = 0; BYTE renderExceptionCount = 0; #ifndef _DEBUG const BYTE MAX_EXCEPTION_COUNT = 10; #endif // Run xbmc while (!m_bStop) { #ifdef HAS_PERFORMANCE_SAMPLE CPerformanceSample sampleLoop("XBApplicationEx-loop"); #endif //----------------------------------------- // Animate and render a frame //----------------------------------------- #ifndef _DEBUG try { #endif Process(); //reset exception count processExceptionCount = 0; #ifndef _DEBUG } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::Process()"); processExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (processExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions"); throw; } } #endif // Frame move the scene #ifndef _DEBUG try { #endif if (!m_bStop) FrameMove(); //reset exception count frameMoveExceptionCount = 0; #ifndef _DEBUG } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::FrameMove()"); frameMoveExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (frameMoveExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::FrameMove(), too many exceptions"); throw; } } #endif // Render the scene #ifndef _DEBUG try { #endif if (!m_bStop) Render(); //reset exception count renderExceptionCount = 0; #ifndef _DEBUG } catch (...) { CLog::Log(LOGERROR, "exception in CApplication::Render()"); renderExceptionCount++; //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out if (renderExceptionCount > MAX_EXCEPTION_COUNT) { CLog::Log(LOGERROR, "CApplication::Render(), too many exceptions"); throw; } } #endif } // while (!m_bStop) Destroy(); CLog::Log(LOGNOTICE, "application stopped..." ); return 0; }