From a2278cfb1e97001ab4a320cdbbd291ccda271c41 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 8 Mar 2021 22:50:42 -0800 Subject: [PATCH 1/2] Adds StrConv type for enum conversion --- External/FEXCore/Source/Common/StringConv.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/External/FEXCore/Source/Common/StringConv.h b/External/FEXCore/Source/Common/StringConv.h index bcec5b51a..407ac3d57 100644 --- a/External/FEXCore/Source/Common/StringConv.h +++ b/External/FEXCore/Source/Common/StringConv.h @@ -38,4 +38,11 @@ namespace FEXCore::StrConv { *Result = Value; return true; } + template ::value, T>> + [[maybe_unused]] static bool Conv(std::string_view Value, T *Result) { + *Result = static_cast(std::stoull(std::string(Value), nullptr, 0)); + return true; + } + } From a3ba1ae1990e00278f8651b4f1f3e48b1c061276 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 8 Mar 2021 22:53:41 -0800 Subject: [PATCH 2/2] Deduplicates some configuration data Configuration mapping was duplicated between three different tables. Additionally default configuration values were strewn about. Making it confusing as to what the default value would end up being Adds a new ConfigValues.inl header that defines a few things right next to each other. Defines the enum name as usual. Defines the JSON config option name. Defines the Environment config option name Defines the default value that the configuration should be --- .../Source/Interface/Config/Config.cpp | 112 ++---------------- .../Source/Interface/Context/Context.h | 37 +++--- .../FEXCore/Source/Interface/Core/Core.cpp | 24 ++-- .../FEXCore/Source/Interface/Core/GdbServer.h | 2 +- .../Source/Interface/Core/OpcodeDispatcher.h | 1 - .../Source/Interface/Core/X86HelperGen.cpp | 2 +- .../Source/Interface/HLE/Thunks/Thunks.cpp | 10 +- .../Source/Interface/IR/PassManager.cpp | 2 +- .../FEXCore/include/FEXCore/Config/Config.h | 52 ++++---- .../include/FEXCore/Config/ConfigValues.inl | 72 +++++++++++ Source/Common/ArgumentLoader.cpp | 5 - Source/Common/Config.cpp | 76 ++---------- Source/Core/CPU/HostCore/HostCore.cpp | 1 - Source/Tests/ELFLoader.cpp | 44 ++----- Source/Tests/HarnessHelpers.h | 2 +- Source/Tests/IRLoader.cpp | 13 -- .../EmulatedFiles/EmulatedFiles.h | 2 +- Source/Tests/LinuxSyscalls/FileManagement.h | 4 +- Source/Tests/LinuxSyscalls/Syscalls.h | 12 +- Source/Tests/LinuxSyscalls/x64/Memory.cpp | 2 +- Source/Tests/TestHarness.cpp | 8 -- Source/Tests/TestHarnessRunner.cpp | 30 +---- Source/Tools/Debugger/IMGui_I.cpp | 8 +- 23 files changed, 172 insertions(+), 349 deletions(-) create mode 100644 External/FEXCore/include/FEXCore/Config/ConfigValues.inl diff --git a/External/FEXCore/Source/Interface/Config/Config.cpp b/External/FEXCore/Source/Interface/Config/Config.cpp index 65b6ce3bc..16ade70f6 100644 --- a/External/FEXCore/Source/Interface/Config/Config.cpp +++ b/External/FEXCore/Source/Interface/Config/Config.cpp @@ -8,114 +8,12 @@ namespace FEXCore::Config { void SetConfig(FEXCore::Context::Context *CTX, ConfigOption Option, uint64_t Config) { - switch (Option) { - case FEXCore::Config::CONFIG_MULTIBLOCK: - CTX->Config.Multiblock = Config != 0; - break; - case FEXCore::Config::CONFIG_MAXBLOCKINST: - CTX->Config.MaxInstPerBlock = Config; - break; - case FEXCore::Config::CONFIG_DEFAULTCORE: - CTX->Config.Core = static_cast(Config); - break; - case FEXCore::Config::CONFIG_VIRTUALMEMSIZE: - CTX->Config.VirtualMemSize = Config; - break; - case FEXCore::Config::CONFIG_SINGLESTEP: - CTX->Config.RunningMode = Config != 0 ? FEXCore::Context::CoreRunningMode::MODE_SINGLESTEP : FEXCore::Context::CoreRunningMode::MODE_RUN; - break; - case FEXCore::Config::CONFIG_GDBSERVER: - Config != 0 ? CTX->StartGdbServer() : CTX->StopGdbServer(); - break; - case FEXCore::Config::CONFIG_IS64BIT_MODE: - CTX->Config.Is64BitMode = Config != 0; - break; - case FEXCore::Config::CONFIG_TSO_ENABLED: - CTX->Config.TSOEnabled = Config != 0; - break; - case FEXCore::Config::CONFIG_SMC_CHECKS: - CTX->Config.SMCChecks = static_cast(Config); - break; - case FEXCore::Config::CONFIG_ABI_LOCAL_FLAGS: - CTX->Config.ABILocalFlags = Config != 0; - break; - case FEXCore::Config::CONFIG_ABI_NO_PF: - CTX->Config.ABINoPF = Config != 0; - break; - case FEXCore::Config::CONFIG_VALIDATE_IR_PARSER: - CTX->Config.ValidateIRarser = Config != 0; - break; - case FEXCore::Config::CONFIG_AOTIR_GENERATE: - CTX->Config.AOTIRCapture = Config != 0; - break; - case FEXCore::Config::CONFIG_AOTIR_LOAD: - CTX->Config.AOTIRLoad = Config != 0; - break; - default: LogMan::Msg::A("Unknown configuration option"); - } } void SetConfig(FEXCore::Context::Context *CTX, ConfigOption Option, std::string const &Config) { - switch (Option) { - case CONFIG_ROOTFSPATH: - CTX->Config.RootFSPath = Config; - break; - case CONFIG_THUNKLIBSPATH: - CTX->Config.ThunkLibsPath = Config; - break; - case FEXCore::Config::CONFIG_DUMPIR: - CTX->Config.DumpIR = Config; - break; - default: LogMan::Msg::A("Unknown configuration option"); - } } uint64_t GetConfig(FEXCore::Context::Context *CTX, ConfigOption Option) { - switch (Option) { - case FEXCore::Config::CONFIG_MULTIBLOCK: - return CTX->Config.Multiblock; - break; - case FEXCore::Config::CONFIG_MAXBLOCKINST: - return CTX->Config.MaxInstPerBlock; - break; - case FEXCore::Config::CONFIG_DEFAULTCORE: - return CTX->Config.Core; - break; - case FEXCore::Config::CONFIG_VIRTUALMEMSIZE: - return CTX->Config.VirtualMemSize; - break; - case FEXCore::Config::CONFIG_SINGLESTEP: - return CTX->Config.RunningMode == FEXCore::Context::CoreRunningMode::MODE_SINGLESTEP ? 1 : 0; - case FEXCore::Config::CONFIG_GDBSERVER: - return CTX->GetGdbServerStatus(); - break; - case FEXCore::Config::CONFIG_IS64BIT_MODE: - return CTX->Config.Is64BitMode; - break; - case FEXCore::Config::CONFIG_TSO_ENABLED: - return CTX->Config.TSOEnabled; - break; - case FEXCore::Config::CONFIG_SMC_CHECKS: - return CTX->Config.SMCChecks; - break; - case FEXCore::Config::CONFIG_ABI_LOCAL_FLAGS: - return CTX->Config.ABILocalFlags; - break; - case FEXCore::Config::CONFIG_ABI_NO_PF: - return CTX->Config.ABINoPF; - break; - case FEXCore::Config::CONFIG_VALIDATE_IR_PARSER: - return CTX->Config.ValidateIRarser; - break; - case FEXCore::Config::CONFIG_AOTIR_GENERATE: - return CTX->Config.AOTIRCapture; - break; - case FEXCore::Config::CONFIG_AOTIR_LOAD: - return CTX->Config.AOTIRLoad; - break; - default: LogMan::Msg::A("Unknown configuration option"); - } - return 0; } @@ -252,8 +150,14 @@ namespace FEXCore::Config { } } - template bool Value::GetIfExists(FEXCore::Config::ConfigOption Option, bool Default); - template uint8_t Value::GetIfExists(FEXCore::Config::ConfigOption Option, uint8_t Default); + template bool Value::GetIfExists(FEXCore::Config::ConfigOption Option, bool Default); + template int8_t Value::GetIfExists(FEXCore::Config::ConfigOption Option, int8_t Default); + template uint8_t Value::GetIfExists(FEXCore::Config::ConfigOption Option, uint8_t Default); + template int16_t Value::GetIfExists(FEXCore::Config::ConfigOption Option, int16_t Default); + template uint16_t Value::GetIfExists(FEXCore::Config::ConfigOption Option, uint16_t Default); + template int32_t Value::GetIfExists(FEXCore::Config::ConfigOption Option, int32_t Default); + template uint32_t Value::GetIfExists(FEXCore::Config::ConfigOption Option, uint32_t Default); + template int64_t Value::GetIfExists(FEXCore::Config::ConfigOption Option, int64_t Default); template uint64_t Value::GetIfExists(FEXCore::Config::ConfigOption Option, uint64_t Default); // Constructor diff --git a/External/FEXCore/Source/Interface/Context/Context.h b/External/FEXCore/Source/Interface/Context/Context.h index 334a6ac9f..d9b7ab83f 100644 --- a/External/FEXCore/Source/Interface/Context/Context.h +++ b/External/FEXCore/Source/Interface/Context/Context.h @@ -63,30 +63,27 @@ namespace FEXCore::Context { friend class FEXCore::IR::Validation::IRValidation; struct { - bool Multiblock {false}; - bool BreakOnFrontendFailure {true}; - int64_t MaxInstPerBlock {-1LL}; - uint64_t VirtualMemSize {1ULL << 36}; CoreRunningMode RunningMode {CoreRunningMode::MODE_RUN}; - FEXCore::Config::ConfigCore Core {FEXCore::Config::CONFIG_INTERPRETER}; - bool GdbServer {false}; - std::string RootFSPath; - std::string ThunkLibsPath; - - bool Is64BitMode {true}; - bool TSOEnabled {true}; - FEXCore::Config::ConfigSMCChecks SMCChecks {FEXCore::Config::CONFIG_SMC_MMAN}; - bool ABILocalFlags {false}; - bool ABINoPF {false}; - - bool AOTIRCapture {false}; - bool AOTIRLoad {false}; - - std::string DumpIR; + uint64_t VirtualMemSize{1ULL << 36}; // this is for internal use bool ValidateIRarser { false }; + FEX_CONFIG_OPT(Multiblock, MULTIBLOCK); + FEX_CONFIG_OPT(SingleStepConfig, SINGLESTEP); + FEX_CONFIG_OPT(GdbServer, GDBSERVER); + FEX_CONFIG_OPT(Is64BitMode, IS64BIT_MODE); + FEX_CONFIG_OPT(TSOEnabled, TSO_ENABLED); + FEX_CONFIG_OPT(ABILocalFlags, ABI_LOCAL_FLAGS); + FEX_CONFIG_OPT(ABINoPF, ABI_NO_PF); + FEX_CONFIG_OPT(AOTIRCapture, AOTIR_GENERATE); + FEX_CONFIG_OPT(AOTIRLoad, AOTIR_LOAD); + FEX_CONFIG_OPT(SMCChecks, SMC_CHECKS); + FEX_CONFIG_OPT(Core, DEFAULTCORE); + FEX_CONFIG_OPT(MaxInstPerBlock, MAXBLOCKINST); + FEX_CONFIG_OPT(RootFSPath, ROOTFSPATH); + FEX_CONFIG_OPT(ThunkLibsPath, THUNKLIBSPATH); + FEX_CONFIG_OPT(DumpIR, DUMPIR); } Config; using IntCallbackReturn = __attribute__((naked)) void(*)(FEXCore::Core::InternalThreadState *Thread, volatile void *Host_RSP); @@ -231,7 +228,7 @@ namespace FEXCore::Context { std::unique_ptr DebugServer; bool StartPaused = false; - FEXCore::Config::Value AppFilename{FEXCore::Config::CONFIG_APP_FILENAME, ""}; + FEX_CONFIG_OPT(AppFilename, APP_FILENAME); }; uint64_t HandleSyscall(FEXCore::HLE::SyscallHandler *Handler, FEXCore::Core::InternalThreadState *Thread, FEXCore::HLE::SyscallArguments *Args); diff --git a/External/FEXCore/Source/Interface/Core/Core.cpp b/External/FEXCore/Source/Interface/Core/Core.cpp index aaca037f3..5a22de2e4 100644 --- a/External/FEXCore/Source/Interface/Core/Core.cpp +++ b/External/FEXCore/Source/Interface/Core/Core.cpp @@ -179,6 +179,12 @@ namespace FEXCore::Context { #ifdef BLOCKSTATS BlockData = std::make_unique(); #endif + if (Config.GdbServer) { + StartGdbServer(); + } + else { + StopGdbServer(); + } } bool Context::GetFilenameHash(std::string const &Filename, std::string &Hash) { @@ -641,10 +647,6 @@ namespace FEXCore::Context { uint64_t TotalInstructionsLength {0}; if (!Thread->FrontendDecoder->DecodeInstructionsAtEntry(GuestCode, GuestRIP)) { - if (Config.BreakOnFrontendFailure) { - LogMan::Msg::E("Had Frontend decoder error"); - Stop(false /* Ignore Current Thread */); - } return { nullptr, nullptr, 0, 0, 0, 0 }; } @@ -703,10 +705,6 @@ namespace FEXCore::Context { auto Fn = TableInfo->OpcodeDispatcher; std::invoke(Fn, Thread->OpDispatcher, DecodedInfo); if (Thread->OpDispatcher->HadDecodeFailure()) { - if (Config.BreakOnFrontendFailure) { - LogMan::Msg::E("Had OpDispatcher error at 0x%lx", GuestRIP); - Stop(false /* Ignore Current Thread */); - } HadDispatchError = true; } else { @@ -748,15 +746,15 @@ namespace FEXCore::Context { FILE* f = nullptr; bool CloseAfter = false; - if (Thread->CTX->Config.DumpIR=="stderr") { + if (Thread->CTX->Config.DumpIR() =="stderr") { f = stderr; } - else if (Thread->CTX->Config.DumpIR=="stdout") { + else if (Thread->CTX->Config.DumpIR() =="stdout") { f = stdout; } else { std::stringstream fileName; - fileName << Thread->CTX->Config.DumpIR << "/" << std::hex << GuestRIP << (RA ? "-post.ir" : "-pre.ir"); + fileName << Thread->CTX->Config.DumpIR() << "/" << std::hex << GuestRIP << (RA ? "-post.ir" : "-pre.ir"); f = fopen(fileName.str().c_str(), "w"); CloseAfter = true; @@ -774,7 +772,7 @@ namespace FEXCore::Context { } }; - if (Thread->CTX->Config.DumpIR != "no") { + if (Thread->CTX->Config.DumpIR() != "no") { IRDumper(nullptr); } @@ -804,7 +802,7 @@ namespace FEXCore::Context { // Run the passmanager over the IR from the dispatcher Thread->PassManager->Run(Thread->OpDispatcher.get()); - if (Thread->CTX->Config.DumpIR != "no") { + if (Thread->CTX->Config.DumpIR() != "no") { IRDumper(Thread->PassManager->GetRAPass() ? Thread->PassManager->GetRAPass()->GetAllocationData() : nullptr); } diff --git a/External/FEXCore/Source/Interface/Core/GdbServer.h b/External/FEXCore/Source/Interface/Core/GdbServer.h index 5081afea8..651dca939 100644 --- a/External/FEXCore/Source/Interface/Core/GdbServer.h +++ b/External/FEXCore/Source/Interface/Core/GdbServer.h @@ -57,7 +57,7 @@ private: bool NoAckMode{false}; std::string ThreadString{}; uint32_t CurrentDebuggingThread{}; - FEXCore::Config::Value Filename{FEXCore::Config::CONFIG_APP_FILENAME, ""}; + FEX_CONFIG_OPT(Filename, APP_FILENAME); }; } diff --git a/External/FEXCore/Source/Interface/Core/OpcodeDispatcher.h b/External/FEXCore/Source/Interface/Core/OpcodeDispatcher.h index 63ed56e17..f861ec763 100644 --- a/External/FEXCore/Source/Interface/Core/OpcodeDispatcher.h +++ b/External/FEXCore/Source/Interface/Core/OpcodeDispatcher.h @@ -475,7 +475,6 @@ public: OrderedNode *GetPackedRFLAG(bool Lower8); void SetMultiblock(bool _Multiblock) { Multiblock = _Multiblock; } - bool GetMultiblock() { return Multiblock; } private: bool DecodeFailure{false}; diff --git a/External/FEXCore/Source/Interface/Core/X86HelperGen.cpp b/External/FEXCore/Source/Interface/Core/X86HelperGen.cpp index 4ed9099e3..e8aafe2d3 100644 --- a/External/FEXCore/Source/Interface/Core/X86HelperGen.cpp +++ b/External/FEXCore/Source/Interface/Core/X86HelperGen.cpp @@ -28,7 +28,7 @@ X86GeneratedCode::~X86GeneratedCode() { } void* X86GeneratedCode::AllocateGuestCodeSpace(size_t Size) { - FEXCore::Config::Value Is64BitMode{FEXCore::Config::CONFIG_IS64BIT_MODE, 0}; + FEX_CONFIG_OPT(Is64BitMode, IS64BIT_MODE); if (Is64BitMode()) { // 64bit mode can have its sigret handler anywhere diff --git a/External/FEXCore/Source/Interface/HLE/Thunks/Thunks.cpp b/External/FEXCore/Source/Interface/HLE/Thunks/Thunks.cpp index 2aa21bb70..d83e7678b 100644 --- a/External/FEXCore/Source/Interface/HLE/Thunks/Thunks.cpp +++ b/External/FEXCore/Source/Interface/HLE/Thunks/Thunks.cpp @@ -23,7 +23,7 @@ static thread_local FEXCore::Core::InternalThreadState *Thread; namespace FEXCore { - + struct ExportEntry { uint8_t *sha256; ThunkedFunction* Fn; }; class ThunkHandler_impl final: public ThunkHandler { @@ -41,7 +41,7 @@ namespace FEXCore { Set arg0/1 to arg regs, use CTX::HandleCallback to handle the callback */ static void CallCallback(void *callback, void *arg0, void* arg1) { - + Thread->State.State.gregs[FEXCore::X86State::REG_RDI] = (uintptr_t)arg0; Thread->State.State.gregs[FEXCore::X86State::REG_RSI] = (uintptr_t)arg1; @@ -57,10 +57,10 @@ namespace FEXCore { auto Name = Args->Name; auto CallbackThunks = Args->CallbackThunks; - auto SOName = CTX->Config.ThunkLibsPath + "/" + (const char*)Name + "-host.so"; + auto SOName = CTX->Config.ThunkLibsPath() + "/" + (const char*)Name + "-host.so"; LogMan::Msg::D("Load lib: %s -> %s", Name, SOName.c_str()); - + auto Handle = dlopen(SOName.c_str(), RTLD_LOCAL | RTLD_NOW); if (!Handle) { @@ -78,7 +78,7 @@ namespace FEXCore { LogMan::Msg::E("Load lib: failed to find export %s", InitSym.c_str()); return; } - + auto Exports = InitFN((void*)&CallCallback, CallbackThunks); auto That = reinterpret_cast(CTX->ThunkHandler.get()); diff --git a/External/FEXCore/Source/Interface/IR/PassManager.cpp b/External/FEXCore/Source/Interface/IR/PassManager.cpp index 992fef2c0..d03ee4ade 100644 --- a/External/FEXCore/Source/Interface/IR/PassManager.cpp +++ b/External/FEXCore/Source/Interface/IR/PassManager.cpp @@ -7,7 +7,7 @@ namespace FEXCore::IR { void PassManager::AddDefaultPasses(bool InlineConstants, bool StaticRegisterAllocation) { - FEXCore::Config::Value DisablePasses{FEXCore::Config::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES, false}; + FEX_CONFIG_OPT(DisablePasses, DEBUG_DISABLE_OPTIMIZATION_PASSES); if (!DisablePasses()) { InsertPass(CreateContextLoadStoreElimination()); diff --git a/External/FEXCore/include/FEXCore/Config/Config.h b/External/FEXCore/include/FEXCore/Config/Config.h index 040be52b7..3da5909bd 100644 --- a/External/FEXCore/include/FEXCore/Config/Config.h +++ b/External/FEXCore/include/FEXCore/Config/Config.h @@ -9,33 +9,8 @@ namespace FEXCore::Config { enum ConfigOption { - CONFIG_MULTIBLOCK, - CONFIG_MAXBLOCKINST, - CONFIG_DEFAULTCORE, - CONFIG_VIRTUALMEMSIZE, - CONFIG_SINGLESTEP, - CONFIG_GDBSERVER, - CONFIG_ROOTFSPATH, - CONFIG_THUNKLIBSPATH, - CONFIG_IS64BIT_MODE, - CONFIG_EMULATED_CPU_CORES, - CONFIG_TSO_ENABLED, - CONFIG_SMC_CHECKS, - CONFIG_ABI_LOCAL_FLAGS, - CONFIG_ABI_NO_PF, - CONFIG_DUMPIR, - CONFIG_VALIDATE_IR_PARSER, - CONFIG_SILENTLOGS, - CONFIG_ENVIRONMENT, - CONFIG_OUTPUTLOG, - CONFIG_BREAK_ON_FRONTEND, - CONFIG_DUMP_GPRS, - CONFIG_IS_INTERPRETER, - CONFIG_INTERPRETER_INSTALLED, - CONFIG_APP_FILENAME, - CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES, - CONFIG_AOTIR_GENERATE, - CONFIG_AOTIR_LOAD +#define OPT_BASE(type, group, enum, json, env, default) CONFIG_##enum, +#include }; enum ConfigCore { @@ -49,10 +24,6 @@ namespace FEXCore::Config { CONFIG_SMC_MMAN, CONFIG_SMC_FULL, }; - - void SetConfig(FEXCore::Context::Context *CTX, ConfigOption Option, uint64_t Config); - void SetConfig(FEXCore::Context::Context *CTX, ConfigOption Option, std::string const &Config); - uint64_t GetConfig(FEXCore::Context::Context *CTX, ConfigOption Option); enum class LayerType { LAYER_MAIN, @@ -63,6 +34,23 @@ namespace FEXCore::Config { LAYER_TOP, }; +namespace DefaultValues { +#define P(x) x +#define OPT_BASE(type, group, enum, json, env, default) constexpr P(type) P(enum) = P(default); +#define OPT_STR(group, enum, json, env, default) const std::string P(enum) = P(default); +#include + +namespace Type { +#define OPT_BASE(type, group, enum, json, env, default) using P(enum) = P(type); +#define OPT_STR(group, enum, json, env, default) using P(enum) = std::string; +#include +} +#define FEX_CONFIG_OPT(name, enum) \ + FEXCore::Config::Value name {FEXCore::Config::CONFIG_##enum, FEXCore::Config::DefaultValues::enum} + +#undef P +} + using LayerValue = std::list; using LayerOptions = std::unordered_map; @@ -147,7 +135,9 @@ namespace FEXCore::Config { GetListIfExists(Option, &AppendList); } + operator T() { return ValueData; } T operator()() { return ValueData; } + Value(T Value) { ValueData = Value; } std::list &All() { return AppendList; } private: diff --git a/External/FEXCore/include/FEXCore/Config/ConfigValues.inl b/External/FEXCore/include/FEXCore/Config/ConfigValues.inl new file mode 100644 index 000000000..373a309e9 --- /dev/null +++ b/External/FEXCore/include/FEXCore/Config/ConfigValues.inl @@ -0,0 +1,72 @@ +#ifndef OPT_BASE +#define OPT_BASE(type, group, enum, json, env, default) +#endif +#ifndef OPT_BOOL +#define OPT_BOOL(group, enum, json, env, default) OPT_BASE(bool, group, enum, json, env, default) +#endif +#ifndef OPT_UINT8 +#define OPT_UINT8(group, enum, json, env, default) OPT_BASE(uint8_t, group, enum, json, env, default) +#endif +#ifndef OPT_INT32 +#define OPT_INT32(group, enum, json, env, default) OPT_BASE(int32_t, group, enum, json, env, default) +#endif +#ifndef OPT_UINT32 +#define OPT_UINT32(group, enum, json, env, default) OPT_BASE(uint32_t, group, enum, json, env, default) +#endif +#ifndef OPT_UINT64 +#define OPT_UINT64(group, enum, json, env, default) OPT_BASE(uint64_t, group, enum, json, env, default) +#endif +#ifndef OPT_STR +#define OPT_STR(group, enum, json, env, default) OPT_BASE(std::string, group, enum, json, env, default) +#endif +#ifndef OPT_STRARRAY +#define OPT_STRARRAY(group, enum, json, env, default) OPT_BASE(std::string, group, enum, json, env, default) +#endif + +// Option definitions +// Arguments +// 1) Group +// 2) Enum name +// 3) json Option name +// 4) Environment Option name +// 5) Default option +OPT_UINT32(CPU, DEFAULTCORE, Core, CORE, FEXCore::Config::ConfigCore::CONFIG_IRJIT) +OPT_BOOL (CPU, MULTIBLOCK, Multiblock, MULTIBLOCK, true) +OPT_INT32 (CPU, MAXBLOCKINST, MaxInst, MAXINST, 5000) +OPT_INT32 (CPU, EMULATED_CPU_CORES, Threads, THREADS, 1) + +OPT_STR (EMULATION, ROOTFSPATH, RootFS, ROOTFS, "") +OPT_STR (EMULATION, THUNKLIBSPATH, ThunkLibs, THUNKLIBS, "") +OPT_STR (EMULATION, THUNKSCONFIGPATH, ThunksConfigPath, THUNKSCONFIGPATH, "") + +OPT_STR (EMULATION, ENVIRONMENT, Env, ENV, "") + +OPT_BOOL (DEBUG, SINGLESTEP, SingleStep, SINGLESTEP, false) +OPT_BOOL (DEBUG, GDBSERVER, GdbServer, GDBSERVER, false) +OPT_STR (DEBUG, DUMPIR, DumpIR, DUMPIR, "no") +OPT_BOOL (DEBUG, DUMP_GPRS, DumpGPRs, DUMP_GPRS, false) +OPT_BOOL (DEBUG, DEBUG_DISABLE_OPTIMIZATION_PASSES, O0, O0, false) + +OPT_BOOL (LOGGING, SILENTLOGS, SilentLog, SILENTLOG, false) +OPT_STR (LOGGING, OUTPUTLOG, OutputLog, OUTPUTLOG, "") + +OPT_BOOL (HACKS, TSO_ENABLED, TSOEnabled, TSO_ENABLED, true) +OPT_UINT8 (HACKS, SMC_CHECKS, SMCChecks, SMC_CHECKS, FEXCore::Config::CONFIG_SMC_MMAN) +OPT_BOOL (HACKS, ABI_LOCAL_FLAGS, ABILocalFlags, ABILOCALFLAGS, false) +OPT_BOOL (HACKS, ABI_NO_PF, ABINoPF, ABINOPF, false) + +OPT_BOOL (MISC, IS_INTERPRETER, INVALID, INVALID, false) +OPT_BOOL (MISC, INTERPRETER_INSTALLED, INVALID, INVALID, false) +OPT_STR (MISC, APP_FILENAME, INVALID, INVALID, "") +OPT_BOOL (MISC, AOTIR_GENERATE, AOTIRCapture, AOT_GENERATE, false) +OPT_BOOL (MISC, AOTIR_LOAD, AOTIRLoad, AOT_LOAD, false) +OPT_BOOL (MISC, IS64BIT_MODE, INVALID, INVALID, false) + +#undef OPT_BASE +#undef OPT_BOOL +#undef OPT_UINT8 +#undef OPT_INT32 +#undef OPT_UINT32 +#undef OPT_UINT64 +#undef OPT_STR +#undef OPT_STRARRAY diff --git a/Source/Common/ArgumentLoader.cpp b/Source/Common/ArgumentLoader.cpp index 5e6753a15..f063c4d5f 100644 --- a/Source/Common/ArgumentLoader.cpp +++ b/Source/Common/ArgumentLoader.cpp @@ -189,11 +189,6 @@ namespace FEX::ArgLoader { #endif } - if (Options.is_set_by_user("Break")) { - bool Break = Options.get("Break"); - Set(FEXCore::Config::ConfigOption::CONFIG_BREAK_ON_FRONTEND, std::to_string(Break)); - } - if (Options.is_set_by_user("SingleStep")) { bool SingleStep = Options.get("SingleStep"); Set(FEXCore::Config::ConfigOption::CONFIG_SINGLESTEP, std::to_string(SingleStep)); diff --git a/Source/Common/Config.cpp b/Source/Common/Config.cpp index 07af50404..4262a4f10 100644 --- a/Source/Common/Config.cpp +++ b/Source/Common/Config.cpp @@ -171,27 +171,18 @@ namespace FEX::Config { } static const std::map ConfigToNameLookup = {{ - {FEXCore::Config::ConfigOption::CONFIG_DEFAULTCORE, "Core"}, - {FEXCore::Config::ConfigOption::CONFIG_MAXBLOCKINST, "MaxInst"}, - {FEXCore::Config::ConfigOption::CONFIG_SINGLESTEP, "SingleStep"}, - {FEXCore::Config::ConfigOption::CONFIG_MULTIBLOCK, "Multiblock"}, - {FEXCore::Config::ConfigOption::CONFIG_GDBSERVER, "GdbServer"}, - {FEXCore::Config::ConfigOption::CONFIG_EMULATED_CPU_CORES, "Threads"}, - {FEXCore::Config::ConfigOption::CONFIG_ROOTFSPATH, "RootFS"}, - {FEXCore::Config::ConfigOption::CONFIG_THUNKLIBSPATH, "ThunkLibs"}, - {FEXCore::Config::ConfigOption::CONFIG_SILENTLOGS, "SilentLog"}, - {FEXCore::Config::ConfigOption::CONFIG_ENVIRONMENT, "Env"}, - {FEXCore::Config::ConfigOption::CONFIG_OUTPUTLOG, "OutputLog"}, - {FEXCore::Config::ConfigOption::CONFIG_DUMPIR, "DumpIR"}, - {FEXCore::Config::ConfigOption::CONFIG_TSO_ENABLED, "TSOEnabled"}, - {FEXCore::Config::ConfigOption::CONFIG_SMC_CHECKS, "SMCChecks"}, - {FEXCore::Config::ConfigOption::CONFIG_ABI_LOCAL_FLAGS, "ABILocalFlags"}, - {FEXCore::Config::ConfigOption::CONFIG_ABI_NO_PF, "ABINoPF"}, - {FEXCore::Config::ConfigOption::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES, "O0"}, - {FEXCore::Config::ConfigOption::CONFIG_AOTIR_GENERATE, "AOTIRCapture"}, - {FEXCore::Config::ConfigOption::CONFIG_AOTIR_LOAD, "AOTIRLoad"}, +#define OPT_BASE(type, group, enum, json, env, default) {FEXCore::Config::ConfigOption::CONFIG_##enum, #json}, +#include }}; + static const std::map ConfigLookup = {{ +#define OPT_BASE(type, group, enum, json, env, default) {#json, FEXCore::Config::ConfigOption::CONFIG_##enum}, +#include + }}; + static const std::vector> EnvConfigLookup = {{ +#define OPT_BASE(type, group, enum, json, env, default) {"FEX_" #env, FEXCore::Config::ConfigOption::CONFIG_##enum}, +#include + }}; void SaveLayerToJSON(std::string Filename, FEXCore::Config::Layer *const Layer) { char Buffer[4096]; @@ -219,28 +210,6 @@ namespace FEX::Config { : FEXCore::Config::Layer(Layer) { } - static const std::map ConfigLookup = {{ - {"Core", FEXCore::Config::ConfigOption::CONFIG_DEFAULTCORE}, - {"MaxInst", FEXCore::Config::ConfigOption::CONFIG_MAXBLOCKINST}, - {"SingleStep", FEXCore::Config::ConfigOption::CONFIG_SINGLESTEP}, - {"Multiblock", FEXCore::Config::ConfigOption::CONFIG_MULTIBLOCK}, - {"GdbServer", FEXCore::Config::ConfigOption::CONFIG_GDBSERVER}, - {"Threads", FEXCore::Config::ConfigOption::CONFIG_EMULATED_CPU_CORES}, - {"RootFS", FEXCore::Config::ConfigOption::CONFIG_ROOTFSPATH}, - {"ThunkLibs", FEXCore::Config::ConfigOption::CONFIG_THUNKLIBSPATH}, - {"SilentLog", FEXCore::Config::ConfigOption::CONFIG_SILENTLOGS}, - {"Env", FEXCore::Config::ConfigOption::CONFIG_ENVIRONMENT}, - {"OutputLog", FEXCore::Config::ConfigOption::CONFIG_OUTPUTLOG}, - {"DumpIR", FEXCore::Config::ConfigOption::CONFIG_DUMPIR}, - {"TSOEnabled", FEXCore::Config::ConfigOption::CONFIG_TSO_ENABLED}, - {"SMCChecks", FEXCore::Config::ConfigOption::CONFIG_SMC_CHECKS}, - {"ABILocalFlags", FEXCore::Config::ConfigOption::CONFIG_ABI_LOCAL_FLAGS}, - {"AbiNoPF", FEXCore::Config::ConfigOption::CONFIG_ABI_NO_PF}, - {"O0", FEXCore::Config::ConfigOption::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES}, - {"AOTIRCapture", FEXCore::Config::ConfigOption::CONFIG_AOTIR_GENERATE}, - {"AOTIRLoad", FEXCore::Config::ConfigOption::CONFIG_AOTIR_LOAD}, - }}; - void OptionMapper::MapNameToOption(const char *ConfigName, const char *ConfigString) { auto it = ConfigLookup.find(ConfigName); if (it != ConfigLookup.end()) { @@ -311,32 +280,9 @@ namespace FEX::Config { } }; - static const std::array, 20> ConfigLookup = {{ - {"FEX_CORE", FEXCore::Config::ConfigOption::CONFIG_DEFAULTCORE}, - {"FEX_MAXINST", FEXCore::Config::ConfigOption::CONFIG_MAXBLOCKINST}, - {"FEX_SINGLESTEP", FEXCore::Config::ConfigOption::CONFIG_SINGLESTEP}, - {"FEX_MULTIBLOCK", FEXCore::Config::ConfigOption::CONFIG_MULTIBLOCK}, - {"FEX_GDBSERVER", FEXCore::Config::ConfigOption::CONFIG_GDBSERVER}, - {"FEX_THREADS", FEXCore::Config::ConfigOption::CONFIG_EMULATED_CPU_CORES}, - {"FEX_ROOTFS", FEXCore::Config::ConfigOption::CONFIG_ROOTFSPATH}, - {"FEX_THUNKLIBS", FEXCore::Config::ConfigOption::CONFIG_THUNKLIBSPATH}, - {"FEX_SILENTLOG", FEXCore::Config::ConfigOption::CONFIG_SILENTLOGS}, - {"FEX_ENV", FEXCore::Config::ConfigOption::CONFIG_ENVIRONMENT}, - {"FEX_OUTPUTLOG", FEXCore::Config::ConfigOption::CONFIG_OUTPUTLOG}, - {"FEX_DUMPIR", FEXCore::Config::ConfigOption::CONFIG_DUMPIR}, - {"FEX_TSOENABLED", FEXCore::Config::ConfigOption::CONFIG_TSO_ENABLED}, - {"FEX_SMCCHECKS", FEXCore::Config::ConfigOption::CONFIG_SMC_CHECKS}, - {"FEX_ABILOCALFLAGS", FEXCore::Config::ConfigOption::CONFIG_ABI_LOCAL_FLAGS}, - {"FEX_ABINOPF", FEXCore::Config::ConfigOption::CONFIG_ABI_NO_PF}, - {"FEX_BREAK", FEXCore::Config::ConfigOption::CONFIG_BREAK_ON_FRONTEND}, - {"FEX_DUMP_GPRS", FEXCore::Config::ConfigOption::CONFIG_DUMP_GPRS}, - {"FEX_AOT_GENERATE", FEXCore::Config::ConfigOption::CONFIG_AOTIR_GENERATE}, - {"FEX_AOT_LOAD", FEXCore::Config::ConfigOption::CONFIG_AOTIR_LOAD}, - }}; - std::optional Value; - for (auto &it : ConfigLookup) { + for (auto &it : EnvConfigLookup) { if ((Value = GetVar(it.first)).has_value()) { Set(it.second, std::string(*Value)); } diff --git a/Source/Core/CPU/HostCore/HostCore.cpp b/Source/Core/CPU/HostCore/HostCore.cpp index 8c5169e2f..fc3243bcc 100644 --- a/Source/Core/CPU/HostCore/HostCore.cpp +++ b/Source/Core/CPU/HostCore/HostCore.cpp @@ -48,7 +48,6 @@ private: void InstallSignalHandler(); FEX::ThreadState *ThreadState; - FEXCore::Config::Value ConfigMultiblock{"Multiblock", false}; std::thread ExecutionThread; Memmap LocalMemoryMapper{}; pid_t ChildPid; diff --git a/Source/Tests/ELFLoader.cpp b/Source/Tests/ELFLoader.cpp index 7ecaf811e..79696cc11 100644 --- a/Source/Tests/ELFLoader.cpp +++ b/Source/Tests/ELFLoader.cpp @@ -193,24 +193,12 @@ int main(int argc, char **argv, char **const envp) { FEXCore::Config::Set(FEXCore::Config::CONFIG_IS_INTERPRETER, IsInterpreter ? "1" : "0"); FEXCore::Config::Set(FEXCore::Config::CONFIG_INTERPRETER_INSTALLED, IsInterpreterInstalled() ? "1" : "0"); - FEXCore::Config::Value CoreConfig{FEXCore::Config::CONFIG_DEFAULTCORE, 1}; - FEXCore::Config::Value BlockSizeConfig{FEXCore::Config::CONFIG_MAXBLOCKINST, 5000}; - FEXCore::Config::Value SingleStepConfig{FEXCore::Config::CONFIG_SINGLESTEP, false}; - FEXCore::Config::Value MultiblockConfig{FEXCore::Config::CONFIG_MULTIBLOCK, true}; - FEXCore::Config::Value GdbServerConfig{FEXCore::Config::CONFIG_GDBSERVER, false}; - FEXCore::Config::Value LDPath{FEXCore::Config::CONFIG_ROOTFSPATH, ""}; - FEXCore::Config::Value ThunkLibsPath{FEXCore::Config::CONFIG_THUNKLIBSPATH, ""}; - FEXCore::Config::Value SilentLog{FEXCore::Config::CONFIG_SILENTLOGS, false}; - FEXCore::Config::Value Environment{FEXCore::Config::CONFIG_ENVIRONMENT, ""}; - FEXCore::Config::Value OutputLog{FEXCore::Config::CONFIG_OUTPUTLOG, "stderr"}; - FEXCore::Config::Value DumpIR{FEXCore::Config::CONFIG_DUMPIR, "no"}; - FEXCore::Config::Value TSOEnabledConfig{FEXCore::Config::CONFIG_TSO_ENABLED, true}; - FEXCore::Config::Value SMCChecksConfig{FEXCore::Config::CONFIG_SMC_CHECKS, FEXCore::Config::CONFIG_SMC_MMAN}; - FEXCore::Config::Value ABILocalFlags{FEXCore::Config::CONFIG_ABI_LOCAL_FLAGS, false}; - FEXCore::Config::Value AbiNoPF{FEXCore::Config::CONFIG_ABI_NO_PF, false}; - FEXCore::Config::Value AOTIRCapture{FEXCore::Config::CONFIG_AOTIR_GENERATE, false}; - FEXCore::Config::Value AOTIRLoad{FEXCore::Config::CONFIG_AOTIR_LOAD, false}; - + FEX_CONFIG_OPT(SilentLog, SILENTLOGS); + FEX_CONFIG_OPT(AOTIRCapture, AOTIR_GENERATE); + FEX_CONFIG_OPT(AOTIRLoad, AOTIR_LOAD); + FEX_CONFIG_OPT(OutputLog, OUTPUTLOG); + FEX_CONFIG_OPT(LDPath, ROOTFSPATH); + FEX_CONFIG_OPT(Environment, ENVIRONMENT); ::SilentLog = SilentLog(); if (!::SilentLog) { @@ -236,6 +224,8 @@ int main(int argc, char **argv, char **const envp) { } FEX::HarnessHelper::ELFCodeLoader Loader{Program, LDPath(), Args, ParsedArgs, envp, &Environment}; + FEXCore::Config::Set(FEXCore::Config::CONFIG_APP_FILENAME, std::filesystem::canonical(Program)); + FEXCore::Config::Set(FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode() ? "1" : "0"); uint32_t KernelVersion = FEX::HLE::SyscallHandler::CalculateHostKernelVersion(); if (KernelVersion < FEX::HLE::SyscallHandler::KernelVersion(4, 17) && @@ -249,24 +239,6 @@ int main(int argc, char **argv, char **const envp) { auto CTX = FEXCore::Context::CreateNewContext(); FEXCore::Context::InitializeContext(CTX); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_DEFAULTCORE, CoreConfig() > 3 ? FEXCore::Config::CONFIG_CUSTOM : CoreConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_MULTIBLOCK, MultiblockConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_SINGLESTEP, SingleStepConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_MAXBLOCKINST, BlockSizeConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_GDBSERVER, GdbServerConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_ROOTFSPATH, LDPath()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_THUNKLIBSPATH, ThunkLibsPath()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_TSO_ENABLED, TSOEnabledConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_SMC_CHECKS, SMCChecksConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_ABI_LOCAL_FLAGS, ABILocalFlags()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_ABI_NO_PF, AbiNoPF()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_DUMPIR, DumpIR()); - FEXCore::Config::Set(FEXCore::Config::CONFIG_APP_FILENAME, std::filesystem::canonical(Program)); - FEXCore::Config::Set(FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode() ? "1" : "0"); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_AOTIR_GENERATE, AOTIRCapture()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_AOTIR_LOAD, AOTIRLoad()); - std::unique_ptr SignalDelegation = std::make_unique(); std::unique_ptr SyscallHandler{ FEX::HLE::CreateHandler( diff --git a/Source/Tests/HarnessHelpers.h b/Source/Tests/HarnessHelpers.h index 761ae73c4..70acc286d 100644 --- a/Source/Tests/HarnessHelpers.h +++ b/Source/Tests/HarnessHelpers.h @@ -289,7 +289,7 @@ namespace FEX::HarnessHelper { bool Is64BitMode() const { return BaseConfig.OptionMode == 1; } private: - FEXCore::Config::Value ConfigDumpGPRs{FEXCore::Config::CONFIG_DUMP_GPRS, false}; + FEX_CONFIG_OPT(ConfigDumpGPRs, DUMP_GPRS); struct ConfigStructBase { uint64_t OptionMatch; diff --git a/Source/Tests/IRLoader.cpp b/Source/Tests/IRLoader.cpp index 89f288af7..145f43d8f 100644 --- a/Source/Tests/IRLoader.cpp +++ b/Source/Tests/IRLoader.cpp @@ -98,13 +98,6 @@ int main(int argc, char **argv, char **const envp) { FEXCore::Config::AddLayer(std::make_unique(envp)); FEXCore::Config::Load(); - FEXCore::Config::Value CoreConfig{FEXCore::Config::CONFIG_DEFAULTCORE, 0}; - FEXCore::Config::Value BlockSizeConfig{FEXCore::Config::CONFIG_MAXBLOCKINST, 1}; - FEXCore::Config::Value SingleStepConfig{FEXCore::Config::CONFIG_SINGLESTEP, false}; - FEXCore::Config::Value MultiblockConfig{FEXCore::Config::CONFIG_MULTIBLOCK, false}; - FEXCore::Config::Value GdbServerConfig{FEXCore::Config::CONFIG_GDBSERVER, false}; - FEXCore::Config::Value LDPath{FEXCore::Config::CONFIG_ROOTFSPATH, ""}; - auto Args = FEX::ArgLoader::Get(); auto ParsedArgs = FEX::ArgLoader::GetParsedArgs(); @@ -114,12 +107,6 @@ int main(int argc, char **argv, char **const envp) { auto CTX = FEXCore::Context::CreateNewContext(); FEXCore::Context::InitializeContext(CTX); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_DEFAULTCORE, CoreConfig() > 3 ? FEXCore::Config::CONFIG_CUSTOM : CoreConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_MULTIBLOCK, MultiblockConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_SINGLESTEP, SingleStepConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_MAXBLOCKINST, BlockSizeConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_GDBSERVER, GdbServerConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_ROOTFSPATH, LDPath()); std::unique_ptr SignalDelegation = std::make_unique(); FEXCore::Context::SetSignalDelegator(CTX, SignalDelegation.get()); diff --git a/Source/Tests/LinuxSyscalls/EmulatedFiles/EmulatedFiles.h b/Source/Tests/LinuxSyscalls/EmulatedFiles/EmulatedFiles.h index cd0142562..164479ad5 100644 --- a/Source/Tests/LinuxSyscalls/EmulatedFiles/EmulatedFiles.h +++ b/Source/Tests/LinuxSyscalls/EmulatedFiles/EmulatedFiles.h @@ -29,6 +29,6 @@ namespace FEX::EmulatedFile { std::unordered_map FDReadCreators; static int32_t ProcAuxv(FEXCore::Context::Context* ctx, int32_t fd, const char* pathname, int32_t flags, mode_t mode); - FEXCore::Config::Value ThreadsConfig{FEXCore::Config::CONFIG_EMULATED_CPU_CORES, 1}; + FEX_CONFIG_OPT(ThreadsConfig, EMULATED_CPU_CORES); }; } diff --git a/Source/Tests/LinuxSyscalls/FileManagement.h b/Source/Tests/LinuxSyscalls/FileManagement.h index 748a7f990..21f095712 100644 --- a/Source/Tests/LinuxSyscalls/FileManagement.h +++ b/Source/Tests/LinuxSyscalls/FileManagement.h @@ -50,7 +50,7 @@ private: std::string PidSelfPath; std::string GetEmulatedPath(const char *pathname); - FEXCore::Config::Value Filename{FEXCore::Config::CONFIG_APP_FILENAME, ""}; - FEXCore::Config::Value LDPath{FEXCore::Config::CONFIG_ROOTFSPATH, ""}; + FEX_CONFIG_OPT(Filename, APP_FILENAME); + FEX_CONFIG_OPT(LDPath, ROOTFSPATH); }; } diff --git a/Source/Tests/LinuxSyscalls/Syscalls.h b/Source/Tests/LinuxSyscalls/Syscalls.h index 01fbc71b9..dd7e63caf 100644 --- a/Source/Tests/LinuxSyscalls/Syscalls.h +++ b/Source/Tests/LinuxSyscalls/Syscalls.h @@ -99,12 +99,12 @@ public: void SetCodeLoader(FEXCore::CodeLoader *Loader) { LocalLoader = Loader; } FEX::HLE::SignalDelegator *GetSignalDelegator() { return SignalDelegation; } - FEXCore::Config::Value IsInterpreter{FEXCore::Config::CONFIG_IS_INTERPRETER, 0}; - FEXCore::Config::Value IsInterpreterInstalled{FEXCore::Config::CONFIG_INTERPRETER_INSTALLED, 0}; - FEXCore::Config::Value Filename{FEXCore::Config::CONFIG_APP_FILENAME, ""}; - FEXCore::Config::Value RootFSPath{FEXCore::Config::CONFIG_ROOTFSPATH, ""}; - FEXCore::Config::Value ThreadsConfig{FEXCore::Config::CONFIG_EMULATED_CPU_CORES, 1}; - FEXCore::Config::Value Is64BitMode{FEXCore::Config::CONFIG_IS64BIT_MODE, 0}; + FEX_CONFIG_OPT(IsInterpreter, IS_INTERPRETER); + FEX_CONFIG_OPT(IsInterpreterInstalled, INTERPRETER_INSTALLED); + FEX_CONFIG_OPT(Filename, APP_FILENAME); + FEX_CONFIG_OPT(RootFSPath, ROOTFSPATH); + FEX_CONFIG_OPT(ThreadsConfig, EMULATED_CPU_CORES); + FEX_CONFIG_OPT(Is64BitMode, IS64BIT_MODE); uint32_t GetHostKernelVersion() const { return HostKernelVersion; } diff --git a/Source/Tests/LinuxSyscalls/x64/Memory.cpp b/Source/Tests/LinuxSyscalls/x64/Memory.cpp index fcd64627a..dcac70e65 100644 --- a/Source/Tests/LinuxSyscalls/x64/Memory.cpp +++ b/Source/Tests/LinuxSyscalls/x64/Memory.cpp @@ -31,7 +31,7 @@ namespace FEX::HLE::x64 { }); REGISTER_SYSCALL_IMPL_X64(mmap, [](FEXCore::Core::InternalThreadState *Thread, void *addr, size_t length, int prot, int flags, int fd, off_t offset) -> uint64_t { - static FEXCore::Config::Value AOTIRLoad(FEXCore::Config::CONFIG_AOTIR_LOAD, false); + static FEX_CONFIG_OPT(AOTIRLoad, AOTIR_LOAD); uint64_t Result = reinterpret_cast(::mmap(addr, length, prot, flags, fd, offset)); if (Result != -1) { if (!(flags & MAP_ANONYMOUS)) { diff --git a/Source/Tests/TestHarness.cpp b/Source/Tests/TestHarness.cpp index 52c755083..da1ceee43 100644 --- a/Source/Tests/TestHarness.cpp +++ b/Source/Tests/TestHarness.cpp @@ -63,14 +63,6 @@ int main(int argc, char **argv) { auto CTX2 = FEXCore::Context::CreateNewContext(); - FEXCore::Config::SetConfig(CTX1, FEXCore::Config::CONFIG_DEFAULTCORE, FEXCore::Config::CONFIG_CUSTOM); - FEXCore::Config::SetConfig(CTX1, FEXCore::Config::CONFIG_SINGLESTEP, 1); - FEXCore::Config::SetConfig(CTX1, FEXCore::Config::CONFIG_MAXBLOCKINST, 1); - - FEXCore::Config::SetConfig(CTX2, FEXCore::Config::CONFIG_DEFAULTCORE, FEXCore::Config::CONFIG_INTERPRETER); - FEXCore::Config::SetConfig(CTX2, FEXCore::Config::CONFIG_SINGLESTEP, 1); - FEXCore::Config::SetConfig(CTX2, FEXCore::Config::CONFIG_MAXBLOCKINST, 1); - FEXCore::Context::InitializeContext(CTX1); FEXCore::Context::InitializeContext(CTX2); diff --git a/Source/Tests/TestHarnessRunner.cpp b/Source/Tests/TestHarnessRunner.cpp index f0936efe5..02e2b5210 100644 --- a/Source/Tests/TestHarnessRunner.cpp +++ b/Source/Tests/TestHarnessRunner.cpp @@ -58,47 +58,19 @@ int main(int argc, char **argv, char **const envp) { FEXCore::Config::AddLayer(std::make_unique(envp)); FEXCore::Config::Load(); - FEXCore::Config::Value CoreConfig{FEXCore::Config::CONFIG_DEFAULTCORE, 0}; - FEXCore::Config::Value BlockSizeConfig{FEXCore::Config::CONFIG_MAXBLOCKINST, 1}; - FEXCore::Config::Value SingleStepConfig{FEXCore::Config::CONFIG_SINGLESTEP, false}; - FEXCore::Config::Value MultiblockConfig{FEXCore::Config::CONFIG_MULTIBLOCK, false}; - FEXCore::Config::Value GdbServerConfig{FEXCore::Config::CONFIG_GDBSERVER, false}; - FEXCore::Config::Value ThreadsConfig{FEXCore::Config::CONFIG_EMULATED_CPU_CORES, 1}; - FEXCore::Config::Value LDPath{FEXCore::Config::CONFIG_ROOTFSPATH, ""}; - FEXCore::Config::Value ThunkLibsPath{FEXCore::Config::CONFIG_THUNKLIBSPATH, ""}; - FEXCore::Config::Value SilentLog{FEXCore::Config::CONFIG_SILENTLOGS, false}; - FEXCore::Config::Value Environment{FEXCore::Config::CONFIG_ENVIRONMENT, ""}; - FEXCore::Config::Value OutputLog{FEXCore::Config::CONFIG_OUTPUTLOG, "stderr"}; - FEXCore::Config::Value DumpIR{FEXCore::Config::CONFIG_DUMPIR, "no"}; - FEXCore::Config::Value TSOEnabledConfig{FEXCore::Config::CONFIG_TSO_ENABLED, true}; - FEXCore::Config::Value SMCChecksConfig{FEXCore::Config::CONFIG_SMC_CHECKS, FEXCore::Config::CONFIG_SMC_MMAN}; - FEXCore::Config::Value ABILocalFlags{FEXCore::Config::CONFIG_ABI_LOCAL_FLAGS, false}; - FEXCore::Config::Value AbiNoPF{FEXCore::Config::CONFIG_ABI_NO_PF, false}; - auto Args = FEX::ArgLoader::Get(); LogMan::Throw::A(Args.size() > 1, "Not enough arguments"); FEX::HarnessHelper::HarnessCodeLoader Loader{Args[0], Args[1].c_str()}; + FEXCore::Config::Set(FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode() ? "1" : "0"); FEXCore::Context::InitializeStaticTables(Loader.Is64BitMode() ? FEXCore::Context::MODE_64BIT : FEXCore::Context::MODE_32BIT); auto CTX = FEXCore::Context::CreateNewContext(); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_DEFAULTCORE, CoreConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_MULTIBLOCK, MultiblockConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_SINGLESTEP, SingleStepConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_MAXBLOCKINST, BlockSizeConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_TSO_ENABLED, TSOEnabledConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_SMC_CHECKS, SMCChecksConfig()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_ABI_LOCAL_FLAGS, ABILocalFlags()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_ABI_NO_PF, AbiNoPF()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_DUMPIR, DumpIR()); - FEXCore::Config::SetConfig(CTX, FEXCore::Config::CONFIG_VALIDATE_IR_PARSER, true); FEXCore::Context::SetCustomCPUBackendFactory(CTX, HostFactory::CPUCreationFactory); FEXCore::Context::InitializeContext(CTX); - FEXCore::Config::Set(FEXCore::Config::CONFIG_IS64BIT_MODE, Loader.Is64BitMode() ? "1" : "0"); std::unique_ptr SignalDelegation = std::make_unique(); std::unique_ptr SyscallHandler{ diff --git a/Source/Tools/Debugger/IMGui_I.cpp b/Source/Tools/Debugger/IMGui_I.cpp index 391a4a2e9..b800c8570 100644 --- a/Source/Tools/Debugger/IMGui_I.cpp +++ b/Source/Tools/Debugger/IMGui_I.cpp @@ -788,10 +788,10 @@ namespace History { namespace Config { bool ShowConfig = true; struct Configs { - FEXCore::Config::Value ConfigMaxInst{FEXCore::Config::CONFIG_MAXBLOCKINST, 255}; - FEXCore::Config::Value ConfigCore{FEXCore::Config::CONFIG_DEFAULTCORE, 0}; - FEXCore::Config::Value ConfigRunningMode{FEXCore::Config::CONFIG_SINGLESTEP, 0}; - FEXCore::Config::Value ConfigMultiblock{FEXCore::Config::CONFIG_MULTIBLOCK, false}; + FEX_CONFIG_OPT(ConfigMaxInst, MAXBLOCKINST); + FEX_CONFIG_OPT(ConfigCore, DEFAULTCORE); + FEX_CONFIG_OPT(ConfigRunningMode, SINGLESTEP); + FEX_CONFIG_OPT(ConfigMultiblock, MULTIBLOCK); }; std::unique_ptr Config;