diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-06-01 15:35:46 +0800 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-06-01 23:25:15 -0400 |
commit | 7fcb7c472f455d1711eb5a7633204dba8800a6d6 (patch) | |
tree | ba64de513bdbe5550c6fc08078a356359830ec99 /include/trace/events/sched.h | |
parent | a9c1c3abe1160a5632e48c929b02b740556bf423 (diff) |
tracing/events: introduce __dynamic_array()
__string() is limited:
- it's a char array, but we may want to define array with other types
- a source string should be available, but we may just know the string size
We introduce __dynamic_array() to break those limitations, and __string()
becomes a wrapper of it. As a side effect, now __get_str() can be used
in TP_fast_assign but not only TP_print.
Take XFS for example, we have the string length in the dirent, but the
string itself is not NULL-terminated, so __dynamic_array() can be used:
TRACE_EVENT(xfs_dir2,
TP_PROTO(struct xfs_da_args *args),
TP_ARGS(args),
TP_STRUCT__entry(
__field(int, namelen)
__dynamic_array(char, name, args->namelen + 1)
...
),
TP_fast_assign(
char *name = __get_str(name);
if (args->namelen)
memcpy(name, args->name, args->namelen);
name[args->namelen] = '\0';
__entry->namelen = args->namelen;
),
TP_printk("name %.*s namelen %d",
__entry->namelen ? __get_str(name) : NULL
__entry->namelen)
);
[ Impact: allow defining dynamic size arrays ]
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A2384D2.3080403@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'include/trace/events/sched.h')
0 files changed, 0 insertions, 0 deletions