aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/thread.c')
-rw-r--r--tools/perf/util/thread.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 873ab505ca80..590793cc5142 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -214,14 +214,24 @@ struct comm *thread__comm(const struct thread *thread)
214 214
215struct comm *thread__exec_comm(const struct thread *thread) 215struct comm *thread__exec_comm(const struct thread *thread)
216{ 216{
217 struct comm *comm, *last = NULL; 217 struct comm *comm, *last = NULL, *second_last = NULL;
218 218
219 list_for_each_entry(comm, &thread->comm_list, list) { 219 list_for_each_entry(comm, &thread->comm_list, list) {
220 if (comm->exec) 220 if (comm->exec)
221 return comm; 221 return comm;
222 second_last = last;
222 last = comm; 223 last = comm;
223 } 224 }
224 225
226 /*
227 * 'last' with no start time might be the parent's comm of a synthesized
228 * thread (created by processing a synthesized fork event). For a main
229 * thread, that is very probably wrong. Prefer a later comm to avoid
230 * that case.
231 */
232 if (second_last && !last->start && thread->pid_ == thread->tid)
233 return second_last;
234
225 return last; 235 return last;
226} 236}
227 237