2 * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
4 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation;
8 * version 2.1 of the License (not later!)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, see <http://www.gnu.org/licenses>
18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 #include "event-parse.h"
25 #include "trace-seq.h"
27 static int call_site_handler(struct trace_seq
*s
, struct tep_record
*record
,
28 struct tep_event_format
*event
, void *context
)
30 struct tep_format_field
*field
;
31 unsigned long long val
, addr
;
32 void *data
= record
->data
;
35 field
= tep_find_field(event
, "call_site");
39 if (tep_read_number_field(field
, data
, &val
))
42 func
= tep_find_function(event
->pevent
, val
);
46 addr
= tep_find_function_address(event
->pevent
, val
);
48 trace_seq_printf(s
, "(%s+0x%x) ", func
, (int)(val
- addr
));
52 int TEP_PLUGIN_LOADER(struct tep_handle
*pevent
)
54 tep_register_event_handler(pevent
, -1, "kmem", "kfree",
55 call_site_handler
, NULL
);
57 tep_register_event_handler(pevent
, -1, "kmem", "kmalloc",
58 call_site_handler
, NULL
);
60 tep_register_event_handler(pevent
, -1, "kmem", "kmalloc_node",
61 call_site_handler
, NULL
);
63 tep_register_event_handler(pevent
, -1, "kmem", "kmem_cache_alloc",
64 call_site_handler
, NULL
);
66 tep_register_event_handler(pevent
, -1, "kmem",
67 "kmem_cache_alloc_node",
68 call_site_handler
, NULL
);
70 tep_register_event_handler(pevent
, -1, "kmem", "kmem_cache_free",
71 call_site_handler
, NULL
);
75 void TEP_PLUGIN_UNLOADER(struct tep_handle
*pevent
)
77 tep_unregister_event_handler(pevent
, -1, "kmem", "kfree",
78 call_site_handler
, NULL
);
80 tep_unregister_event_handler(pevent
, -1, "kmem", "kmalloc",
81 call_site_handler
, NULL
);
83 tep_unregister_event_handler(pevent
, -1, "kmem", "kmalloc_node",
84 call_site_handler
, NULL
);
86 tep_unregister_event_handler(pevent
, -1, "kmem", "kmem_cache_alloc",
87 call_site_handler
, NULL
);
89 tep_unregister_event_handler(pevent
, -1, "kmem",
90 "kmem_cache_alloc_node",
91 call_site_handler
, NULL
);
93 tep_unregister_event_handler(pevent
, -1, "kmem", "kmem_cache_free",
94 call_site_handler
, NULL
);