Ejemplo n.º 1
0
/* virtual */
OpScopeProfiler::~OpScopeProfiler()
{
	StopProfiling();

	g_main_message_handler->UnsetCallBack(this, MSG_SCOPE_PROCESS_TIMELINE);
	frame_ids->Release();
}
Ejemplo n.º 2
0
bool VRSDClient::StartProfiling()
{
  if(m_bProfilingEnabled)
  {
    StopProfiling();
    return false;
  }

  Vision::Callbacks.OnEditorModeChanged += this;

  // tell the client language implementation that we are now profiling (just in case it has something special to do)
  if(GetClientLanguageImplementation()->StartProfiling())
  {
    V_SAFE_DELETE(m_pProfilingStack);
    m_pProfilingStack = new VPListStack<VRSDProfilingSample*>();
    m_bProfilingEnabled = true;

    Vision::Error.SystemMessage("Starting script profiling..");

    return true;
  }

  /// \todo Editor Play Mode starten
//  if(!Vision::Editor.IsPlaying())
//    Vision::Editor.SetMode(VisEditorManager_cl::EDITORMODE_PLAYING_IN_EDITOR);

  return false;
}
Ejemplo n.º 3
0
int main() {
    if (SystemCheck()) {
        LOG("Adding resources.");

        if (Effect.Load)
            Effect.Load();

        StartEventQueue();
        StartProfiling();
        SetFrameCounter(0);
        TRY {
            BOOL loopExit = false;

            LOG("Setting up the effect.");
            Effect.Init();
            LOG("Running up main loop.");

            do {
                InputEventT event;
                int32_t frameNumber;

                while (EventQueuePop(&event)) {
                    if (event.ie_Class == IECLASS_RAWKEY)
                        if (event.ie_Code & IECODE_UP_PREFIX)
                            if ((event.ie_Code & ~IECODE_UP_PREFIX) == KEY_ESCAPE)
                                loopExit = true;
                    if (Effect.HandleEvent && !loopExit)
                        Effect.HandleEvent(&event);
                }

                frameNumber = ReadFrameCounter();
                Effect.Render(frameNumber);
                RenderFrameNumber(frameNumber);
                RenderFramesPerSecond(frameNumber);

                DisplaySwap();
            } while (!loopExit);

            LOG("Tearing down the effect.");
            Effect.Kill();
        }
        CATCH {
            LOG("Effect crashed!");
        }
        StopProfiling();
        StopEventQueue();

        if (Effect.UnLoad)
            Effect.UnLoad();
    }

    return 0;
}
Ejemplo n.º 4
0
/* virtual */ OP_STATUS
OpScopeProfiler::OnServiceDisabled()
{
	StopProfiling();

	session_ids.Purge();

	current_session = NULL;

	next_timeline_id = 1;

	return OpStatus::OK;
}
Ejemplo n.º 5
0
void Host::Shutdown()
{
    // Do not shut down the logger here, because logging
    // may need to happen after this method is called.

    static bool shutdown = false;
    if (shutdown)
        return;

    Poco::Mutex::ScopedLock lock(moduleMutex);
    this->UnloadModuleProviders();
    this->UnloadModules();

    UnloadBuiltinModules();

    logger->Notice("Exiting with exit code: %i", exitCode);
    StopProfiling(); // Stop the profiler, if it was enabled
    Logger::Shutdown();
    shutdown = true;
}
Ejemplo n.º 6
0
/*
 * Tear down effect function.
 */
void TearDownEffect() {
  StopProfiling();
}
Ejemplo n.º 7
0
	int Host::Run()
	{
		if (this->waitForDebugger)
		{
#ifdef OS_WIN32
			DebugBreak();
#else
			printf("Waiting for debugger (Press Any Key to Continue pid=%i)...\n", getpid());
			getchar();
#endif
		}

		try
		{
			ScopedLock lock(&moduleMutex);
			this->AddModuleProvider(this);
			this->LoadModules();
		}
		catch (ValueException e)
		{
			SharedString ss = e.GetValue()->DisplayString();
			logger->Error(*ss);
			return 1;
		}

		// Depending on the implementation of platform-specific host,
		// it may block in Start() or implement a UI loop which will
		// be continually called until this->running becomes false.
		try
		{
			this->running = this->Start();
			if (this->runUILoop) 
			{
				while (this->running)
				{
					if (!this->RunLoop())
					{
						break;
					}
				}
			}
		}
		catch (kroll::ValueException& e)
		{
			SharedString s = e.GetValue()->DisplayString();
			logger->Error("Caught exception in main loop: %s", s->c_str());
		}

		ScopedLock lock(&moduleMutex);
		this->Stop();
		this->UnloadModuleProviders();
		this->UnloadModules();

		this->globalObject = NULL;

		// Stop the profiler, if it was enabled
		StopProfiling();

		logger->Notice("Exiting with exit code: %i", exitCode);

		Logger::Shutdown();
		return this->exitCode;
	}
