This can be used to get config values like which objdump Perf uses for disassembly.
Showing the changes to tools/perf/scripts/python (1 of 4 files). Show all
Unified · Split
| @@ -12,6 +12,7 @@ · 11 unmodified lines | |||
| 12 | #define PY_SSIZE_T_CLEAN | 12 | #define PY_SSIZE_T_CLEAN |
| 13 | 13 | ||
| 14 | #include <Python.h> | 14 | #include <Python.h> |
| 15 | #include "../../../util/config.h" | ||
| 15 | #include "../../../util/trace-event.h" | 16 | #include "../../../util/trace-event.h" |
| 16 | #include "../../../util/event.h" | 17 | #include "../../../util/event.h" |
| 17 | #include "../../../util/symbol.h" | 18 | #include "../../../util/symbol.h" |
| @@ -182,6 +183,15 @@ static PyObject *perf_sample_srccode(PyObject *obj, PyObject *args) · 164 unmodified lines | |||
| 182 | return perf_sample_src(obj, args, true); | 183 | return perf_sample_src(obj, args, true); |
| 183 | } | 184 | } |
| 184 | 185 | ||
| 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 | |||
| 185 | static PyMethodDef ContextMethods[] = { | 195 | static PyMethodDef ContextMethods[] = { |
| 186 | #ifdef HAVE_LIBTRACEEVENT | 196 | #ifdef HAVE_LIBTRACEEVENT |
| 187 | { "common_pc", perf_trace_context_common_pc, METH_VARARGS, | 197 | { "common_pc", perf_trace_context_common_pc, METH_VARARGS, |
| @@ -199,6 +209,7 @@ static PyMethodDef ContextMethods[] = { · 11 unmodified lines | |||
| 199 | METH_VARARGS, "Get source file name and line number."}, | 209 | METH_VARARGS, "Get source file name and line number."}, |
| 200 | { "perf_sample_srccode", perf_sample_srccode, | 210 | { "perf_sample_srccode", perf_sample_srccode, |
| 201 | METH_VARARGS, "Get source file name, line number and line."}, | 211 | METH_VARARGS, "Get source file name, line number and line."}, |
| 212 | { "perf_config_get", __perf_config_get, METH_VARARGS, "Get perf config entry"}, | ||
| 202 | { NULL, NULL, 0, NULL} | 213 | { NULL, NULL, 0, NULL} |
| 203 | }; | 214 | }; |
| 204 | 215 | ||