Skip to content

Commit 30410ac

Browse files
committed
Update for Arma v1.90
1 parent 361f830 commit 30410ac

File tree

6 files changed

+43
-54
lines changed

6 files changed

+43
-54
lines changed

CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ endif()
55
project (ArmaScriptProfiler CXX ASM_MASM)
66
find_package (Threads)
77

8-
option(USE_64BIT_BUILD "USE_64BIT_BUILD" OFF)
8+
set(USE_64BIT_BUILD ${CMAKE_CL_64})
99
option(USE_STATIC_LINKING "USE_STATIC_LINKING" ON)
1010
option(WITH_BROFILER "WITH_BROFILER" OFF)
1111
option(WITH_CHROME "WITH_CHROME" OFF)
@@ -18,10 +18,7 @@ else()
1818
set(INTERCEPT_LINK_TYPE "dynamic")
1919
endif()
2020

21-
if(MSVC AND CMAKE_CL_64)
22-
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest" )
23-
set( USE_64BIT_BUILD ON)
24-
elseif(MSVC)
21+
if(MSVC)
2522
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest" )
2623
#elseif(MSVC)
2724
# message(FATAL_ERROR "ERROR: You need a C++17 compatible compiler")
@@ -30,8 +27,6 @@ endif()
3027
message("GENERATOR USED: '${CMAKE_GENERATOR}'")
3128
message("COMPILER USED: '${CMAKE_CXX_COMPILER_ID}'")
3229

33-
set(CMAKE_CL_64 ${USE_64BIT_BUILD})
34-
3530
if(USE_64BIT_BUILD)
3631
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/release/@ArmaScriptProfiler/intercept")
3732
else()

src/CMakeLists.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ target_link_libraries(${INTERCEPT_PLUGIN_NAME} ${LINK_LIBS})
7777

