This source file includes following definitions.
- call_site_handler
- TEP_PLUGIN_LOADER
- TEP_PLUGIN_UNLOADER
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23
24 #include "event-parse.h"
25 #include "trace-seq.h"
26
27 static int call_site_handler(struct trace_seq *s, struct tep_record *record,
28 struct tep_event *event, void *context)
29 {
30 struct tep_format_field *field;
31 unsigned long long val, addr;
32 void *data = record->data;
33 const char *func;
34
35 field = tep_find_field(event, "call_site");
36 if (!field)
37 return 1;
38
39 if (tep_read_number_field(field, data, &val))
40 return 1;
41
42 func = tep_find_function(event->tep, val);
43 if (!func)
44 return 1;
45
46 addr = tep_find_function_address(event->tep, val);
47
48 trace_seq_printf(s, "(%s+0x%x) ", func, (int)(val - addr));
49 return 1;
50 }
51
52 int TEP_PLUGIN_LOADER(struct tep_handle *tep)
53 {
54 tep_register_event_handler(tep, -1, "kmem", "kfree",
55 call_site_handler, NULL);
56
57 tep_register_event_handler(tep, -1, "kmem", "kmalloc",
58 call_site_handler, NULL);
59
60 tep_register_event_handler(tep, -1, "kmem", "kmalloc_node",
61 call_site_handler, NULL);
62
63 tep_register_event_handler(tep, -1, "kmem", "kmem_cache_alloc",
64 call_site_handler, NULL);
65
66 tep_register_event_handler(tep, -1, "kmem",
67 "kmem_cache_alloc_node",
68 call_site_handler, NULL);
69
70 tep_register_event_handler(tep, -1, "kmem", "kmem_cache_free",
71 call_site_handler, NULL);
72 return 0;
73 }
74
75 void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
76 {
77 tep_unregister_event_handler(tep, -1, "kmem", "kfree",
78 call_site_handler, NULL);
79
80 tep_unregister_event_handler(tep, -1, "kmem", "kmalloc",
81 call_site_handler, NULL);
82
83 tep_unregister_event_handler(tep, -1, "kmem", "kmalloc_node",
84 call_site_handler, NULL);
85
86 tep_unregister_event_handler(tep, -1, "kmem", "kmem_cache_alloc",
87 call_site_handler, NULL);
88
89 tep_unregister_event_handler(tep, -1, "kmem",
90 "kmem_cache_alloc_node",
91 call_site_handler, NULL);
92
93 tep_unregister_event_handler(tep, -1, "kmem", "kmem_cache_free",
94 call_site_handler, NULL);
95 }