diff --git a/lnt/testing/profile/cPerf.cpp b/lnt/testing/profile/cPerf.cpp --- a/lnt/testing/profile/cPerf.cpp +++ b/lnt/testing/profile/cPerf.cpp @@ -259,16 +259,18 @@ class NmOutput : public std::vector { public: - std::string Nm; + std::string Nm, BinaryCacheRoot; - NmOutput(std::string Nm) : Nm(Nm) {} + NmOutput(std::string Nm, std::string BinaryCacheRoot) + : Nm(Nm), BinaryCacheRoot(BinaryCacheRoot) {} void fetchSymbols(Map *M, bool Dynamic) { std::string D = "-D"; if (!Dynamic) // Don't fetch the dynamic symbols - instead fetch static ones. D = ""; - std::string Cmd = Nm + " " + D + " -S --defined-only " + std::string(M->Filename) + + std::string Cmd = Nm + " " + D + " -S --defined-only " + + BinaryCacheRoot + std::string(M->Filename) + " 2>/dev/null"; auto Stream = ForkAndExec(Cmd); @@ -343,7 +345,7 @@ class ObjdumpOutput { public: - std::string Objdump; + std::string Objdump, BinaryCacheRoot; FILE *Stream; char *ThisText; uint64_t ThisAddress; @@ -351,8 +353,9 @@ char *Line; size_t LineLen; - ObjdumpOutput(std::string Objdump) - : Objdump(Objdump), Stream(nullptr), Line(NULL), LineLen(0) {} + ObjdumpOutput(std::string Objdump, std::string BinaryCacheRoot) + : Objdump(Objdump), BinaryCacheRoot(BinaryCacheRoot), Stream(nullptr), + Line(NULL), LineLen(0) {} ~ObjdumpOutput() { if (Stream) { fclose(Stream); @@ -375,7 +378,8 @@ std::string Cmd = Objdump + " -d --no-show-raw-insn --start-address=" + std::string(buf1) + " --stop-address=" + - std::string(buf2) + " " + std::string(M->Filename) + + std::string(buf2) + " " + + BinaryCacheRoot + std::string(M->Filename) + " 2>/dev/null"; Stream = ForkAndExec(Cmd); @@ -420,7 +424,7 @@ class PerfReader { public: PerfReader(const std::string &Filename, std::string Nm, - std::string Objdump); + std::string Objdump, std::string BinaryCacheRoot); ~PerfReader(); void readHeader(); @@ -458,12 +462,13 @@ PyObject *Functions, *TopLevelCounters; std::vector Lines; - std::string Nm, Objdump; + std::string Nm, Objdump, BinaryCacheRoot; }; PerfReader::PerfReader(const std::string &Filename, - std::string Nm, std::string Objdump) - : Nm(Nm), Objdump(Objdump) { + std::string Nm, std::string Objdump, + std::string BinaryCacheRoot) + : Nm(Nm), Objdump(Objdump), BinaryCacheRoot(BinaryCacheRoot) { int fd = open(Filename.c_str(), O_RDONLY); assert(fd > 0); @@ -707,7 +712,7 @@ bool IsSO = IsSharedObject(Maps[MapID].Filename); uint64_t Adjust = IsSO ? Maps[MapID].Start : 0; - NmOutput Syms(Nm); + NmOutput Syms(Nm, BinaryCacheRoot); Syms.reset(&Maps[MapID]); // Accumulate the event totals for each symbol @@ -753,7 +758,7 @@ std::map>::iterator Event, std::map &SymEvents, uint64_t Adjust) { - ObjdumpOutput Dump(Objdump); + ObjdumpOutput Dump(Objdump, BinaryCacheRoot); Dump.reset(&M, Sym.Start, Sym.End); Dump.next(); @@ -784,11 +789,12 @@ const char *Fname; const char *Nm = "nm"; const char *Objdump = "objdump"; - if (!PyArg_ParseTuple(args, "s|ss", &Fname, &Nm, &Objdump)) + const char *BinaryCacheRoot = ""; + if (!PyArg_ParseTuple(args, "s|sss", &Fname, &Nm, &Objdump, &BinaryCacheRoot)) return NULL; try { - PerfReader P(Fname, Nm, Objdump); + PerfReader P(Fname, Nm, Objdump, BinaryCacheRoot); P.readHeader(); P.readAttrs(); P.readDataStream(); diff --git a/lnt/testing/profile/perf.py b/lnt/testing/profile/perf.py --- a/lnt/testing/profile/perf.py +++ b/lnt/testing/profile/perf.py @@ -22,7 +22,8 @@ return f.read(8) == b'PERFILE2' @staticmethod - def deserialize(f, nm='nm', objdump='objdump', propagateExceptions=False): + def deserialize(f, nm='nm', objdump='objdump', propagateExceptions=False, + binaryCacheRoot=''): f = f.name if os.path.getsize(f) == 0: diff --git a/lnt/testing/profile/profile.py b/lnt/testing/profile/profile.py --- a/lnt/testing/profile/profile.py +++ b/lnt/testing/profile/profile.py @@ -27,7 +27,15 @@ """ for impl in lnt.testing.profile.IMPLEMENTATIONS.values(): if impl.checkFile(f): - ret = impl.deserialize(open(f, 'rb')) + ret = None + with open(f, 'rb') as fd: + if impl is lnt.testing.profile.perf.LinuxPerfProfile: + ret = impl.deserialize(fd, + nm = os.getenv('CMAKE_NM', 'nm'), + objdump = os.getenv('CMAKE_OBJDUMP', 'objdump'), + binaryCacheRoot = os.getenv('LNT_BINARY_CACHE_ROOT', '')) + else: + ret = impl.deserialize(fd) if ret: return Profile(ret) else: