10 #include <linux/kernel.h>
12 #include <linux/string.h>
13 #include <linux/module.h>
15 #include <linux/ctype.h>
16 #include <linux/list.h>
17 #include <linux/slab.h>
33 struct trace_bprintk_fmt {
38 static inline struct trace_bprintk_fmt *lookup_format(
const char *
fmt)
40 struct trace_bprintk_fmt *
pos;
42 if (!
strcmp(pos->fmt, fmt))
49 void hold_module_trace_bprintk_format(
const char **
start,
const char **
end)
59 for (iter = start; iter <
end; iter++) {
60 struct trace_bprintk_fmt *tb_fmt = lookup_format(*iter);
83 static int module_trace_bprintk_format_notify(
struct notifier_block *
self,
87 if (mod->num_trace_bprintk_fmt) {
88 const char **start = mod->trace_bprintk_fmt_start;
89 const char **end = start + mod->num_trace_bprintk_fmt;
91 if (val == MODULE_STATE_COMING)
92 hold_module_trace_bprintk_format(start, end);
118 find_next_mod_format(
int start_index,
void *
v,
const char **fmt, loff_t *pos)
120 struct trace_bprintk_fmt *mod_fmt;
122 if (list_empty(&trace_bprintk_fmt_list))
131 if (!v || start_index == *pos) {
132 struct trace_bprintk_fmt *
p;
136 if (start_index == *pos)
149 if (mod_fmt->list.next == &trace_bprintk_fmt_list)
154 return &mod_fmt->fmt;
157 static void format_mod_start(
void)
162 static void format_mod_stop(
void)
170 unsigned long val,
void *data)
174 static inline const char **
175 find_next_mod_format(
int start_index,
void *v,
const char **fmt, loff_t *pos)
179 static inline void format_mod_start(
void) { }
180 static inline void format_mod_stop(
void) { }
186 .notifier_call = module_trace_bprintk_format_notify,
243 static const char **find_next(
void *v, loff_t *pos)
245 const char **fmt =
v;
250 if (*pos < start_index)
251 return __start___trace_bprintk_fmt + *
pos;
253 return find_next_mod_format(start_index, v, fmt, pos);
260 return find_next(
NULL, pos);
263 static void *t_next(
struct seq_file *
m,
void * v, loff_t *pos)
266 return find_next(v, pos);
269 static int t_show(
struct seq_file *
m,
void *v)
271 const char **fmt =
v;
275 seq_printf(m,
"0x%lx : \"", *(
unsigned long *)fmt);
280 for (i = 0; str[
i]; i++) {
303 static void t_stop(
struct seq_file *m,
void *p)
318 return seq_open(file, &show_format_seq_ops);
322 .open = ftrace_formats_open,
328 static __init int init_trace_printk_function_export(
void)
337 NULL, &ftrace_formats_fops);
344 static __init int init_trace_printk(
void)