7878
set_target_properties(${INTERCEPT_PLUGIN_NAME} PROPERTIES PREFIX "")
7979
set_target_properties(${INTERCEPT_PLUGIN_NAME} PROPERTIES FOLDER ArmaScriptProfiler)
80-
message("${CONFIGURATION}")
80+
8181
if(CMAKE_COMPILER_IS_GNUCXX)
8282
set_source_files_properties(hooks.s PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
8383
add_compile_definitions(__linux__)
@@ -86,7 +86,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
8686
target_compile_options(
8787
${INTERCEPT_PLUGIN_NAME} PRIVATE
8888
"-std=c++1z"
89-
"$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-O3>"
89+
"$<$<CONFIG:Release>:-O3>"
9090
"-s"
9191
"-fPIC"
9292
"-fpermissive"
@@ -96,13 +96,13 @@ if(CMAKE_COMPILER_IS_GNUCXX)
9696
"-m32"
9797
"-Wno-ignored-attributes"
9898
"-static"
99-
"$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-ffunction-sections>"
100-
"$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-fdata-sections>"
99+
"$<$<CONFIG:Release>:-ffunction-sections>"
100+
"$<$<CONFIG:Release>:-fdata-sections>"
101101

102102
)
103103
target_link_options(${INTERCEPT_PLUGIN_NAME} PRIVATE "-m32" "-fPIC" "-static" "-static-libgcc" "-static-libstdc++"
104-
"$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-Wl,--gc-sections>"
105-
"$<$<OR:$<CONFIG:Release>>:-Wl,--strip-all>"
104+
"$<$<CONFIG:Release>:-Wl,--gc-sections>"
105+
"$<$<CONFIG:Release>:-Wl,--strip-all>"
106106
)
107107
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
108108

@@ -112,11 +112,11 @@ else()
112112
target_compile_options(
113113
${INTERCEPT_PLUGIN_NAME} PRIVATE
114114
"/MP" "/Zi"
115-
"$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:/MT>"
116-
"$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:/Ox>"
117-
"$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:/Ob2>"
118-
"$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:/Oi>"
119-
"$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:/Ot>"
115+
"$<$<CONFIG:Release>:/MT>"
116+
"$<$<CONFIG:Release>:/Ox>"
117+
"$<$<CONFIG:Release>:/Ob2>"
118+
"$<$<CONFIG:Release>:/Oi>"
119+
"$<$<CONFIG:Release>:/Ot>"
120120
)
121121
target_link_options(${INTERCEPT_PLUGIN_NAME} PRIVATE "/OPT:REF" "/OPT:ICF" "/DEBUG:FULL")
122122
endif()

src/EngineProfiling.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bool checkMainThread = false;
3030
thread_local bool isMainThread = false;
3131

3232
std::string getScriptName(const r_string& str, const r_string& filePath, uint32_t returnFirstLineIfNoName = 0);
33-
void addScopeInstruction(ref<compact_array<ref<game_instruction>>>& bodyCode, const r_string& scriptName);
33+
void addScopeInstruction(auto_array<ref<game_instruction>>& bodyCode, const r_string& scriptName);
3434

3535

3636
extern "C" {
@@ -47,14 +47,14 @@ extern "C" {
4747
void compileCacheIns();
4848

4949
void insertCompileCache(uintptr_t code, sourcedocpos& sdp) {
50-
51-
auto x = reinterpret_cast<ref<compact_array<ref<game_instruction>>>*>(code);
52-
53-
if (sdp.content.length() < 64 || !x || !*x || x->get()->size() < 16) return;
54-
55-
r_string name(getScriptName(sdp.content, sdp.sourcefile, 32));
56-
if (!name.empty() && name != "<unknown>"sv)
57-
addScopeInstruction(*x, name);
50+
//broken
51+
//auto x = reinterpret_cast<ref<compact_array<ref<game_instruction>>>*>(code);
52+
//
53+
//if (sdp.content.length() < 64 || !x || !*x || x->get()->size() < 16) return;
54+
//
55+
//r_string name(getScriptName(sdp.content, sdp.sourcefile, 32));
56+
//if (!name.empty() && name != "<unknown>"sv)
57+
// addScopeInstruction(x, name);
5858
}
5959
}
6060

@@ -161,7 +161,7 @@ HookManager::Pattern pat_shouldTime{
161161
};
162162

163163
#else
164-
164+
//#FIXME
165165
HookManager::Pattern pat_compileCacheIns{ //1.88.145.302 profv1 013D40B3
166166
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?xxx????xxxx????xxxxx????xxxxxxxxxxxxxxxxxxxxxxxxx????xxx?????xxxx?x????xxxxxxxxxxxxxxxxxxxxx????xxxxxxxxxxxxxxxxx"sv,
167167
"\x48\x89\x45\xB0\x8B\x43\x10\x89\x45\xB8\x48\x8B\x43\x18\x48\x85\xC0\x74\x03\xF0\xFF\x00\x48\x89\x45\xC0\x8B\x43\x20\x48\x8D\x54\x24\x00\x48\x8D\x0D\x00\x00\x00\x00\x89\x45\xC8\xE8\x00\x00\x00\x00\x48\x8D\x4D\xA8\xE8\x00\x00\x00\x00\x48\x8B\x4D\xA0\x48\x85\xC9\x74\x1C\x41\x8B\xC7\xF0\x0F\xC1\x01\xFF\xC8\x75\x09\x48\x8B\x4D\xA0\xE8\x00\x00\x00\x00\x48\xC7\x45\x00\x00\x00\x00\x00\x48\x8D\x4C\x24\x00\xE8\x00\x00\x00\x00\x4D\x85\xE4\x74\x1D\x41\x8B\xC7\xF0\x41\x0F\xC1\x04\x24\xFF\xC8\x75\x10\x48\x8B\x0D\x00\x00\x00\x00\x49\x8B\xD4\x48\x8B\x01\xFF\x50\x18\x4D\x85\xF6\x74\x1C\x41\x8B\xC7"sv
@@ -210,7 +210,7 @@ void EngineProfiling::init() {
210210
hooks.placeHook(hookTypes::shouldTime, pat_shouldTime, reinterpret_cast<uintptr_t>(shouldTime), shouldTimeJmpback, 0);
211211
hooks.placeHook(hookTypes::frameEnd, pat_frameEnd, reinterpret_cast<uintptr_t>(frameEnd), frameEndJmpback, 0);
212212
#ifndef __linux__
213-
hooks.placeHook(hookTypes::compileCacheIns, pat_compileCacheIns, reinterpret_cast<uintptr_t>(compileCacheIns), compileCacheInsJmpback, 0);
213+
//hooks.placeHook(hookTypes::compileCacheIns, pat_compileCacheIns, reinterpret_cast<uintptr_t>(compileCacheIns), compileCacheInsJmpback, 0);
214214
#endif
215215
#ifdef __linux__
216216
auto found = hooks.findPattern(pat_doEnd, 0);

src/scriptProfiler.cpp

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -557,57 +557,51 @@ class GameInstructionConst : public game_instruction {
557557
r_string get_name() const override { return ""sv; }
558558
};
559559

560-
void addScopeInstruction(ref<compact_array<ref<game_instruction>>>& bodyCode, const r_string& scriptName) {
560+
void addScopeInstruction(auto_array<ref<game_instruction>>& bodyCode, const r_string& scriptName) {
561561
#ifndef __linux__
562562
#ifndef _WIN64
563563
#error "no x64 hash codes yet"
564564
#endif
565565
#endif
566-
if (!bodyCode) return;
566+
if (bodyCode.empty()) return;
567567

568-
auto lt = typeid(bodyCode->data()[0]).hash_code();
568+
auto lt = typeid(bodyCode.data()[0]).hash_code();
569569
auto rt = typeid(GameInstructionProfileScopeStart).hash_code();
570570

571571
if (lt == rt) return;
572-
if (bodyCode->size() < 4) return;
572+
if (bodyCode.size() < 4) return;
573573

574574

575-
auto& funcPath = bodyCode->front()->sdp.sourcefile;
575+
auto& funcPath = bodyCode.front()->sdp.sourcefile;
576576
//r_string src = getScriptFromFirstLine(bodyCode->instructions->front()->sdp, false);
577577

578578

579579

580580
//Insert instruction to set _x
581581
ref<GameInstructionProfileScopeStart> curElInstruction = rv_allocator<GameInstructionProfileScopeStart>::create_single(scriptName);
582-
curElInstruction->sdp = bodyCode->front()->sdp;
582+
curElInstruction->sdp = bodyCode.front()->sdp;
583583
curElInstruction->scopeInfo = GProfilerAdapter->createScope(curElInstruction->name,
584584
funcPath.empty() ? curElInstruction->name : funcPath,
585585
curElInstruction->sdp.sourceline);
586586
//if (scriptName == "<unknown>")
587587
//curElInstruction->eventDescription->source = src;
588588

589-
590-
auto oldInstructions = bodyCode;
591-
ref<compact_array<ref<game_instruction>>> newInstr = compact_array<ref<game_instruction>>::create(*oldInstructions, oldInstructions->size() + 1);
592-
593-
std::copy(oldInstructions->begin(), oldInstructions->begin() + oldInstructions->size(), newInstr->begin() + 1);
594-
newInstr->data()[0] = curElInstruction;
595-
bodyCode = newInstr;
596-
589+
//Add instruction at start
590+
bodyCode.insert(bodyCode.begin(), curElInstruction);
597591

598592
#ifdef __linux__
599593
static const size_t ConstTypeIDHash = 600831349;
600594
#else
601595
static const size_t ConstTypeIDHash = 0x0a56f03038a03360ull;
602596
#endif
603-
for (auto& it : *bodyCode) {
597+
for (auto& it : bodyCode) {
604598

605599
auto instC = dynamic_cast<GameInstructionProfileScopeStart*>(it.get());
606600
if (instC) {
607601
break;
608602
}
609603

610-
auto typeHash = typeid(*it.get()).hash_code();
604+
auto typeHash = typeid(it.get()).hash_code();
611605

612606
//linux
613607
//auto typeN = typeid(*it.get()).name();
@@ -620,7 +614,7 @@ void addScopeInstruction(ref<compact_array<ref<game_instruction>>>& bodyCode, co
620614
if (inst->value.type_enum() != game_data_type::CODE) continue;
621615

622616
auto bodyCodeNext = static_cast<game_data_code*>(inst->value.data.get());
623-
if (bodyCodeNext->instructions && bodyCodeNext->instructions->size() > 20)
617+
if (bodyCodeNext->instructions.size() > 20)
624618
addScopeInstruction(bodyCodeNext->instructions, scriptName);
625619
}
626620
}
@@ -655,7 +649,7 @@ game_value compileRedirect2(game_state& state, game_value_parameter message) {
655649

656650
auto comp = sqf::compile(str);
657651
auto bodyCode = static_cast<game_data_code*>(comp.data.get());
658-
if (!bodyCode->instructions) {
652+
if (bodyCode->instructions.empty()) {
659653
GProfilerAdapter->leaveScope(tempData);
660654
return comp;
661655
}
@@ -669,13 +663,13 @@ game_value compileRedirect2(game_state& state, game_value_parameter message) {
669663

670664
GProfilerAdapter->leaveScope(tempData);
671665

672-
auto& funcPath = bodyCode->instructions->front()->sdp.sourcefile;
666+
auto& funcPath = bodyCode->instructions.front()->sdp.sourcefile;
673667
//#TODO pass instructions to getScriptName and check if there is a "scriptName" or "scopeName" unary command call
674668
r_string scriptName(getScriptName(str, funcPath, 32));
675669

676670
//if (scriptName.empty()) scriptName = "<unknown>";
677671

678-
if (bodyCode->instructions&& bodyCode->instructions->size() > 4 && !scriptName.empty())// && scriptName != "<unknown>"
672+
if (bodyCode->instructions.size() > 4 && !scriptName.empty())// && scriptName != "<unknown>"
679673
addScopeInstruction(bodyCode->instructions, scriptName);
680674

681675
return comp;
@@ -694,7 +688,7 @@ game_value compileRedirectFinal(game_state& state, game_value_parameter message)
694688

695689
auto comp = sqf::compile_final(str);
696690
auto bodyCode = static_cast<game_data_code*>(comp.data.get());
697-
if (!bodyCode->instructions) {
691+
if (bodyCode->instructions.empty()) {
698692
GProfilerAdapter->leaveScope(tempData);
699693
return comp;
700694
}
@@ -708,14 +702,14 @@ game_value compileRedirectFinal(game_state& state, game_value_parameter message)
708702

709703
GProfilerAdapter->leaveScope(tempData);
710704

711-
auto& funcPath = bodyCode->instructions->front()->sdp.sourcefile;
705+
auto& funcPath = bodyCode->instructions.front()->sdp.sourcefile;
712706

713707
auto scriptName = tryGetNameFromInitFunctions(state);
714708
if (!scriptName) scriptName = tryGetNameFromCBACompile(state);
715709
if (!scriptName) scriptName = getScriptName(str, funcPath, 32);
716710
//if (scriptName.empty()) scriptName = "<unknown>";
717711

718-
if (bodyCode->instructions&& bodyCode->instructions->size() > 4 && scriptName && !scriptName->empty())// && scriptName != "<unknown>"
712+
if (bodyCode->instructions.size() > 4 && scriptName && !scriptName->empty())// && scriptName != "<unknown>"
719713
addScopeInstruction(bodyCode->instructions, *scriptName);
720714

721715
return comp;

tracy

Submodule tracy updated from 4558508 to 6c86db8

0 commit comments

Comments
 (0)