aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parse-events.c121
-rw-r--r--parse-events.h11
-rw-r--r--trace-cmd.c5
-rw-r--r--trace-read.c5
4 files changed, 122 insertions, 20 deletions
diff --git a/parse-events.c b/parse-events.c
index 3581214..50ed6d9 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -36,6 +36,8 @@ int header_page_size_size;
36int header_page_data_offset; 36int header_page_data_offset;
37int header_page_data_size; 37int header_page_data_size;
38 38
39int latency_format;
40
39static char *input_buf; 41static char *input_buf;
40static unsigned long long input_buf_ptr; 42static unsigned long long input_buf_ptr;
41static unsigned long long input_buf_siz; 43static unsigned long long input_buf_siz;
@@ -1866,37 +1868,67 @@ static int get_common_info(const char *type, int *offset, int *size)
1866 return 0; 1868 return 0;
1867} 1869}
1868 1870
1869static int parse_common_type(void *data) 1871static int __parse_common(void *data, int *size, int *offset,
1872 char *name)
1870{ 1873{
1871 static int type_offset;
1872 static int type_size;
1873 int ret; 1874 int ret;
1874 1875
1875 if (!type_size) { 1876 if (!*size) {
1876 ret = get_common_info("common_type", 1877 ret = get_common_info(name, offset, size);
1877 &type_offset,
1878 &type_size);
1879 if (ret < 0) 1878 if (ret < 0)
1880 return ret; 1879 return ret;
1881 } 1880 }
1882 return read_size(data + type_offset, type_size); 1881 return read_size(data + *offset, *size);
1882}
1883
1884static int parse_common_type(void *data)
1885{
1886 static int type_offset;
1887 static int type_size;
1888
1889 return __parse_common(data, &type_size, &type_offset,
1890 "common_type");
1883} 1891}
1884 1892
1885static int parse_common_pid(void *data) 1893static int parse_common_pid(void *data)
1886{ 1894{
1887 static int pid_offset; 1895 static int pid_offset;
1888 static int pid_size; 1896 static int pid_size;
1897
1898 return __parse_common(data, &pid_size, &pid_offset,
1899 "common_pid");
1900}
1901
1902static int parse_common_pc(void *data)
1903{
1904 static int pc_offset;
1905 static int pc_size;
1906
1907 return __parse_common(data, &pc_size, &pc_offset,
1908 "common_preempt_count");
1909}
1910
1911static int parse_common_flags(void *data)
1912{
1913 static int flags_offset;
1914 static int flags_size;
1915
1916 return __parse_common(data, &flags_size, &flags_offset,
1917 "common_flags");
1918}
1919
1920static int parse_common_lock_depth(void *data)
1921{
1922 static int ld_offset;
1923 static int ld_size;
1889 int ret; 1924 int ret;
1890 1925
1891 if (!pid_size) { 1926 ret = __parse_common(data, &ld_size, &ld_offset,
1892 ret = get_common_info("common_pid", 1927 "common_lock_depth");
1893 &pid_offset, 1928 if (ret < 0)
1894 &pid_size); 1929 return -1;
1895 if (ret < 0)
1896 return ret;
1897 }
1898 1930
1899 return read_size(data + pid_offset, pid_size); 1931 return ret;
1900} 1932}
1901 1933
1902static struct event *find_event(int id) 1934static struct event *find_event(int id)
@@ -2438,6 +2470,41 @@ static inline int log10_cpu(int nb)
2438 return 1; 2470 return 1;
2439} 2471}
2440 2472
2473static void print_lat_fmt(void *data, int size)
2474{
2475 unsigned int flags;
2476 unsigned int pc;
2477 int lock_depth;
2478 int hardirq;
2479 int softirq;
2480
2481 flags = parse_common_flags(data);
2482 pc = parse_common_pc(data);
2483 lock_depth = parse_common_lock_depth(data);
2484
2485 hardirq = flags & TRACE_FLAG_HARDIRQ;
2486 softirq = flags & TRACE_FLAG_SOFTIRQ;
2487
2488 printf("%c%c%c",
2489 (flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
2490 (flags & TRACE_FLAG_IRQS_NOSUPPORT) ?
2491 'X' : '.',
2492 (flags & TRACE_FLAG_NEED_RESCHED) ?
2493 'N' : '.',
2494 (hardirq && softirq) ? 'H' :
2495 hardirq ? 'h' : softirq ? 's' : '.');
2496
2497 if (pc)
2498 printf("%x", pc);
2499 else
2500 printf(".");
2501
2502 if (lock_depth < 0)
2503 printf(".");
2504 else
2505 printf("%d", lock_depth);
2506}
2507
2441/* taken from Linux, written by Frederic Weisbecker */ 2508/* taken from Linux, written by Frederic Weisbecker */
2442static void print_graph_cpu(int cpu) 2509static void print_graph_cpu(int cpu)
2443{ 2510{
@@ -2681,6 +2748,11 @@ pretty_print_func_ent(void *data, int size, struct event *event,
2681 2748
2682 printf(" | "); 2749 printf(" | ");
2683 2750
2751 if (latency_format) {
2752 print_lat_fmt(data, size);
2753 printf(" | ");
2754 }
2755
2684 field = find_field(event, "func"); 2756 field = find_field(event, "func");
2685 if (!field) 2757 if (!field)
2686 die("function entry does not have func field"); 2758 die("function entry does not have func field");
@@ -2724,6 +2796,11 @@ pretty_print_func_ret(void *data, int size, struct event *event,
2724 2796
2725 printf(" | "); 2797 printf(" | ");
2726 2798
2799 if (latency_format) {
2800 print_lat_fmt(data, size);
2801 printf(" | ");
2802 }
2803
2727 field = find_field(event, "rettime"); 2804 field = find_field(event, "rettime");
2728 if (!field) 2805 if (!field)
2729 die("can't find rettime in return graph"); 2806 die("can't find rettime in return graph");
@@ -2794,9 +2871,15 @@ void print_event(int cpu, void *data, int size, unsigned long long nsecs)
2794 return pretty_print_func_graph(data, size, event, cpu, 2871 return pretty_print_func_graph(data, size, event, cpu,
2795 pid, comm, secs, usecs); 2872 pid, comm, secs, usecs);
2796 2873
2797 printf("%16s-%-5d [%03d] %5lu.%06lu: %s: ", 2874 if (latency_format) {
2798 comm, pid, cpu, 2875 printf("%8.8s-%-5d %3d",
2799 secs, usecs, event->name); 2876 comm, pid, cpu);
2877 print_lat_fmt(data, size);
2878 } else
2879 printf("%16s-%-5d [%03d] %5lu.%06lu: %s: ",
2880 comm, pid, cpu,
2881 secs, usecs, event->name);
2882
2800 2883
2801 if (event->flags & EVENT_FL_FAILED) { 2884 if (event->flags & EVENT_FL_FAILED) {
2802 printf("EVENT '%s' FAILED TO PARSE\n", 2885 printf("EVENT '%s' FAILED TO PARSE\n",
diff --git a/parse-events.h b/parse-events.h
index d517ba2..d9e8f4f 100644
--- a/parse-events.h
+++ b/parse-events.h
@@ -234,6 +234,17 @@ extern int header_page_size_size;
234extern int header_page_data_offset; 234extern int header_page_data_offset;
235extern int header_page_data_size; 235extern int header_page_data_size;
236 236
237extern int latency_format;
238
237int parse_header_page(char *buf, unsigned long size); 239int parse_header_page(char *buf, unsigned long size);
238 240
241/* taken from kernel/trace/trace.h */
242enum trace_flag_type {
243 TRACE_FLAG_IRQS_OFF = 0x01,
244 TRACE_FLAG_IRQS_NOSUPPORT = 0x02,
245 TRACE_FLAG_NEED_RESCHED = 0x04,
246 TRACE_FLAG_HARDIRQ = 0x08,
247 TRACE_FLAG_SOFTIRQ = 0x10,
248};
249
239#endif /* _PARSE_EVENTS_H */ 250#endif /* _PARSE_EVENTS_H */
diff --git a/trace-cmd.c b/trace-cmd.c
index 3657dd3..25e9692 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -153,6 +153,8 @@ void warn(char *fmt, ...)
153 153
154 if (errno) 154 if (errno)
155 perror("trace-cmd"); 155 perror("trace-cmd");
156 breakpoint();
157 errno = 0;
156 158
157 va_start(ap, fmt); 159 va_start(ap, fmt);
158 fprintf(stderr, " "); 160 fprintf(stderr, " ");
@@ -1039,6 +1041,7 @@ void usage(char **argv)
1039 " -e show file endianess\n" 1041 " -e show file endianess\n"
1040 " -f show function list\n" 1042 " -f show function list\n"
1041 " -P show printk list\n" 1043 " -P show printk list\n"
1044 " -l show latency format (default with latency tracers)\n"
1042 "\n" 1045 "\n"
1043 " %s list [-e][-p]\n" 1046 " %s list [-e][-p]\n"
1044 " -e list available events\n" 1047 " -e list available events\n"
@@ -1058,6 +1061,8 @@ int main (int argc, char **argv)
1058 1061
1059 int c; 1062 int c;
1060 1063
1064 errno = 0;
1065
1061 if (argc < 2) 1066 if (argc < 2)
1062 usage(argv); 1067 usage(argv);
1063 1068
diff --git a/trace-read.c b/trace-read.c
index d3faede..b3cb20a 100644
--- a/trace-read.c
+++ b/trace-read.c
@@ -613,7 +613,7 @@ void trace_report (int argc, char **argv)
613 {NULL, 0, NULL, 0} 613 {NULL, 0, NULL, 0}
614 }; 614 };
615 615
616 c = getopt_long (argc-1, argv+1, "+hi:fepP", 616 c = getopt_long (argc-1, argv+1, "+hi:fepPl",
617 long_options, &option_index); 617 long_options, &option_index);
618 if (c == -1) 618 if (c == -1)
619 break; 619 break;
@@ -636,6 +636,9 @@ void trace_report (int argc, char **argv)
636 case 'p': 636 case 'p':
637 show_page_size = 1; 637 show_page_size = 1;
638 break; 638 break;
639 case 'l':
640 latency_format = 1;
641 break;
639 case 0: 642 case 0:
640 switch(option_index) { 643 switch(option_index) {
641 case 0: 644 case 0: