lkml.org 
[lkml]   [2013]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v0 13/71] perf tools: Add machine__get_thread_pid()
Date
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


\
 
 \ /
  Last update: 2013-12-13 02:21    [W:1.206 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site