aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Zanussi <tzanussi@gmail.com>2009-10-06 02:09:50 -0400
committerIngo Molnar <mingo@elte.hu>2009-10-06 09:04:45 -0400
commit26a50744b21fff65bd754874072857bee8967f4d (patch)
tree4819820f0841090232fcd2525f496f787fd411c7
parentd9b2002c406011164f245de7a81304625989f1c9 (diff)
tracing/events: Add 'signed' field to format files
The sign info used for filters in the kernel is also useful to applications that process the trace stream. Add it to the format files and make it available to userspace. Signed-off-by: Tom Zanussi <tzanussi@gmail.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: rostedt@goodmis.org Cc: lizf@cn.fujitsu.com Cc: hch@infradead.org Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <1254809398-8078-2-git-send-email-tzanussi@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--include/trace/ftrace.h15
-rw-r--r--kernel/trace/ring_buffer.c15
-rw-r--r--kernel/trace/trace_events.c24
-rw-r--r--kernel/trace/trace_export.c25
-rw-r--r--kernel/trace/trace_syscalls.c20
-rw-r--r--tools/perf/util/trace-event-parse.c24
-rw-r--r--tools/perf/util/trace-event.h1
7 files changed, 82 insertions, 42 deletions
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index cc0d9667e182..c9bbcab95fbe 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -120,9 +120,10 @@
120#undef __field 120#undef __field
121#define __field(type, item) \ 121#define __field(type, item) \
122 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ 122 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
123 "offset:%u;\tsize:%u;\n", \ 123 "offset:%u;\tsize:%u;\tsigned:%u;\n", \
124 (unsigned int)offsetof(typeof(field), item), \ 124 (unsigned int)offsetof(typeof(field), item), \
125 (unsigned int)sizeof(field.item)); \ 125 (unsigned int)sizeof(field.item), \
126 (unsigned int)is_signed_type(type)); \
126 if (!ret) \ 127 if (!ret) \
127 return 0; 128 return 0;
128 129
@@ -132,19 +133,21 @@
132#undef __array 133#undef __array
133#define __array(type, item, len) \ 134#define __array(type, item, len) \
134 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ 135 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
135 "offset:%u;\tsize:%u;\n", \ 136 "offset:%u;\tsize:%u;\tsigned:%u;\n", \
136 (unsigned int)offsetof(typeof(field), item), \ 137 (unsigned int)offsetof(typeof(field), item), \
137 (unsigned int)sizeof(field.item)); \ 138 (unsigned int)sizeof(field.item), \
139 (unsigned int)is_signed_type(type)); \
138 if (!ret) \ 140 if (!ret) \
139 return 0; 141 return 0;
140 142
141#undef __dynamic_array 143#undef __dynamic_array
142#define __dynamic_array(type, item, len) \ 144#define __dynamic_array(type, item, len) \
143 ret = trace_seq_printf(s, "\tfield:__data_loc " #type "[] " #item ";\t"\ 145 ret = trace_seq_printf(s, "\tfield:__data_loc " #type "[] " #item ";\t"\
144 "offset:%u;\tsize:%u;\n", \ 146 "offset:%u;\tsize:%u;\tsigned:%u;\n", \
145 (unsigned int)offsetof(typeof(field), \ 147 (unsigned int)offsetof(typeof(field), \
146 __data_loc_##item), \ 148 __data_loc_##item), \
147 (unsigned int)sizeof(field.__data_loc_##item)); \ 149 (unsigned int)sizeof(field.__data_loc_##item), \
150 (unsigned int)is_signed_type(type)); \
148 if (!ret) \ 151 if (!ret) \
149 return 0; 152 return 0;
150 153
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index d4ff01970547..e43c928356ee 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -397,18 +397,21 @@ int ring_buffer_print_page_header(struct trace_seq *s)
397 int ret; 397 int ret;
398 398
399 ret = trace_seq_printf(s, "\tfield: u64 timestamp;\t" 399 ret = trace_seq_printf(s, "\tfield: u64 timestamp;\t"
400 "offset:0;\tsize:%u;\n", 400 "offset:0;\tsize:%u;\tsigned:%u;\n",
401 (unsigned int)sizeof(field.time_stamp)); 401 (unsigned int)sizeof(field.time_stamp),
402 (unsigned int)is_signed_type(u64));
402 403
403 ret = trace_seq_printf(s, "\tfield: local_t commit;\t" 404 ret = trace_seq_printf(s, "\tfield: local_t commit;\t"
404 "offset:%u;\tsize:%u;\n", 405 "offset:%u;\tsize:%u;\tsigned:%u;\n",
405 (unsigned int)offsetof(typeof(field), commit), 406 (unsigned int)offsetof(typeof(field), commit),
406 (unsigned int)sizeof(field.commit)); 407 (unsigned int)sizeof(field.commit),
408 (unsigned int)is_signed_type(long));
407 409
408 ret = trace_seq_printf(s, "\tfield: char data;\t" 410 ret = trace_seq_printf(s, "\tfield: char data;\t"
409 "offset:%u;\tsize:%u;\n", 411 "offset:%u;\tsize:%u;\tsigned:%u;\n",
410 (unsigned int)offsetof(typeof(field), data), 412 (unsigned int)offsetof(typeof(field), data),
411 (unsigned int)BUF_PAGE_SIZE); 413 (unsigned int)BUF_PAGE_SIZE,
414 (unsigned int)is_signed_type(char));
412 415
413 return ret; 416 return ret;
414} 417}
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index d128f65778e6..cf3cabf6ce14 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -507,7 +507,7 @@ extern char *__bad_type_size(void);
507#define FIELD(type, name) \ 507#define FIELD(type, name) \
508 sizeof(type) != sizeof(field.name) ? __bad_type_size() : \ 508 sizeof(type) != sizeof(field.name) ? __bad_type_size() : \
509 #type, "common_" #name, offsetof(typeof(field), name), \ 509 #type, "common_" #name, offsetof(typeof(field), name), \
510 sizeof(field.name) 510 sizeof(field.name), is_signed_type(type)
511 511
512static int trace_write_header(struct trace_seq *s) 512static int trace_write_header(struct trace_seq *s)
513{ 513{
@@ -515,17 +515,17 @@ static int trace_write_header(struct trace_seq *s)
515 515
516 /* struct trace_entry */ 516 /* struct trace_entry */
517 return trace_seq_printf(s, 517 return trace_seq_printf(s,
518 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" 518 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
519 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" 519 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
520 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" 520 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
521 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" 521 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
522 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" 522 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\tsigned:%u;\n"
523 "\n", 523 "\n",
524 FIELD(unsigned short, type), 524 FIELD(unsigned short, type),
525 FIELD(unsigned char, flags), 525 FIELD(unsigned char, flags),
526 FIELD(unsigned char, preempt_count), 526 FIELD(unsigned char, preempt_count),
527 FIELD(int, pid), 527 FIELD(int, pid),
528 FIELD(int, lock_depth)); 528 FIELD(int, lock_depth));
529} 529}
530 530
531static ssize_t 531static ssize_t
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c
index 9753fcc61bc5..31da218ee10f 100644
--- a/kernel/trace/trace_export.c
+++ b/kernel/trace/trace_export.c
@@ -66,44 +66,47 @@ static void __used ____ftrace_check_##name(void) \
66#undef __field 66#undef __field
67#define __field(type, item) \ 67#define __field(type, item) \
68 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ 68 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
69 "offset:%zu;\tsize:%zu;\n", \ 69 "offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
70 offsetof(typeof(field), item), \ 70 offsetof(typeof(field), item), \
71 sizeof(field.item)); \ 71 sizeof(field.item), is_signed_type(type)); \
72 if (!ret) \ 72 if (!ret) \
73 return 0; 73 return 0;
74 74
75#undef __field_desc 75#undef __field_desc
76#define __field_desc(type, container, item) \ 76#define __field_desc(type, container, item) \
77 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ 77 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
78 "offset:%zu;\tsize:%zu;\n", \ 78 "offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
79 offsetof(typeof(field), container.item), \ 79 offsetof(typeof(field), container.item), \
80 sizeof(field.container.item)); \ 80 sizeof(field.container.item), \
81 is_signed_type(type)); \
81 if (!ret) \ 82 if (!ret) \
82 return 0; 83 return 0;
83 84
84#undef __array 85#undef __array
85#define __array(type, item, len) \ 86#define __array(type, item, len) \
86 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ 87 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
87 "offset:%zu;\tsize:%zu;\n", \ 88 "offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
88 offsetof(typeof(field), item), \ 89 offsetof(typeof(field), item), \
89 sizeof(field.item)); \ 90 sizeof(field.item), is_signed_type(type)); \
90 if (!ret) \ 91 if (!ret) \
91 return 0; 92 return 0;
92 93
93#undef __array_desc 94#undef __array_desc
94#define __array_desc(type, container, item, len) \ 95#define __array_desc(type, container, item, len) \
95 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \ 96 ret = trace_seq_printf(s, "\tfield:" #type " " #item "[" #len "];\t" \
96 "offset:%zu;\tsize:%zu;\n", \ 97 "offset:%zu;\tsize:%zu;\tsigned:%u;\n", \
97 offsetof(typeof(field), container.item), \ 98 offsetof(typeof(field), container.item), \
98 sizeof(field.container.item)); \ 99 sizeof(field.container.item), \
100 is_signed_type(type)); \
99 if (!ret) \ 101 if (!ret) \
100 return 0; 102 return 0;
101 103
102#undef __dynamic_array 104#undef __dynamic_array
103#define __dynamic_array(type, item) \ 105#define __dynamic_array(type, item) \
104 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \ 106 ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
105 "offset:%zu;\tsize:0;\n", \ 107 "offset:%zu;\tsize:0;\tsigned:%u;\n", \
106 offsetof(typeof(field), item)); \ 108 offsetof(typeof(field), item), \
109 is_signed_type(type)); \
107 if (!ret) \ 110 if (!ret) \
108 return 0; 111 return 0;
109 112
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 527e17eae575..d99abc427c39 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -103,7 +103,8 @@ extern char *__bad_type_size(void);
103#define SYSCALL_FIELD(type, name) \ 103#define SYSCALL_FIELD(type, name) \
104 sizeof(type) != sizeof(trace.name) ? \ 104 sizeof(type) != sizeof(trace.name) ? \
105 __bad_type_size() : \ 105 __bad_type_size() : \
106 #type, #name, offsetof(typeof(trace), name), sizeof(trace.name) 106 #type, #name, offsetof(typeof(trace), name), \
107 sizeof(trace.name), is_signed_type(type)
107 108
108int syscall_enter_format(struct ftrace_event_call *call, struct trace_seq *s) 109int syscall_enter_format(struct ftrace_event_call *call, struct trace_seq *s)
109{ 110{
@@ -120,7 +121,8 @@ int syscall_enter_format(struct ftrace_event_call *call, struct trace_seq *s)
120 if (!entry) 121 if (!entry)
121 return 0; 122 return 0;
122 123
123 ret = trace_seq_printf(s, "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n", 124 ret = trace_seq_printf(s, "\tfield:%s %s;\toffset:%zu;\tsize:%zu;"
125 "\tsigned:%u;\n",
124 SYSCALL_FIELD(int, nr)); 126 SYSCALL_FIELD(int, nr));
125 if (!ret) 127 if (!ret)
126 return 0; 128 return 0;
@@ -130,8 +132,10 @@ int syscall_enter_format(struct ftrace_event_call *call, struct trace_seq *s)
130 entry->args[i]); 132 entry->args[i]);
131 if (!ret) 133 if (!ret)
132 return 0; 134 return 0;
133 ret = trace_seq_printf(s, "\toffset:%d;\tsize:%zu;\n", offset, 135 ret = trace_seq_printf(s, "\toffset:%d;\tsize:%zu;"
134 sizeof(unsigned long)); 136 "\tsigned:%u;\n", offset,
137 sizeof(unsigned long),
138 is_signed_type(unsigned long));
135 if (!ret) 139 if (!ret)
136 return 0; 140 return 0;
137 offset += sizeof(unsigned long); 141 offset += sizeof(unsigned long);
@@ -163,8 +167,10 @@ int syscall_exit_format(struct ftrace_event_call *call, struct trace_seq *s)
163 struct syscall_trace_exit trace; 167 struct syscall_trace_exit trace;
164 168
165 ret = trace_seq_printf(s, 169 ret = trace_seq_printf(s,
166 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n" 170 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;"
167 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n", 171 "\tsigned:%u;\n"
172 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;"
173 "\tsigned:%u;\n",
168 SYSCALL_FIELD(int, nr), 174 SYSCALL_FIELD(int, nr),
169 SYSCALL_FIELD(long, ret)); 175 SYSCALL_FIELD(long, ret));
170 if (!ret) 176 if (!ret)
@@ -212,7 +218,7 @@ int syscall_exit_define_fields(struct ftrace_event_call *call)
212 if (ret) 218 if (ret)
213 return ret; 219 return ret;
214 220
215 ret = trace_define_field(call, SYSCALL_FIELD(long, ret), 0, 221 ret = trace_define_field(call, SYSCALL_FIELD(long, ret),
216 FILTER_OTHER); 222 FILTER_OTHER);
217 223
218 return ret; 224 return ret;
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 55b41b9e3834..be8412d699a1 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -897,6 +897,21 @@ static int event_read_fields(struct event *event, struct format_field **fields)
897 if (read_expected(EVENT_OP, (char *)";") < 0) 897 if (read_expected(EVENT_OP, (char *)";") < 0)
898 goto fail_expect; 898 goto fail_expect;
899 899
900 if (read_expected(EVENT_ITEM, (char *)"signed") < 0)
901 goto fail_expect;
902
903 if (read_expected(EVENT_OP, (char *)":") < 0)
904 goto fail_expect;
905
906 if (read_expect_type(EVENT_ITEM, &token))
907 goto fail;
908 if (strtoul(token, NULL, 0))
909 field->flags |= FIELD_IS_SIGNED;
910 free_token(token);
911
912 if (read_expected(EVENT_OP, (char *)";") < 0)
913 goto fail_expect;
914
900 if (read_expect_type(EVENT_NEWLINE, &token) < 0) 915 if (read_expect_type(EVENT_NEWLINE, &token) < 0)
901 goto fail; 916 goto fail;
902 free_token(token); 917 free_token(token);
@@ -2845,6 +2860,15 @@ static void parse_header_field(char *type,
2845 free_token(token); 2860 free_token(token);
2846 if (read_expected(EVENT_OP, (char *)";") < 0) 2861 if (read_expected(EVENT_OP, (char *)";") < 0)
2847 return; 2862 return;
2863 if (read_expected(EVENT_ITEM, (char *)"signed") < 0)
2864 return;
2865 if (read_expected(EVENT_OP, (char *)":") < 0)
2866 return;
2867 if (read_expect_type(EVENT_ITEM, &token) < 0)
2868 return;
2869 free_token(token);
2870 if (read_expected(EVENT_OP, (char *)";") < 0)
2871 return;
2848 if (read_expect_type(EVENT_NEWLINE, &token) < 0) 2872 if (read_expect_type(EVENT_NEWLINE, &token) < 0)
2849 return; 2873 return;
2850 free_token(token); 2874 free_token(token);
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 162c3e6deb93..00b440df66d8 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -26,6 +26,7 @@ enum {
26enum format_flags { 26enum format_flags {
27 FIELD_IS_ARRAY = 1, 27 FIELD_IS_ARRAY = 1,
28 FIELD_IS_POINTER = 2, 28 FIELD_IS_POINTER = 2,
29 FIELD_IS_SIGNED = 4,
29}; 30};
30 31
31struct format_field { 32struct format_field {