ftrace实现(二)----event tracer

好像,event tracer虽然可以动态指定,但实际上是静态实现的?不知道对不对

trace_outpu.c : device_initcall    init_events

vmlinux.lds

__start_ftrace_events = .;
*(_ftrace_events)
__stop_ftrace_events = .;


412 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
413 +--137 lines: #endif-------------------------
550 #undef TRACE_EVENT
551 #define TRACE_EVENT(call, proto, args, tstruct, assign, print)      \
552                                     \
553 +-- 67 lines: static struct ftrace_event_call event_##call;    \--------------
620                                     \
621 static struct ftrace_event_call __used                  \
622 __attribute__((__aligned__(4)))                     \
623 __attribute__((section("_ftrace_events"))) event_##call = {     \
624     .name           = #call,                \
625     .system         = __stringify(TRACE_SYSTEM),        \
626     .event          = &ftrace_event_type_##call,        \
627     .raw_init       = ftrace_raw_init_event_##call,     \
628     .regfunc        = ftrace_raw_reg_event_##call,      \
629     .unregfunc      = ftrace_raw_unreg_event_##call,    \
630     .show_format        = ftrace_format_##call,         \
631     .define_fields      = ftrace_define_fields_##call,      \
632     _TRACE_PROFILE_INIT(call)                   \
633 }

 

1147 static __init int setup_trace_event(char *str)                                                                               
1148 {
1149     strlcpy(bootup_event_buf, str, COMMAND_LINE_SIZE);
1150 +--  4 lines: ring_buffer_expanded = 1;----------------
1154 }
1155 __setup("trace_event=", setup_trace_event);
1156 
1157 static __init int event_trace_init(void)
1158 {
1159     struct ftrace_event_call *call;
1160 +---  4 lines: struct dentry *d_tracer;----------------
1164     char *buf = bootup_event_buf;
1165     char *token;
1166 +--- 35 lines: d_tracer = tracing_init_dentry();-------
1201     for_each_event(call, __start_ftrace_events, __stop_ftrace_events) {
1202         /* The linker may leave blanks */
1203         if (!call->name)
1204             continue;
1205         if (call->raw_init) {
1206             ret = call->raw_init();
1207 +--  6 lines: if (ret < 0) {---------------------------
1213         }       
1214         list_add(&call->list, &ftrace_events);
1215 +--  4 lines: event_create_dir(call, d_events, &ftrace_event_id_fops,----
1219
1220     while (true) {
1221         token = strsep(&buf, ",");
1222 +--  6 lines: if (!token)-------------------------------------------------
1228         ret = ftrace_set_clr_event(token, 1);
1229         if (ret)
1230             pr_warning("Failed to enable trace event: %s\n", token);
1231     }
1232 
1233     ret = register_module_notifier(&trace_module_nb);
1234 +---  3 lines: if (ret)--------------------------------------------------
1237     return 0;
1238 }
1239 fs_initcall(event_trace_init);

 

posted on 2014-12-21 23:14  阿加  阅读(545)  评论(0)    收藏  举报

导航