Ejemplo n.º 8
0
VSPTree::VSPTree( QString appPath,  QString argument) :
	m_applicationPath( appPath ),
	m_settings( appPath + "/VSPTree.ini", QSettings::IniFormat )
{ 
	QDir dir(PATH32);
	QDir dir2(PATH64);
	if ( dir.exists() )
	{
		m_profilerpath = PATH32;
	}
	else if ( dir2.exists() )
	{
		m_profilerpath = PATH64;
	}
	else
	{
		QMessageBox::critical(NULL,"Standalone Debugger not installed", "C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Team Tools\\Performance Tools\\ does not exist");
	}

	QStringList env = QProcess::systemEnvironment();
	env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), QString("PATH=\\1;") + m_profilerpath);
	m_process.setEnvironment(env);

	if ( m_settings.contains("m_lastExe") ) 
	{
		m_lastExe = m_settings.value("m_lastExe").toString();
	}

	if ( m_settings.contains("m_lastVSP") ) 
	{
		m_lastVSP = m_settings.value("m_lastVSP").toString();
	}

	if ( m_settings.contains("m_lastArguments") ) 
	{
		m_lastArguments = m_settings.value("m_lastArguments").toString();
	}

	m_editorPath = "";
	if ( m_settings.contains("m_editorPath") ) 
	{
		m_editorPath = m_settings.value("m_editorPath").toString();
	}

	m_editorArguments = "<filename> -n<linenum>";
	if ( m_settings.contains("m_editorArguments") ) 
	{
		m_editorArguments = m_settings.value("m_editorArguments").toString();
	}

	m_log = new QTextEdit();
	m_log->setReadOnly(true);
	connect (&m_process, SIGNAL(readyReadStandardOutput()),this,  SLOT(StdOutLog()));
	connect (&m_process, SIGNAL(readyReadStandardError()),this,  SLOT(StdErrorLog()));

	menubar = this->menuBar();
	QMenu* fileMenu = menubar->addMenu("File");
	QAction* openAct = fileMenu->addAction("Open VSP");
	connect(openAct, SIGNAL(triggered()), this, SLOT(LoadVSPClicked()));
	QAction* exitAct = fileMenu->addAction("Exit");
	connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
	
	QMenu* profilerMenu = menubar->addMenu("Profiler");

	QAction* startProfilingAct = profilerMenu->addAction("Start Profiler Service");
	connect(startProfilingAct, SIGNAL(triggered()), this, SLOT(StartProfiling()));

	QAction* ProfileAct = profilerMenu->addAction("Profile Application");
	connect(ProfileAct, SIGNAL(triggered()), this, SLOT(Profile()));

	QAction* stopProfilingAct = profilerMenu->addAction("Stop Profiler Service");
	connect(stopProfilingAct, SIGNAL(triggered()), this, SLOT(StopProfiling()));

	QMenu* OptionsMenu = menubar->addMenu("Options");
	QAction* setTextEditor = OptionsMenu->addAction("Set Text Editor");
	connect(setTextEditor, SIGNAL(triggered()), this, SLOT(setTextEditor()));

	m_tabWidget = new QTabWidget();

	m_callTreeWidget = new QTreeWidget();

	m_flatCallTreeWidget = new QTreeWidget();

	m_functionSummaryTreeWidget = new QTreeWidget();

	m_tabWidget->addTab(m_callTreeWidget,"CallTree");
	m_tabWidget->addTab(m_flatCallTreeWidget,"CallTreeFlat");
	m_tabWidget->addTab(m_functionSummaryTreeWidget,"FunctionSummary");
	m_tabWidget->addTab(m_log,"Log");

	m_callTreeMenu = new QMenu();
	QAction* openFileAct = m_callTreeMenu->addAction("Open File");
	connect(openFileAct, SIGNAL(triggered()), this, SLOT(openFile()));

	QAction* expandAllAct = m_callTreeMenu->addAction("Expand All");
	connect(expandAllAct, SIGNAL(triggered()), m_callTreeWidget, SLOT(expandAll()));

	QAction* collapseAllAct = m_callTreeMenu->addAction("Collapse All");
	connect(collapseAllAct, SIGNAL(triggered()), m_callTreeWidget, SLOT(collapseAll()));

	m_flatCallTreeMenu = new QMenu();
	
	m_flatCallTreeMenu->addAction(openFileAct);
	QAction* FindInTreeAct = m_flatCallTreeMenu->addAction("Find In Tree");
	connect(FindInTreeAct, SIGNAL(triggered()), this, SLOT(FindInTree()));

	//threads
	connect( &m_thread, SIGNAL( output( QString ) ), this, SLOT( Log( QString ) ) );
	connect( &m_thread, SIGNAL( finished() ), this, SLOT( workDone() ) );

	this->setCentralWidget(m_tabWidget);
	this->setWindowTitle(VERSION);
	this->resize(640,480);
	this->show();

	if ( !argument.isEmpty() )
	{
		LoadVSP(argument);
	}
}
Ejemplo n.º 9
0
void VRSDClient::OnHandleCallback(IVisCallbackDataObject_cl *pData)
{
  // check event source
  if(pData->m_pSender == &m_pClientLanguageImplementation->ScriptEvent)
  {
    VRSDScriptEvent* pEvent = static_cast<VRSDScriptEventCallbackItem*>(pData)->pScriptEvent;

    if(!pEvent)
      return;

    // If profiling is enabled the profiler will handle the script event,
    // Afterwards the return ensures that the standard debugging procedure is not followed
    if(m_bProfilingEnabled)
    {
      HandleScriptEventForProfiling(pEvent);
      return;
    }

    // Check if there is a connection from the remote debugger available
    if(!m_pConnection)
      return;

    // send event to debugger
    if(!SendScriptEvent(pEvent))
      return;

    // wait for debugger on what to do
    VMessage Msg;

    {
      VMutexLocker lock(m_ConnectionMutex);
      if(!m_pConnection)
        return;
      m_pConnection->Recv(&Msg);
    }

    while(Msg.IsValid() && Msg.GetMessageType() != 'CONT')
    {
      // check here for profiling messages as well since the async send may lead to them being received here
      if(Msg.GetMessageType() == 'BRSP')
      {
        StartProfiling();
        break;
      }
      else if(Msg.GetMessageType() == 'ERSP')
      {
        StopProfiling();
        break;
      }

      // process message (get callstack, get local variables, get global variables etc.)
      HandleDebuggingMessage(&Msg);

      // get the next message
      VMutexLocker lock(m_ConnectionMutex);
      if(!m_pConnection || !m_pConnection->Recv(&Msg))
        break;
    }
  }

  else if(pData->m_pSender == &VTarget::OnConnection)
  {
    VTargetConnectionCallbackItem* pTCCI = (VTargetConnectionCallbackItem*)pData;
    if(pTCCI->pConnection)
    {
      if(pTCCI->pConnection->IsFor("VRSD"))
      {
        m_pConnection = pTCCI->pConnection;

        // register message callback
        Vision::Error.AddCallback(EngineMessageCallback, this);

        Vision::Callbacks.OnUpdateSceneBegin += this;

        // Send connected callback
        OnConnected.TriggerCallbacks();
      }
    }
  }

  else if(pData->m_pSender == &VTarget::OnDisconnection)
  {
    VTargetConnectionCallbackItem* pTCCI = (VTargetConnectionCallbackItem*)pData;
    if(pTCCI->pConnection)
    {
      if(pTCCI->pConnection->IsFor("VRSD"))
      {
        {
          VMutexLocker lock(m_ConnectionMutex);
          m_pConnection = NULL;
        }

        // register message callback
        Vision::Error.RemoveCallback(EngineMessageCallback, this);

        Vision::Callbacks.OnUpdateSceneBegin -= this;

        // Send disconnected callback
        OnDisconnected.TriggerCallbacks();
      }
    }
  }

  else if(pData->m_pSender == &Vision::Callbacks.OnUpdateSceneBegin)
  {
    VMessage* pMsg = NULL;

    {
      VMutexLocker lock(m_ConnectionMutex);

      if(!m_pConnection)
        return;

      pMsg = m_pConnection->GetNextASyncReceivedMessage();
    }

    if(!pMsg)
      return;

    // command messages
    switch(pMsg->GetMessageType())
    {
      // begin remote script profiling
      case 'BRSP':
        StartProfiling();
        break;

      // end remote script profiling
      case 'ERSP':
        StopProfiling();
        break;

      // script reload
      case 'RSRN':
        HandleScriptReloadMessage(pMsg);
        break;
    }

    V_SAFE_DELETE(pMsg);
  }

  else if(pData->m_pSender == &Vision::Callbacks.OnEditorModeChanged)
  {
    if(Vision::Editor.IsInEditor() && !Vision::Editor.IsPlaying() && m_bProfilingEnabled)
      StopProfiling();
  }


}