aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/Perf-Trace-Util/Context.c
diff options
context:
space:
mode:
authorMaxime Ripard <[email protected]>2023-05-12 09:47:12 +0200
committerMaxime Ripard <[email protected]>2023-05-12 09:47:12 +0200
commit50282fd57bcd3525c9d81eef58df8718e4337c6d (patch)
tree9795dfdb1a9b66904d9320f33c9216683d10576a /tools/perf/scripts/python/Perf-Trace-Util/Context.c
parentad81e23426a651eb89a4b306e1c4169e6308c124 (diff)
parentac9a78681b921877518763ba0e89202254349d1b (diff)
Merge drm/drm-fixes into drm-misc-fixes
Let's bring 6.4-rc1 in drm-misc-fixes to start the new fix cycle. Signed-off-by: Maxime Ripard <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/Perf-Trace-Util/Context.c')
-rw-r--r--tools/perf/scripts/python/Perf-Trace-Util/Context.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Context.c b/tools/perf/scripts/python/Perf-Trace-Util/Context.c
index 895f5fc23965..53b1587db403 100644
--- a/tools/perf/scripts/python/Perf-Trace-Util/Context.c
+++ b/tools/perf/scripts/python/Perf-Trace-Util/Context.c
@@ -59,6 +59,7 @@ static struct scripting_context *get_scripting_context(PyObject *args)
return get_args(args, "context", NULL);
}
+#ifdef HAVE_LIBTRACEEVENT
static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
{
struct scripting_context *c = get_scripting_context(args);
@@ -90,6 +91,7 @@ static PyObject *perf_trace_context_common_lock_depth(PyObject *obj,
return Py_BuildValue("i", common_lock_depth(c));
}
+#endif
static PyObject *perf_sample_insn(PyObject *obj, PyObject *args)
{
@@ -98,10 +100,11 @@ static PyObject *perf_sample_insn(PyObject *obj, PyObject *args)
if (!c)
return NULL;
- if (c->sample->ip && !c->sample->insn_len &&
- c->al->thread->maps && c->al->thread->maps->machine)
- script_fetch_insn(c->sample, c->al->thread, c->al->thread->maps->machine);
+ if (c->sample->ip && !c->sample->insn_len && c->al->thread->maps) {
+ struct machine *machine = maps__machine(c->al->thread->maps);
+ script_fetch_insn(c->sample, c->al->thread, machine);
+ }
if (!c->sample->insn_len)
Py_RETURN_NONE; /* N.B. This is a return statement */
@@ -142,6 +145,7 @@ static PyObject *perf_sample_src(PyObject *obj, PyObject *args, bool get_srccode
char *srccode = NULL;
PyObject *result;
struct map *map;
+ struct dso *dso;
int len = 0;
u64 addr;
@@ -150,9 +154,10 @@ static PyObject *perf_sample_src(PyObject *obj, PyObject *args, bool get_srccode
map = c->al->map;
addr = c->al->addr;
+ dso = map ? map__dso(map) : NULL;
- if (map && map->dso)
- srcfile = get_srcline_split(map->dso, map__rip_2objdump(map, addr), &line);
+ if (dso)
+ srcfile = get_srcline_split(dso, map__rip_2objdump(map, addr), &line);
if (get_srccode) {
if (srcfile)
@@ -178,12 +183,14 @@ static PyObject *perf_sample_srccode(PyObject *obj, PyObject *args)
}
static PyMethodDef ContextMethods[] = {
+#ifdef HAVE_LIBTRACEEVENT
{ "common_pc", perf_trace_context_common_pc, METH_VARARGS,
"Get the common preempt count event field value."},
{ "common_flags", perf_trace_context_common_flags, METH_VARARGS,
"Get the common flags event field value."},
{ "common_lock_depth", perf_trace_context_common_lock_depth,
METH_VARARGS, "Get the common lock depth event field value."},
+#endif
{ "perf_sample_insn", perf_sample_insn,
METH_VARARGS, "Get the machine code instruction."},
{ "perf_set_itrace_options", perf_set_itrace_options,