aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index b2bdd5534026..0a79da21df23 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -20,18 +20,42 @@ static u64 last_timestamp;
20static u64 nr_unordered; 20static u64 nr_unordered;
21extern const struct option record_options[]; 21extern const struct option record_options[];
22 22
23static void print_sample_start(struct perf_sample *sample,
24 struct thread *thread)
25{
26 int type;
27 struct event *event;
28 const char *evname = NULL;
29 unsigned long secs;
30 unsigned long usecs;
31 unsigned long long nsecs = sample->time;
32
33 if (latency_format)
34 printf("%8.8s-%-5d %3d", thread->comm, sample->tid, sample->cpu);
35 else
36 printf("%16s-%-5d [%03d]", thread->comm, sample->tid, sample->cpu);
37
38 secs = nsecs / NSECS_PER_SEC;
39 nsecs -= secs * NSECS_PER_SEC;
40 usecs = nsecs / NSECS_PER_USEC;
41 printf(" %5lu.%06lu: ", secs, usecs);
42
43 type = trace_parse_common_type(sample->raw_data);
44 event = trace_find_event(type);
45 if (event)
46 evname = event->name;
47
48 printf("%s: ", evname ? evname : "(unknown)");
49}
50
23static void process_event(union perf_event *event __unused, 51static void process_event(union perf_event *event __unused,
24 struct perf_sample *sample, 52 struct perf_sample *sample,
25 struct perf_session *session __unused, 53 struct perf_session *session __unused,
26 struct thread *thread) 54 struct thread *thread)
27{ 55{
28 /* 56 print_sample_start(sample, thread);
29 * FIXME: better resolve from pid from the struct trace_entry 57 print_trace_event(sample->cpu, sample->raw_data, sample->raw_size);
30 * field, although it should be the same than this perf 58 printf("\n");
31 * event pid
32 */
33 print_event(sample->cpu, sample->raw_data, sample->raw_size,
34 sample->time, thread->comm);
35} 59}
36 60
37static int default_start_script(const char *script __unused, 61static int default_start_script(const char *script __unused,