History

perf scripting python: Assign perf_script_context

The scripting_context pointer itself does not change and nor does it need to. Put it directly into the script as a variable at the start so it does not have to be passed on each call into the script.

Adrian Hunter committed 5 years ago

Commit cf9bfa61 parent 67e50ce2 files · +35 −1Browse files

Showing the changes to tools/perf/scripts/python (1 of 2 files). Show all

Unified · Split

tools/perf/scripts/python/Perf-Trace-Util/Context.c+7−1
@@ -91,6 +91,12 @@ PyMODINIT_FUNC PyInit_perf_trace_context(void) · 90 unmodified lines
9191 NULL, /* m_clear */
9292 NULL, /* m_free */
9393 };
94− return PyModule_Create(&moduledef);
94+ PyObject *mod;
95+
96+ mod = PyModule_Create(&moduledef);
97+ /* Add perf_script_context to the module so it can be imported */
98+ PyObject_SetAttrString(mod, "perf_script_context", Py_None);
99+
100+ return mod;
95101 }
96102 #endif