Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146181
b: refs/heads/master
c: be74b73
h: refs/heads/master
i:
  146179: 103fecd
v: v3
  • Loading branch information
Steven Rostedt authored and Frederic Weisbecker committed May 26, 2009
1 parent a05b2bf commit eaa586a
Show file tree
Hide file tree
Showing 4 changed files with 66 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: 0e907c99391362385c8e3af2c43b904dd1fd5d73
refs/heads/master: be74b73a57645cc253d881ab0c1014eb64b9cf22
13 changes: 12 additions & 1 deletion trunk/include/linux/ftrace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@

#include <linux/trace_seq.h>
#include <linux/ring_buffer.h>

#include <linux/percpu.h>

struct trace_array;
struct tracer;
struct dentry;

DECLARE_PER_CPU(struct trace_seq, ftrace_event_seq);

struct trace_print_flags {
unsigned long mask;
const char *name;
};

const char *ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
unsigned long flags,
const struct trace_print_flags *flag_array);

/*
* The trace entry - the most basic unit of tracing. This is what
* is printed in the end as a single line in the trace output, such as:
Expand Down
14 changes: 14 additions & 0 deletions trunk/include/trace/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
* struct trace_seq *s = &iter->seq;
* struct ftrace_raw_<call> *field; <-- defined in stage 1
* struct trace_entry *entry;
* struct trace_seq *p;
* int ret;
*
* entry = iter->ent;
Expand All @@ -98,7 +99,9 @@
*
* field = (typeof(field))entry;
*
* p = get_cpu_var(ftrace_event_seq);
* ret = trace_seq_printf(s, <TP_printk> "\n");
* put_cpu();
* if (!ret)
* return TRACE_TYPE_PARTIAL_LINE;
*
Expand All @@ -119,6 +122,14 @@
#undef __get_str
#define __get_str(field) ((char *)__entry + __entry->__str_loc_##field)

#undef __print_flags
#define __print_flags(flag, delim, flag_array...) \
({ \
static const struct trace_print_flags flags[] = \
{ flag_array, { -1, NULL }}; \
ftrace_print_flags_seq(p, delim, flag, flags); \
})

#undef TRACE_EVENT
#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
enum print_line_t \
Expand All @@ -127,6 +138,7 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
struct trace_seq *s = &iter->seq; \
struct ftrace_raw_##call *field; \
struct trace_entry *entry; \
struct trace_seq *p; \
int ret; \
\
entry = iter->ent; \
Expand All @@ -138,7 +150,9 @@ ftrace_raw_output_##call(struct trace_iterator *iter, int flags) \
\
field = (typeof(field))entry; \
\
p = &get_cpu_var(ftrace_event_seq); \
ret = trace_seq_printf(s, #call ": " print); \
put_cpu(); \
if (!ret) \
return TRACE_TYPE_PARTIAL_LINE; \
\
Expand Down
39 changes: 39 additions & 0 deletions trunk/kernel/trace/trace_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#define EVENT_HASHSIZE 128

static DECLARE_RWSEM(trace_event_mutex);

DEFINE_PER_CPU(struct trace_seq, ftrace_event_seq);

static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;

static int next_event_type = __TRACE_LAST_TYPE + 1;
Expand Down Expand Up @@ -212,6 +215,42 @@ int trace_seq_path(struct trace_seq *s, struct path *path)
return 0;
}

const char *
ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
unsigned long flags,
const struct trace_print_flags *flag_array)
{
unsigned long mask;
const char *str;
int i;

trace_seq_init(p);

for (i = 0; flag_array[i].name && flags; i++) {

mask = flag_array[i].mask;
if ((flags & mask) != mask)
continue;

str = flag_array[i].name;
flags &= ~mask;
if (p->len && delim)
trace_seq_puts(p, delim);
trace_seq_puts(p, str);
}

/* check for left over flags */
if (flags) {
if (p->len && delim)
trace_seq_puts(p, delim);
trace_seq_printf(p, "0x%lx", flags);
}

trace_seq_putc(p, 0);

return p->buffer;
}

#ifdef CONFIG_KRETPROBES
static inline const char *kretprobed(const char *name)
{
Expand Down

0 comments on commit eaa586a

Please sign in to comment.