diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-28 13:20:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-28 13:20:25 -0500 |
commit | 6556a6743549defc32e5f90ee2cb1ecd833a44c3 (patch) | |
tree | 622306583d4a3c13235a8bfc012854c125c597f1 /tools/perf/scripts/python/Perf-Trace-Util/Context.c | |
parent | e0d272429a34ff143bfa04ee8e29dd4eed2964c7 (diff) | |
parent | 1dd2980d990068e20045b90c424518cc7f3657ff (diff) |
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (172 commits)
perf_event, amd: Fix spinlock initialization
perf_event: Fix preempt warning in perf_clock()
perf tools: Flush maps on COMM events
perf_events, x86: Split PMU definitions into separate files
perf annotate: Handle samples not at objdump output addr boundaries
perf_events, x86: Remove superflous MSR writes
perf_events: Simplify code by removing cpu argument to hw_perf_group_sched_in()
perf_events, x86: AMD event scheduling
perf_events: Add new start/stop PMU callbacks
perf_events: Report the MMAP pgoff value in bytes
perf annotate: Defer allocating sym_priv->hist array
perf symbols: Improve debugging information about symtab origins
perf top: Use a macro instead of a constant variable
perf symbols: Check the right return variable
perf/scripts: Tag syscall_name helper as not yet available
perf/scripts: Add perf-trace-python Documentation
perf/scripts: Remove unnecessary PyTuple resizes
perf/scripts: Add syscall tracing scripts
perf/scripts: Add Python scripting engine
perf/scripts: Remove check-perf-trace from listed scripts
...
Fix trivial conflict in tools/perf/util/probe-event.c
Diffstat (limited to 'tools/perf/scripts/python/Perf-Trace-Util/Context.c')
-rw-r--r-- | tools/perf/scripts/python/Perf-Trace-Util/Context.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Context.c b/tools/perf/scripts/python/Perf-Trace-Util/Context.c new file mode 100644 index 000000000000..957085dd5d8d --- /dev/null +++ b/tools/perf/scripts/python/Perf-Trace-Util/Context.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * Context.c. Python interfaces for perf trace. | ||
3 | * | ||
4 | * Copyright (C) 2010 Tom Zanussi <tzanussi@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <Python.h> | ||
23 | #include "../../../perf.h" | ||
24 | #include "../../../util/trace-event.h" | ||
25 | |||
26 | PyMODINIT_FUNC initperf_trace_context(void); | ||
27 | |||
28 | static PyObject *perf_trace_context_common_pc(PyObject *self, PyObject *args) | ||
29 | { | ||
30 | static struct scripting_context *scripting_context; | ||
31 | PyObject *context; | ||
32 | int retval; | ||
33 | |||
34 | if (!PyArg_ParseTuple(args, "O", &context)) | ||
35 | return NULL; | ||
36 | |||
37 | scripting_context = PyCObject_AsVoidPtr(context); | ||
38 | retval = common_pc(scripting_context); | ||
39 | |||
40 | return Py_BuildValue("i", retval); | ||
41 | } | ||
42 | |||
43 | static PyObject *perf_trace_context_common_flags(PyObject *self, | ||
44 | PyObject *args) | ||
45 | { | ||
46 | static struct scripting_context *scripting_context; | ||
47 | PyObject *context; | ||
48 | int retval; | ||
49 | |||
50 | if (!PyArg_ParseTuple(args, "O", &context)) | ||
51 | return NULL; | ||
52 | |||
53 | scripting_context = PyCObject_AsVoidPtr(context); | ||
54 | retval = common_flags(scripting_context); | ||
55 | |||
56 | return Py_BuildValue("i", retval); | ||
57 | } | ||
58 | |||
59 | static PyObject *perf_trace_context_common_lock_depth(PyObject *self, | ||
60 | PyObject *args) | ||
61 | { | ||
62 | static struct scripting_context *scripting_context; | ||
63 | PyObject *context; | ||
64 | int retval; | ||
65 | |||
66 | if (!PyArg_ParseTuple(args, "O", &context)) | ||
67 | return NULL; | ||
68 | |||
69 | scripting_context = PyCObject_AsVoidPtr(context); | ||
70 | retval = common_lock_depth(scripting_context); | ||
71 | |||
72 | return Py_BuildValue("i", retval); | ||
73 | } | ||
74 | |||
75 | static PyMethodDef ContextMethods[] = { | ||
76 | { "common_pc", perf_trace_context_common_pc, METH_VARARGS, | ||
77 | "Get the common preempt count event field value."}, | ||
78 | { "common_flags", perf_trace_context_common_flags, METH_VARARGS, | ||
79 | "Get the common flags event field value."}, | ||
80 | { "common_lock_depth", perf_trace_context_common_lock_depth, | ||
81 | METH_VARARGS, "Get the common lock depth event field value."}, | ||
82 | { NULL, NULL, 0, NULL} | ||
83 | }; | ||
84 | |||
85 | PyMODINIT_FUNC initperf_trace_context(void) | ||
86 | { | ||
87 | (void) Py_InitModule("perf_trace_context", ContextMethods); | ||
88 | } | ||