perf script: Fix Python support when no libtraceevent
[platform/kernel/linux-starfive.git] / tools / perf / scripts / python / Perf-Trace-Util / Context.c
index 895f5fc..b0d449f 100644 (file)
@@ -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)
 {
@@ -178,12 +180,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,