[PATCH] D117007: [LNT] NFC. Improvements to cPerf
Pavel Kosov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 11 08:48:46 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rLNTd08e89064afd: [LNT] NFC. Improvements to cPerf (authored by kpdev42).
Repository:
rLNT LNT
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117007/new/
https://reviews.llvm.org/D117007
Files:
lnt/testing/profile/cPerf.cpp
Index: lnt/testing/profile/cPerf.cpp
===================================================================
--- lnt/testing/profile/cPerf.cpp
+++ lnt/testing/profile/cPerf.cpp
@@ -500,7 +500,7 @@
public:
std::string Objdump, BinaryCacheRoot;
FILE *Stream;
- char *ThisText;
+ const char *ThisText;
uint64_t ThisAddress;
uint64_t EndAddress;
char *Line;
@@ -535,8 +535,8 @@
}
char buf1[32], buf2[32];
- sprintf(buf1, "%#llx", Start);
- sprintf(buf2, "%#llx", Stop + 4);
+ sprintf(buf1, "%#" PRIx64, Start);
+ sprintf(buf2, "%#" PRIx64, Stop + 4);
std::string Cmd = Objdump + " -d --no-show-raw-insn --start-address=" +
std::string(buf1) + " --stop-address=" +
@@ -1083,16 +1083,33 @@
#else // STANDALONE
+// You can build the standalone version for a debug purpose using
+// clang++ cPerf.cpp -o /tmp/cPerf -DSTANDALONE $(pkg-config --cflags --libs python3-embed)
+
+// getenv() is permitted to overwrite its return value on subsequent calls,
+// so copy it to std::string early.
+static std::string getEnvVar(const char *VarName, const char *DefaultValue) {
+ const char *Value = getenv(VarName);
+ if (!Value)
+ Value = DefaultValue;
+ return Value;
+}
+
int main(int argc, char **argv) {
Py_Initialize();
if (argc < 2) return -1;
- PerfReader P(argv[1], "objdump", "");
+
+ std::string BinaryCacheRoot = getEnvVar("LNT_BINARY_CACHE_ROOT", "");
+ std::string Objdump = getEnvVar("CMAKE_OBJDUMP", "objdump");
+
+ PerfReader P(argv[1], Objdump, BinaryCacheRoot);
P.readHeader();
P.readAttrs();
P.readDataStream();
P.emitTopLevelCounters();
P.emitMaps();
PyObject_Print(P.complete(), stdout, Py_PRINT_RAW);
+ fputs("\n", stdout); // Usually expected by UNIX shells
Py_FinalizeEx();
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117007.398969.patch
Type: text/x-patch
Size: 1810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220111/8f986470/attachment.bin>
More information about the llvm-commits
mailing list