From 935f537a8034c51ef92b0fb6a59275488ff2bee2 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sun, 18 Jan 2026 14:23:58 -0800 Subject: [PATCH 1/3] JitRegister: Fix IsEnabled when using VTune without perf Set `s_is_enabled` to `true` in `Init` when `USE_VTUNE` is defined so that `IsEnabled` returns true even if perf isn't being used. --- Source/Core/Common/JitRegister.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Common/JitRegister.cpp b/Source/Core/Common/JitRegister.cpp index 053c411a93..9728a7682c 100644 --- a/Source/Core/Common/JitRegister.cpp +++ b/Source/Core/Common/JitRegister.cpp @@ -34,6 +34,10 @@ static bool s_is_enabled = false; void Init(const std::string& perf_dir) { +#ifdef USE_VTUNE + s_is_enabled = true; +#endif + if (!perf_dir.empty() || getenv("PERF_BUILDID_DIR")) { const std::string dir = perf_dir.empty() ? "/tmp" : perf_dir; From 7490dea278badc648465ce4042b8cd576dacde3b Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sun, 18 Jan 2026 14:34:17 -0800 Subject: [PATCH 2/3] JitRegister: Verify IOFile IsGood Use IOFile's bool operator to check that it's not just open but good. --- Source/Core/Common/JitRegister.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/JitRegister.cpp b/Source/Core/Common/JitRegister.cpp index 9728a7682c..8555ca8073 100644 --- a/Source/Core/Common/JitRegister.cpp +++ b/Source/Core/Common/JitRegister.cpp @@ -79,7 +79,7 @@ void Register(const void* base_address, u32 code_size, const std::string& symbol #endif // Linux perf /tmp/perf-$pid.map: - if (!s_perf_map_file.IsOpen()) + if (!s_perf_map_file) return; const auto entry = fmt::format("{} {:x} {}\n", fmt::ptr(base_address), code_size, symbol_name); From f4b88af71e5bea2205d6a666d77f2a3611c21564 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sun, 18 Jan 2026 14:36:51 -0800 Subject: [PATCH 3/3] JitRegister: Check Open return code If the call to `Open` a perf map fails don't set `s_is_enabled` (though it could already be true if you're also using VTUNE) and don't call `std::setvbuf` with a null stream. Also fix a typo in a comment (`if` -> `in`) --- Source/Core/Common/JitRegister.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Core/Common/JitRegister.cpp b/Source/Core/Common/JitRegister.cpp index 8555ca8073..4d8ba45fc6 100644 --- a/Source/Core/Common/JitRegister.cpp +++ b/Source/Core/Common/JitRegister.cpp @@ -42,11 +42,13 @@ void Init(const std::string& perf_dir) { const std::string dir = perf_dir.empty() ? "/tmp" : perf_dir; const std::string filename = fmt::format("{}/perf-{}.map", dir, getpid()); - s_perf_map_file.Open(filename, "w"); - // Disable buffering in order to avoid missing some mappings - // if the event of a crash: - std::setvbuf(s_perf_map_file.GetHandle(), nullptr, _IONBF, 0); - s_is_enabled = true; + if (s_perf_map_file.Open(filename, "w")) + { + // Disable buffering in order to avoid missing some mappings + // in the event of a crash: + std::setvbuf(s_perf_map_file.GetHandle(), nullptr, _IONBF, 0); + s_is_enabled = true; + } } }