Merge pull request #14292 from Dentomologist/jitregister_fix_isenabled_when_using_vtune_without_perf
JitRegister: Fix IsEnabled when using VTune without perf
This commit is contained in:
1 file changed
+12
-6
@@ -34,15 +34,21 @@ static bool s_is_enabled = false;
|
|||||||
|
|
||||||
void Init(const std::string& perf_dir)
|
void Init(const std::string& perf_dir)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_VTUNE
|
||||||
|
s_is_enabled = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!perf_dir.empty() || getenv("PERF_BUILDID_DIR"))
|
if (!perf_dir.empty() || getenv("PERF_BUILDID_DIR"))
|
||||||
{
|
{
|
||||||
const std::string dir = perf_dir.empty() ? "/tmp" : perf_dir;
|
const std::string dir = perf_dir.empty() ? "/tmp" : perf_dir;
|
||||||
const std::string filename = fmt::format("{}/perf-{}.map", dir, getpid());
|
const std::string filename = fmt::format("{}/perf-{}.map", dir, getpid());
|
||||||
s_perf_map_file.Open(filename, "w");
|
if (s_perf_map_file.Open(filename, "w"))
|
||||||
// Disable buffering in order to avoid missing some mappings
|
{
|
||||||
// if the event of a crash:
|
// Disable buffering in order to avoid missing some mappings
|
||||||
std::setvbuf(s_perf_map_file.GetHandle(), nullptr, _IONBF, 0);
|
// in the event of a crash:
|
||||||
s_is_enabled = true;
|
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
|
#endif
|
||||||
|
|
||||||
// Linux perf /tmp/perf-$pid.map:
|
// Linux perf /tmp/perf-$pid.map:
|
||||||
if (!s_perf_map_file.IsOpen())
|
if (!s_perf_map_file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto entry = fmt::format("{} {:x} {}\n", fmt::ptr(base_address), code_size, symbol_name);
|
const auto entry = fmt::format("{} {:x} {}\n", fmt::ptr(base_address), code_size, symbol_name);
|
||||||
|
|||||||
Reference in new issue
Block a user