[PATCH] D112203: [LNT] Fixed the standalone mode of cPerf for the debug purpose

Pavel Kosov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 22 02:02:08 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rLNTa00494c15b60: [LNT] Fixed the standalone mode of cPerf for the debug purpose (authored by kpdev42).

Repository:
  rLNT LNT

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112203/new/

https://reviews.llvm.org/D112203

Files:
  lnt/testing/profile/cPerf.cpp


Index: lnt/testing/profile/cPerf.cpp
===================================================================
--- lnt/testing/profile/cPerf.cpp
+++ lnt/testing/profile/cPerf.cpp
@@ -57,9 +57,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef STANDALONE
 #include <Python.h>
-#endif
 #include <algorithm>
 #include <cassert>
 #include <cstring>
@@ -469,6 +467,8 @@
                        std::string Nm, std::string Objdump,
                        std::string BinaryCacheRoot)
     : Nm(Nm), Objdump(Objdump), BinaryCacheRoot(BinaryCacheRoot) {
+  TopLevelCounters = PyDict_New();
+  Functions = PyDict_New();
   int fd = open(Filename.c_str(), O_RDONLY);
   assert(fd > 0);
 
@@ -672,12 +672,9 @@
 }
 
 void PerfReader::emitTopLevelCounters() {
-  TopLevelCounters = PyDict_New();
   for (auto &KV : TotalEvents)
     PyDict_SetItemString(TopLevelCounters, KV.first,
                          PyLong_FromUnsignedLongLong((unsigned long long)KV.second));
-
-  Functions = PyDict_New();
 }
 
 void PerfReader::emitMaps() {
@@ -843,13 +840,17 @@
 #else // STANDALONE
 
 int main(int argc, char **argv) {
-  PerfReader P(argv[1], std::cout);
+  Py_Initialize();
+  if (argc < 2)  return -1;
+  PerfReader P(argv[1], "nm", "objdump", "");
   P.readHeader();
   P.readAttrs();
   P.readDataStream();
   P.emitTopLevelCounters();
   P.emitMaps();
-  P.complete();
+  PyObject_Print(P.complete(), stdout, Py_PRINT_RAW);
+  Py_FinalizeEx();
+  return 0;
 }
 
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112203.381487.patch
Type: text/x-patch
Size: 1506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211022/35131c04/attachment.bin>


More information about the llvm-commits mailing list