diff --git a/src/ArmaScriptProfiler.vcxproj b/src/ArmaScriptProfiler.vcxproj
index aa640db..42b73cc 100644
--- a/src/ArmaScriptProfiler.vcxproj
+++ b/src/ArmaScriptProfiler.vcxproj
@@ -91,7 +91,7 @@
true
$(SolutionDir)..\Intercept\src\client\headers;$(SolutionDir)..\Intercept\src\client\headers\client;$(SolutionDir)..\Intercept\src\client\headers\shared;$(SolutionDir)..\Intercept\src\client\headers\client\sqf;$(SolutionDir)..\Intercept\src;$(SolutionDir)..\brofiler\BrofilerCore;$(SolutionDir)..\brofiler\ThirdParty\TaskScheduler\Scheduler\Include;$(SolutionDir)..\tracy;%(AdditionalIncludeDirectories)
true
- _CRT_SECURE_NO_WARNINGS;INTERCEPT_SQF_STRTYPE_RSTRING;_WINDLL;%(PreprocessorDefinitions)
+ WITH_BROFILER;WITH_CHROME;_CRT_SECURE_NO_WARNINGS;INTERCEPT_SQF_STRTYPE_RSTRING;_WINDLL;%(PreprocessorDefinitions)
stdcpplatest
false
@@ -106,7 +106,7 @@
true
$(SolutionDir)..\Intercept\src\client\headers;$(SolutionDir)..\Intercept\src\client\headers\client;$(SolutionDir)..\Intercept\src\client\headers\shared;$(SolutionDir)..\Intercept\src\client\headers\client\sqf;$(SolutionDir)..\Intercept\src;$(SolutionDir)..\brofiler\BrofilerCore;$(SolutionDir)..\brofiler\ThirdParty\TaskScheduler\Scheduler\Include;$(SolutionDir)..\tracy;%(AdditionalIncludeDirectories)
true
- _CRT_SECURE_NO_WARNINGS;INTERCEPT_SQF_STRTYPE_RSTRING;_WINDLL;%(PreprocessorDefinitions)
+ WITH_BROFILER;WITH_CHROME;_CRT_SECURE_NO_WARNINGS;INTERCEPT_SQF_STRTYPE_RSTRING;_WINDLL;%(PreprocessorDefinitions)
stdcpplatest
false
@@ -120,7 +120,7 @@
true
$(SolutionDir)..\Intercept\src\client\headers;$(SolutionDir)..\Intercept\src\client\headers\client;$(SolutionDir)..\Intercept\src\client\headers\shared;$(SolutionDir)..\Intercept\src\client\headers\client\sqf;$(SolutionDir)..\Intercept\src;$(SolutionDir)..\brofiler\BrofilerCore;$(SolutionDir)..\brofiler\ThirdParty\TaskScheduler\Scheduler\Include;$(SolutionDir)..\tracy;%(AdditionalIncludeDirectories)
true
- _CRT_SECURE_NO_WARNINGS;INTERCEPT_SQF_STRTYPE_RSTRING;_WINDLL;%(PreprocessorDefinitions)
+ WITH_BROFILER;WITH_CHROME;_CRT_SECURE_NO_WARNINGS;INTERCEPT_SQF_STRTYPE_RSTRING;_WINDLL;%(PreprocessorDefinitions)
stdcpplatest
AnySuitable
Speed
@@ -142,7 +142,7 @@
true
$(SolutionDir)..\Intercept\src\client\headers;$(SolutionDir)..\Intercept\src\client\headers\client;$(SolutionDir)..\Intercept\src\client\headers\shared;$(SolutionDir)..\Intercept\src\client\headers\client\sqf;$(SolutionDir)..\Intercept\src;$(SolutionDir)..\brofiler\BrofilerCore;$(SolutionDir)..\brofiler\ThirdParty\TaskScheduler\Scheduler\Include;$(SolutionDir)..\tracy;%(AdditionalIncludeDirectories)
true
- _CRT_SECURE_NO_WARNINGS;INTERCEPT_SQF_STRTYPE_RSTRING;_WINDLL;%(PreprocessorDefinitions)
+ WITH_BROFILER;WITH_CHROME;_CRT_SECURE_NO_WARNINGS;INTERCEPT_SQF_STRTYPE_RSTRING;_WINDLL;%(PreprocessorDefinitions)
stdcpplatest
MultiThreaded
AnySuitable
@@ -234,9 +234,7 @@
-
- true
-
+
diff --git a/src/hooks.asm b/src/hooks.asm
index 29d867a..bf39bee 100644
--- a/src/hooks.asm
+++ b/src/hooks.asm
@@ -1,6 +1,4 @@
option casemap :none
-.intel_syntax noprefix
-
_TEXT SEGMENT
;https://msdn.microsoft.com/en-us/library/windows/hardware/ff561499(v=vs.85).aspx
diff --git a/src/scriptProfiler.cpp b/src/scriptProfiler.cpp
index 5072b83..ff5c1dc 100644
--- a/src/scriptProfiler.cpp
+++ b/src/scriptProfiler.cpp
@@ -13,6 +13,8 @@
#include "Event.h"
#include "AdapterChrome.hpp"
#include "AdapterTracy.hpp"
+#include
+#include
using namespace intercept;
using namespace std::chrono_literals;
@@ -579,6 +581,46 @@ game_value compileRedirect2(const game_state& state, game_value_parameter messag
return comp;
}
+game_value compileRedirectFinal(const game_state& state, game_value_parameter message) {
+ if (!profiler.compileScope) {
+ static r_string compileEventText("compile");
+ static r_string profName("scriptProfiler.cpp");
+ profiler.compileScope = GProfilerAdapter->createScope(compileEventText, profName, __LINE__);
+ }
+
+ auto tempData = GProfilerAdapter->enterScope(profiler.compileScope);
+
+ r_string str = message;
+
+ auto comp = sqf::compile_final(str);
+ auto bodyCode = static_cast(comp.data.get());
+ if (!bodyCode->instructions) {
+ GProfilerAdapter->leaveScope(tempData);
+ return comp;
+ }
+
+#ifdef WITH_BROFILER
+ if (auto brofilerData = std::dynamic_pointer_cast(tempData)) {
+ r_string src = getScriptFromFirstLine(bodyCode->instructions->front()->sdp, false);
+ brofilerData->evtDt->sourceCode = src;
+ }
+#endif
+
+ GProfilerAdapter->leaveScope(tempData);
+
+ auto& funcPath = bodyCode->instructions->front()->sdp.sourcefile;
+ std::string scriptName = getScriptName(str, funcPath, 32);
+ //if (scriptName.empty()) scriptName = "";
+
+ if (bodyCode->instructions && !scriptName.empty() && scriptName != "")
+ addScopeInstruction(bodyCode, scriptName);
+
+ return comp;
+}
+
+
+
+
game_value callExtensionRedirect(uintptr_t st, game_value_parameter ext, game_value_parameter msg) {
if (!profiler.callExtScope) {
static r_string compileEventText("callExtension");
@@ -640,36 +682,6 @@ std::optional getCommandLineParam(std::string_view needle) {
}
scriptProfiler::scriptProfiler() {
- if (getCommandLineParam("-profilerEnableInstruction"sv)) {
- instructionLevelProfiling = true;
- }
-
- auto startAdapter = getCommandLineParam("-profilerAdapter"sv);
-
- if (startAdapter) {
- if (false) {
-#ifdef WITH_CHROME
- } else if (*startAdapter == "Chrome"sv) {
- auto chromeAdapter = std::make_shared();
- GProfilerAdapter = chromeAdapter;
-
- auto chromeOutput = getCommandLineParam("-profilerOutput"sv);
- if (chromeOutput)
- chromeAdapter->setTargetFile(*chromeOutput);
-#endif
-#ifdef WITH_BROFILER
- } else if (*startAdapter == "Brofiler"sv) {
- GProfilerAdapter = std::make_shared();
-#endif
- } else if (*startAdapter == "Arma"sv) {
- GProfilerAdapter = std::make_shared();
- } else if (*startAdapter == "Tracy"sv) {
- GProfilerAdapter = std::make_shared();
- }
- } else {
- GProfilerAdapter = std::make_shared();
- }
-
}
#ifndef __linux__
@@ -980,6 +992,45 @@ class GameInstructionNewExpression : public game_instruction {
#pragma endregion Instructions
#endif
void scriptProfiler::preStart() {
+
+ if (getCommandLineParam("-profilerEnableInstruction"sv)) {
+ instructionLevelProfiling = true;
+ }
+
+ auto startAdapter = getCommandLineParam("-profilerAdapter"sv);
+
+ if (startAdapter) {
+ if (false) {
+#ifdef WITH_CHROME
+ }
+ else if (*startAdapter == "Chrome"sv) {
+ auto chromeAdapter = std::make_shared();
+ GProfilerAdapter = chromeAdapter;
+
+ auto chromeOutput = getCommandLineParam("-profilerOutput"sv);
+ if (chromeOutput)
+ chromeAdapter->setTargetFile(*chromeOutput);
+#endif
+#ifdef WITH_BROFILER
+ }
+ else if (*startAdapter == "Brofiler"sv) {
+ GProfilerAdapter = std::make_shared();
+#endif
+ }
+ else if (*startAdapter == "Arma"sv) {
+ GProfilerAdapter = std::make_shared();
+ }
+ else if (*startAdapter == "Tracy"sv) {
+ GProfilerAdapter = std::make_shared();
+ }
+ }
+ else {
+ GProfilerAdapter = std::make_shared();
+ }
+
+
+
+
#ifndef __linux__
if (getCommandLineParam("-profilerEnableEngine"sv)) {
engineProf = std::make_shared();
@@ -1003,7 +1054,7 @@ void scriptProfiler::preStart() {
static auto _profilerCompile = client::host::register_sqf_command("compile", "Profiler redirect", compileRedirect2, game_data_type::CODE, game_data_type::STRING);
//static auto _profilerCompile2 = client::host::register_sqf_command("compile2", "Profiler redirect", compileRedirect, game_data_type::CODE, game_data_type::STRING);
//static auto _profilerCompile3 = client::host::register_sqf_command("compile3", "Profiler redirect", compileRedirect2, game_data_type::CODE, game_data_type::STRING);
- static auto _profilerCompileF = client::host::register_sqf_command("compileFinal", "Profiler redirect", compileRedirect2, game_data_type::CODE, game_data_type::STRING);
+ static auto _profilerCompileF = client::host::register_sqf_command("compileFinal", "Profiler redirect", compileRedirectFinal, game_data_type::CODE, game_data_type::STRING);
static auto _profilerCallExt = client::host::register_sqf_command("callExtension", "Profiler redirect", callExtensionRedirect, game_data_type::STRING, game_data_type::STRING, game_data_type::STRING);
static auto _profilerDiagLog = client::host::register_sqf_command("diag_log", "Profiler redirect", diag_logRedirect, game_data_type::NOTHING, game_data_type::ANY);
static auto _profilerProfScript = client::host::register_sqf_command("profileScript", "Profiler redirect", profileScript, game_data_type::ARRAY, game_data_type::ARRAY);