| From | Alexander Shishkin <> | Subject | [PATCH v0 13/71] perf tools: Add machine__get_thread_pid() | Date | Wed, 11 Dec 2013 14:36:25 +0200 |
| |
From: Adrian Hunter <adrian.hunter@intel.com>
Add a function to get the pid from the tid.
This is needed when using the sched_switch tracepoint to follow object code execution. sched_switch identifies the thread but, to find the process mmaps, we need the process pid.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> --- tools/perf/util/machine.c | 10 ++++++++++ tools/perf/util/machine.h | 2 ++ 2 files changed, 12 insertions(+)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index bac817a..55f3608 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1402,3 +1402,13 @@ int __machine__synthesize_threads(struct machine *machine, struct perf_tool *too /* command specified */ return 0; } + +pid_t machine__get_thread_pid(struct machine *machine, pid_t tid) +{ + struct thread *thread = machine__find_thread(machine, tid); + + if (!thread) + return -1; + + return thread->pid_; +} diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 4771330..b800a5a 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -190,4 +190,6 @@ int machine__synthesize_threads(struct machine *machine, struct target *target, perf_event__process, data_mmap); } +pid_t machine__get_thread_pid(struct machine *machine, pid_t tid); + #endif /* __PERF_MACHINE_H */ -- 1.8.5.1
|