diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-11-12 22:32:11 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-11-19 10:18:47 -0500 |
commit | 042957801626465492b9428860de39a3cb2a8219 (patch) | |
tree | b0997862babd5e474c500b1b4c522f3a03842106 /include/trace | |
parent | 45677454dd6d128608117abe7dcd2bdfdd7cdf72 (diff) |
tracing/events: Show real number in array fields
Currently we have in something like the sched_switch event:
field:char prev_comm[TASK_COMM_LEN]; offset:12; size:16; signed:1;
When a userspace tool such as perf tries to parse this, the
TASK_COMM_LEN is meaningless. This is done because the TRACE_EVENT() macro
simply uses a #len to show the string of the length. When the length is
an enum, we get a string that means nothing for tools.
By adding a static buffer and a mutex to protect it, we can store the
string into that buffer with snprintf and show the actual number.
Now we get:
field:char prev_comm[16]; offset:12; size:16; signed:1;
Something much more useful.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include/trace')
-rw-r--r-- | include/trace/ftrace.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index e718a917d89..e16610c208c 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -296,13 +296,19 @@ static struct trace_event_functions ftrace_event_type_funcs_##call = { \ | |||
296 | 296 | ||
297 | #undef __array | 297 | #undef __array |
298 | #define __array(type, item, len) \ | 298 | #define __array(type, item, len) \ |
299 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | 299 | do { \ |
300 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 300 | mutex_lock(&event_storage_mutex); \ |
301 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | ||
302 | snprintf(event_storage, sizeof(event_storage), \ | ||
303 | "%s[%d]", #type, len); \ | ||
304 | ret = trace_define_field(event_call, event_storage, #item, \ | ||
301 | offsetof(typeof(field), item), \ | 305 | offsetof(typeof(field), item), \ |
302 | sizeof(field.item), \ | 306 | sizeof(field.item), \ |
303 | is_signed_type(type), FILTER_OTHER); \ | 307 | is_signed_type(type), FILTER_OTHER); \ |
304 | if (ret) \ | 308 | mutex_unlock(&event_storage_mutex); \ |
305 | return ret; | 309 | if (ret) \ |
310 | return ret; \ | ||
311 | } while (0); | ||
306 | 312 | ||
307 | #undef __dynamic_array | 313 | #undef __dynamic_array |
308 | #define __dynamic_array(type, item, len) \ | 314 | #define __dynamic_array(type, item, len) \ |