aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorDavid Ahern <daahern@cisco.com>2011-03-10 00:23:25 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-03-14 16:05:55 -0400
commitc70c94b47405d2c94df19c16273daf1f5fb9193d (patch)
tree44e1f7bb1752bfde03e65b1435a4172a6d67a0d2 /tools/perf
parent2ee7a49f935b19f7daf0a110800488acd2479cba (diff)
perf script: Move printing of 'common' data from print_event and rename
This change does impact output: latency data is trace specific and is now printed after the common data - comm, tid, cpu, time and event name. Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> LKML-Reference: <1299734608-5223-4-git-send-email-daahern@cisco.com> Signed-off-by: David Ahern <daahern@cisco.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-script.c38
-rw-r--r--tools/perf/util/trace-event-parse.c49
-rw-r--r--tools/perf/util/trace-event.h3
3 files changed, 42 insertions, 48 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,
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index dd5f058292d8..0a7ed5b5e281 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -2643,9 +2643,9 @@ static void print_lat_fmt(void *data, int size __unused)
2643 printf("."); 2643 printf(".");
2644 2644
2645 if (lock_depth < 0) 2645 if (lock_depth < 0)
2646 printf("."); 2646 printf(". ");
2647 else 2647 else
2648 printf("%d", lock_depth); 2648 printf("%d ", lock_depth);
2649} 2649}
2650 2650
2651#define TRACE_GRAPH_INDENT 2 2651#define TRACE_GRAPH_INDENT 2
@@ -2821,18 +2821,13 @@ static void print_graph_nested(struct event *event, void *data)
2821 2821
2822static void 2822static void
2823pretty_print_func_ent(void *data, int size, struct event *event, 2823pretty_print_func_ent(void *data, int size, struct event *event,
2824 int cpu, int pid, const char *comm __unused, 2824 int cpu, int pid)
2825 unsigned long secs, unsigned long usecs)
2826{ 2825{
2827 struct format_field *field; 2826 struct format_field *field;
2828 struct record *rec; 2827 struct record *rec;
2829 void *copy_data; 2828 void *copy_data;
2830 unsigned long val; 2829 unsigned long val;
2831 2830
2832 printf("%5lu.%06lu | ", secs, usecs);
2833
2834 printf(" | ");
2835
2836 if (latency_format) { 2831 if (latency_format) {
2837 print_lat_fmt(data, size); 2832 print_lat_fmt(data, size);
2838 printf(" | "); 2833 printf(" | ");
@@ -2865,19 +2860,13 @@ out_free:
2865} 2860}
2866 2861
2867static void 2862static void
2868pretty_print_func_ret(void *data, int size __unused, struct event *event, 2863pretty_print_func_ret(void *data, int size __unused, struct event *event)
2869 int cpu __unused, int pid __unused, const char *comm __unused,
2870 unsigned long secs, unsigned long usecs)
2871{ 2864{
2872 unsigned long long rettime, calltime; 2865 unsigned long long rettime, calltime;
2873 unsigned long long duration, depth; 2866 unsigned long long duration, depth;
2874 struct format_field *field; 2867 struct format_field *field;
2875 int i; 2868 int i;
2876 2869
2877 printf("%5lu.%06lu | ", secs, usecs);
2878
2879 printf(" | ");
2880
2881 if (latency_format) { 2870 if (latency_format) {
2882 print_lat_fmt(data, size); 2871 print_lat_fmt(data, size);
2883 printf(" | "); 2872 printf(" | ");
@@ -2915,31 +2904,21 @@ pretty_print_func_ret(void *data, int size __unused, struct event *event,
2915 2904
2916static void 2905static void
2917pretty_print_func_graph(void *data, int size, struct event *event, 2906pretty_print_func_graph(void *data, int size, struct event *event,
2918 int cpu, int pid, const char *comm, 2907 int cpu, int pid)
2919 unsigned long secs, unsigned long usecs)
2920{ 2908{
2921 if (event->flags & EVENT_FL_ISFUNCENT) 2909 if (event->flags & EVENT_FL_ISFUNCENT)
2922 pretty_print_func_ent(data, size, event, 2910 pretty_print_func_ent(data, size, event, cpu, pid);
2923 cpu, pid, comm, secs, usecs);
2924 else if (event->flags & EVENT_FL_ISFUNCRET) 2911 else if (event->flags & EVENT_FL_ISFUNCRET)
2925 pretty_print_func_ret(data, size, event, 2912 pretty_print_func_ret(data, size, event);
2926 cpu, pid, comm, secs, usecs);
2927 printf("\n"); 2913 printf("\n");
2928} 2914}
2929 2915
2930void print_event(int cpu, void *data, int size, unsigned long long nsecs, 2916void print_trace_event(int cpu, void *data, int size)
2931 char *comm)
2932{ 2917{
2933 struct event *event; 2918 struct event *event;
2934 unsigned long secs;
2935 unsigned long usecs;
2936 int type; 2919 int type;
2937 int pid; 2920 int pid;
2938 2921
2939 secs = nsecs / NSECS_PER_SEC;
2940 nsecs -= secs * NSECS_PER_SEC;
2941 usecs = nsecs / NSECS_PER_USEC;
2942
2943 type = trace_parse_common_type(data); 2922 type = trace_parse_common_type(data);
2944 2923
2945 event = trace_find_event(type); 2924 event = trace_find_event(type);
@@ -2951,17 +2930,10 @@ void print_event(int cpu, void *data, int size, unsigned long long nsecs,
2951 pid = trace_parse_common_pid(data); 2930 pid = trace_parse_common_pid(data);
2952 2931
2953 if (event->flags & (EVENT_FL_ISFUNCENT | EVENT_FL_ISFUNCRET)) 2932 if (event->flags & (EVENT_FL_ISFUNCENT | EVENT_FL_ISFUNCRET))
2954 return pretty_print_func_graph(data, size, event, cpu, 2933 return pretty_print_func_graph(data, size, event, cpu, pid);
2955 pid, comm, secs, usecs);
2956 2934
2957 if (latency_format) { 2935 if (latency_format)
2958 printf("%8.8s-%-5d %3d",
2959 comm, pid, cpu);
2960 print_lat_fmt(data, size); 2936 print_lat_fmt(data, size);
2961 } else
2962 printf("%16s-%-5d [%03d]", comm, pid, cpu);
2963
2964 printf(" %5lu.%06lu: %s: ", secs, usecs, event->name);
2965 2937
2966 if (event->flags & EVENT_FL_FAILED) { 2938 if (event->flags & EVENT_FL_FAILED) {
2967 printf("EVENT '%s' FAILED TO PARSE\n", 2939 printf("EVENT '%s' FAILED TO PARSE\n",
@@ -2970,7 +2942,6 @@ void print_event(int cpu, void *data, int size, unsigned long long nsecs,
2970 } 2942 }
2971 2943
2972 pretty_print(data, size, event); 2944 pretty_print(data, size, event);
2973 printf("\n");
2974} 2945}
2975 2946
2976static void print_fields(struct print_flag_sym *field) 2947static void print_fields(struct print_flag_sym *field)
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 5f7b5139c321..b04da5722437 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -177,8 +177,7 @@ void print_printk(void);
177 177
178int parse_ftrace_file(char *buf, unsigned long size); 178int parse_ftrace_file(char *buf, unsigned long size);
179int parse_event_file(char *buf, unsigned long size, char *sys); 179int parse_event_file(char *buf, unsigned long size, char *sys);
180void print_event(int cpu, void *data, int size, unsigned long long nsecs, 180void print_trace_event(int cpu, void *data, int size);
181 char *comm);
182 181
183extern int file_bigendian; 182extern int file_bigendian;
184extern int host_bigendian; 183extern int host_bigendian;