From: Adrian Hunter <adrian.hun...@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.hun...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to