diff options
author | Pavel Kosov <kosov.pavel@huawei.com> | 2021-10-22 11:56:45 +0300 |
---|---|---|
committer | Pavel Kosov <kosov.pavel@huawei.com> | 2021-10-22 11:58:19 +0300 |
commit | a00494c15b6031adbe32bb73101e88b1294ac9d0 (patch) | |
tree | ddc11a2af1f0b41407b534bbfe51e5f40b3ba59c | |
parent | 8bd6625f60ba1f19dc4386b78bbc693f66e5097a (diff) |
[LNT] Fixed the standalone mode of cPerf for the debug purpose
It also initializes dict objects in the constructor to make the object PerfReader consistent.
Reviewed By: thopre
Differential Revision: https://reviews.llvm.org/D112203
OS Laboratory, Huawei Russian Research Institute, Saint-Petersburg
-rw-r--r-- | lnt/testing/profile/cPerf.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lnt/testing/profile/cPerf.cpp b/lnt/testing/profile/cPerf.cpp index c68cf5d..e812338 100644 --- a/lnt/testing/profile/cPerf.cpp +++ b/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 @@ PerfReader::PerfReader(const std::string &Filename, 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::emitLine(uint64_t PC, } 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 @@ PyMODINIT_FUNC initcPerf(void) { #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 |