History

perf scripting python: Add function to get a config value

This can be used to get config values like which objdump Perf uses for disassembly.

James Clark committed 2 years ago

Commit 99435811 parent ba5ae784 files · +35 −1Browse files

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

Unified · Split

tools/perf/scripts/python/Perf-Trace-Util/Context.c+11−0
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #define PY_SSIZE_T_CLEAN
1313
1414 #include <Python.h>
15+#include "../../../util/config.h"
1516 #include "../../../util/trace-event.h"
1617 #include "../../../util/event.h"
1718 #include "../../../util/symbol.h"
@@ -182,6 +183,15 @@ static PyObject *perf_sample_srccode(PyObject *obj, PyObject *args) · 164 unmodified lines
182183 return perf_sample_src(obj, args, true);
183184 }
184185
186+static PyObject *__perf_config_get(PyObject *obj, PyObject *args)
187+{
188+ const char *config_name;
189+
190+ if (!PyArg_ParseTuple(args, "s", &config_name))
191+ return NULL;
192+ return Py_BuildValue("s", perf_config_get(config_name));
193+}
194+
185195 static PyMethodDef ContextMethods[] = {
186196 #ifdef HAVE_LIBTRACEEVENT
187197 { "common_pc", perf_trace_context_common_pc, METH_VARARGS,
@@ -199,6 +209,7 @@ static PyMethodDef ContextMethods[] = { · 11 unmodified lines
199209 METH_VARARGS, "Get source file name and line number."},
200210 { "perf_sample_srccode", perf_sample_srccode,
201211 METH_VARARGS, "Get source file name, line number and line."},
212+ { "perf_config_get", __perf_config_get, METH_VARARGS, "Get perf config entry"},
202213 { NULL, NULL, 0, NULL}
203214 };
204215