Linux: detect perf and default map dir to /tmp

This obviously only works when Dolphin is run by perf rather than being
started separately.
This commit is contained in:
Tillmann Karras 2015-10-10 16:42:53 +02:00
parent e955a3a191
commit 19a490a82d

View File

@ -5,6 +5,7 @@
#include <cinttypes> #include <cinttypes>
#include <cstddef> #include <cstddef>
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <fstream> #include <fstream>
#include <string> #include <string>
@ -43,9 +44,10 @@ void Init(const std::string& perf_dir)
s_agent = op_open_agent(); s_agent = op_open_agent();
#endif #endif
if (!perf_dir.empty()) if (!perf_dir.empty() || getenv("PERF_BUILDID_DIR"))
{ {
std::string filename = StringFromFormat("%s/perf-%d.map", perf_dir.data(), getpid()); std::string dir = perf_dir.empty() ? "/tmp" : perf_dir;
std::string filename = StringFromFormat("%s/perf-%d.map", dir.data(), getpid());
s_perf_map_file.Open(filename, "w"); s_perf_map_file.Open(filename, "w");
// Disable buffering in order to avoid missing some mappings // Disable buffering in order to avoid missing some mappings
// if the event of a crash: // if the event of a crash: