1 // SPDX-License-Identifier: LGPL-2.1
3 * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
9 #include "event-parse.h"
10 #include "trace-seq.h"
12 static int call_site_handler(struct trace_seq
*s
, struct tep_record
*record
,
13 struct tep_event
*event
, void *context
)
15 struct tep_format_field
*field
;
16 unsigned long long val
, addr
;
17 void *data
= record
->data
;
20 field
= tep_find_field(event
, "call_site");
24 if (tep_read_number_field(field
, data
, &val
))
27 func
= tep_find_function(event
->tep
, val
);
31 addr
= tep_find_function_address(event
->tep
, val
);
33 trace_seq_printf(s
, "(%s+0x%x) ", func
, (int)(val
- addr
));
37 int TEP_PLUGIN_LOADER(struct tep_handle
*tep
)
39 tep_register_event_handler(tep
, -1, "kmem", "kfree",
40 call_site_handler
, NULL
);
42 tep_register_event_handler(tep
, -1, "kmem", "kmalloc",
43 call_site_handler
, NULL
);
45 tep_register_event_handler(tep
, -1, "kmem", "kmalloc_node",
46 call_site_handler
, NULL
);
48 tep_register_event_handler(tep
, -1, "kmem", "kmem_cache_alloc",
49 call_site_handler
, NULL
);
51 tep_register_event_handler(tep
, -1, "kmem",
52 "kmem_cache_alloc_node",
53 call_site_handler
, NULL
);
55 tep_register_event_handler(tep
, -1, "kmem", "kmem_cache_free",
56 call_site_handler
, NULL
);
60 void TEP_PLUGIN_UNLOADER(struct tep_handle
*tep
)
62 tep_unregister_event_handler(tep
, -1, "kmem", "kfree",
63 call_site_handler
, NULL
);
65 tep_unregister_event_handler(tep
, -1, "kmem", "kmalloc",
66 call_site_handler
, NULL
);
68 tep_unregister_event_handler(tep
, -1, "kmem", "kmalloc_node",
69 call_site_handler
, NULL
);
71 tep_unregister_event_handler(tep
, -1, "kmem", "kmem_cache_alloc",
72 call_site_handler
, NULL
);
74 tep_unregister_event_handler(tep
, -1, "kmem",
75 "kmem_cache_alloc_node",
76 call_site_handler
, NULL
);
78 tep_unregister_event_handler(tep
, -1, "kmem", "kmem_cache_free",
79 call_site_handler
, NULL
);