Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140835
b: refs/heads/master
c: 981d081
h: refs/heads/master
i:
  140833: 34208dd
  140831: f8c4606
v: v3
  • Loading branch information
Steven Rostedt committed Mar 2, 2009
1 parent 1e1dc34 commit 723191f
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f9520750c4c9924c14325cd951efae5fae58104c
refs/heads/master: 981d081ec8b958b7d962ee40d433581a55d40fc5
1 change: 1 addition & 0 deletions trunk/kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ struct ftrace_event_call {
int (*raw_init)(void);
int (*raw_reg)(void);
void (*raw_unreg)(void);
int (*show_format)(struct trace_seq *s);
};

void event_trace_printk(unsigned long ip, const char *fmt, ...);
Expand Down
56 changes: 55 additions & 1 deletion trunk/kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
*
* Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
*
* - Added format output of fields of the trace point.
* This was based off of work by Tom Zanussi <tzanussi@gmail.com>.
*
*/

#include <linux/debugfs.h>
Expand Down Expand Up @@ -444,6 +447,42 @@ event_available_types_read(struct file *filp, char __user *ubuf, size_t cnt,
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
}

static ssize_t
event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
loff_t *ppos)
{
struct ftrace_event_call *call = filp->private_data;
struct trace_seq *s;
char *buf;
int r;

s = kmalloc(sizeof(*s), GFP_KERNEL);
if (!s)
return -ENOMEM;

trace_seq_init(s);

if (*ppos)
return 0;

r = call->show_format(s);
if (!r) {
/*
* ug! The format output is bigger than a PAGE!!
*/
buf = "FORMAT TOO BIG\n";
r = simple_read_from_buffer(ubuf, cnt, ppos,
buf, strlen(buf));
goto out;
}

r = simple_read_from_buffer(ubuf, cnt, ppos,
s->buffer, s->len);
out:
kfree(s);
return r;
}

static const struct seq_operations show_event_seq_ops = {
.start = t_start,
.next = t_next,
Expand Down Expand Up @@ -490,6 +529,11 @@ static const struct file_operations ftrace_available_types_fops = {
.read = event_available_types_read,
};

static const struct file_operations ftrace_event_format_fops = {
.open = tracing_open_generic,
.read = event_format_read,
};

static struct dentry *event_trace_events_dir(void)
{
static struct dentry *d_tracer;
Expand Down Expand Up @@ -602,7 +646,17 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
&ftrace_available_types_fops);
if (!entry)
pr_warning("Could not create debugfs "
"'%s/type' available_types\n", call->name);
"'%s/available_types' entry\n", call->name);

/* A trace may not want to export its format */
if (!call->show_format)
return 0;

entry = debugfs_create_file("format", 0444, call->dir, call,
&ftrace_event_format_fops);
if (!entry)
pr_warning("Could not create debugfs "
"'%s/format' entry\n", call->name);

return 0;
}
Expand Down
52 changes: 52 additions & 0 deletions trunk/kernel/trace/trace_events_stage_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,55 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
}

#include <trace/trace_event_types.h>

/*
* Setup the showing format of trace point.
*
* int
* ftrace_format_##call(struct trace_seq *s)
* {
* struct ftrace_raw_##call field;
* int ret;
*
* ret = trace_seq_printf(s, #type " " #item ";"
* " size:%d; offset:%d;\n",
* sizeof(field.type),
* offsetof(struct ftrace_raw_##call,
* item));
*
* }
*/

#undef TRACE_FIELD
#define TRACE_FIELD(type, item, assign) \
ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t" \
"offset:%lu;\tsize:%lu;\n", \
offsetof(typeof(field), item), \
sizeof(field.item)); \
if (!ret) \
return 0;


#undef TRACE_FIELD_SPECIAL
#define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t" \
"offset:%lu;\tsize:%lu;\n", \
offsetof(typeof(field), item), \
sizeof(field.item)); \
if (!ret) \
return 0;

#undef TRACE_EVENT_FORMAT
#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
int \
ftrace_format_##call(struct trace_seq *s) \
{ \
struct ftrace_raw_##call field; \
int ret; \
\
tstruct; \
\
return ret; \
}

#include <trace/trace_event_types.h>
2 changes: 2 additions & 0 deletions trunk/kernel/trace/trace_events_stage_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
* .raw_init = ftrace_raw_init_event_<call>,
* .raw_reg = ftrace_raw_reg_event_<call>,
* .raw_unreg = ftrace_raw_unreg_event_<call>,
* .show_format = ftrace_format_<call>,
* }
*
*/
Expand Down Expand Up @@ -230,4 +231,5 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
.raw_init = ftrace_raw_init_event_##call, \
.raw_reg = ftrace_raw_reg_event_##call, \
.raw_unreg = ftrace_raw_unreg_event_##call, \
.show_format = ftrace_format_##call, \
}

0 comments on commit 723191f

Please sign in to comment.