Browse Source

Profiler changes

Brian Fiete 2 years ago
parent
commit
bb73aced22
2 changed files with 48 additions and 2 deletions
  1. 42 0
      IDE/include/BeefDbg.h
  2. 6 2
      IDEHelper/Profiler.cpp

+ 42 - 0
IDE/include/BeefDbg.h

@@ -0,0 +1,42 @@
+#pragma once
+
+#ifdef BEEFDBG_IMPLEMENTATION
+
+struct BfDebugMessageData
+{
+	int mMessageType; // 0 = none, 1 = error
+	int mStackWindbackCount;
+	int mBufParamLen;
+	const char* mBufParam;
+	void* mPCOverride;
+};
+
+extern "C"
+{
+	BfDebugMessageData gBfDebugMessageData;
+}
+
+extern "C" __declspec(dllimport) void DebugBreak();
+
+void BfProfileStart(int sampleRatea = 1000)
+{
+	char str[128];
+	sprintf(str, "StartSampling\t0\t%d\t0");
+	gBfDebugMessageData.mBufParam = str;
+	gBfDebugMessageData.mBufParamLen = strlen(gBfDebugMessageData.mBufParam);
+	DebugBreak();
+}
+
+void BfProfileEnd()
+{
+	gBfDebugMessageData.mBufParam = "StopSampling\t0";
+	gBfDebugMessageData.mBufParamLen = strlen(gBfDebugMessageData.mBufParam);
+	DebugBreak();
+}
+
+#else
+
+void BfProfileStart(int sampleRatea = 1000);
+void BfProfileEnd();
+
+#endif

+ 6 - 2
IDEHelper/Profiler.cpp

@@ -103,11 +103,15 @@ DbgProfiler::DbgProfiler(WinDebugger* debugger) : mShutdownEvent(true)
 	mDebugger->AddProfiler(this);
 	mDebugger->AddProfiler(this);
 
 
 	mIdleSymbolNames.Add("NtUserGetMessage");
 	mIdleSymbolNames.Add("NtUserGetMessage");
+	mIdleSymbolNames.Add("NtUserMsgWaitForMultipleObjectsEx");
 	mIdleSymbolNames.Add("NtWaitForAlertByThreadId");
 	mIdleSymbolNames.Add("NtWaitForAlertByThreadId");
 	mIdleSymbolNames.Add("NtWaitForMultipleObjects");
 	mIdleSymbolNames.Add("NtWaitForMultipleObjects");
 	mIdleSymbolNames.Add("NtWaitForSingleObject");
 	mIdleSymbolNames.Add("NtWaitForSingleObject");
 	mIdleSymbolNames.Add("ZwDelayExecution");
 	mIdleSymbolNames.Add("ZwDelayExecution");
 	mIdleSymbolNames.Add("ZwRemoveIoCompletion");
 	mIdleSymbolNames.Add("ZwRemoveIoCompletion");
+	mIdleSymbolNames.Add("ZwWaitForAlertByThreadId");
+	mIdleSymbolNames.Add("ZwWaitForMultipleObjects");
+	mIdleSymbolNames.Add("ZwWaitForSingleObject");
 	mIdleSymbolNames.Add("ZwWaitForWorkViaWorkerFactory");
 	mIdleSymbolNames.Add("ZwWaitForWorkViaWorkerFactory");
 }
 }
 
 
@@ -271,8 +275,8 @@ void DbgProfiler::ThreadProc()
 		int wantVirtualSamples = (int)((int64)accumMS * mSamplesPerSecond / 1000);
 		int wantVirtualSamples = (int)((int64)accumMS * mSamplesPerSecond / 1000);
 
 
 		int curSampleCount = wantVirtualSamples - mTotalVirtualSamples;
 		int curSampleCount = wantVirtualSamples - mTotalVirtualSamples;
-		BF_ASSERT(curSampleCount >= 0);
-		if (curSampleCount == 0)
+		//BF_ASSERT(curSampleCount >= 0);
+		if (curSampleCount <= 0)
 			continue;
 			continue;
 
 
 		{
 		{