diff --git a/Source/Core/Common/JitRegister.cpp b/Source/Core/Common/JitRegister.cpp index 053c411a93..4d8ba45fc6 100644 --- a/Source/Core/Common/JitRegister.cpp +++ b/Source/Core/Common/JitRegister.cpp @@ -34,15 +34,21 @@ 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; 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; + } } } @@ -75,7 +81,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);