[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
Thu Oct 21 00:50:18 PDT 2021


kpdev42 created this revision.
kpdev42 added reviewers: cmatthews, thopre, danilaml.
kpdev42 added a project: LLVM.
Herald added a subscriber: dkolesnichenko.
kpdev42 requested review of this revision.

It also initializes dict objects in the constructor to make the object PerfReader consistent.


Repository:
  rLNT LNT

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.381163.patch
Type: text/x-patch
Size: 1506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211021/3c4f1ace/attachment.bin>


More information about the llvm-commits mailing list