};
extern int marker_register_lib(struct marker *markers_start, int markers_count);
+extern int marker_unregister_lib(struct marker *markers_start);
#define MARKER_LIB \
extern struct marker __start___markers[] __attribute__((weak, visibility("hidden"))); \
static void __attribute__((constructor)) __markers__init(void) \
{ \
marker_register_lib(__start___markers, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker)); \
+ } \
+ \
+ static void __attribute__((destructor)) __markers__destroy(void) \
+ { \
+ marker_unregister_lib(__start___markers); \
}
extern void marker_set_new_marker_cb(void (*cb)(struct marker *));
extern int tracepoint_register_lib(struct tracepoint *tracepoints_start,
int tracepoints_count);
+extern int tracepoint_unregister_lib(struct tracepoint *tracepoints_start);
#define TRACEPOINT_LIB \
extern struct tracepoint __start___tracepoints[] __attribute__((weak, visibility("hidden"))); \
{ \
tracepoint_register_lib(__start___tracepoints, \
(((long)__stop___tracepoints)-((long)__start___tracepoints))/sizeof(struct tracepoint)); \
+ } \
+ \
+ static void __attribute__((destructor)) __tracepoints__destroy(void) \
+ { \
+ tracepoint_unregister_lib(__start___tracepoints); \
}
#endif /* _UST_TRACEPOINT_H */
return 0;
}
-int marker_unregister_lib(struct marker *markers_start, int markers_count)
+int marker_unregister_lib(struct marker *markers_start)
{
+ struct lib *lib;
+
/*FIXME: implement; but before implementing, marker_register_lib must
have appropriate locking. */
+ lock_markers();
+
+ /* FIXME: we should probably take a mutex here on libs */
+//ust// mutex_lock(&module_mutex);
+ list_for_each_entry(lib, &libs, list) {
+ if(lib->markers_start == markers_start) {
+ struct lib *lib2free = lib;
+ list_del(&lib->list);
+ free(lib2free);
+ break;
+ }
+ }
+
+ unlock_markers();
+
return 0;
}
{
if(!initialized) {
marker_register_lib(__start___markers, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker));
- //DBG("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers);
initialized = 1;
}
}
+
+void __attribute__((constructor)) destroy_markers(void)
+{
+ marker_unregister_lib(__start___markers);
+}
return 0;
}
-int tracepoint_unregister_lib(struct tracepoint *tracepoints_start, int tracepoints_count)
+int tracepoint_unregister_lib(struct tracepoint *tracepoints_start)
{
- /*FIXME: implement; but before implementing, tracepoint_register_lib must
- have appropriate locking. */
+ struct tracepoint_lib *lib;
+
+ mutex_lock(&tracepoints_mutex);
+
+ list_for_each_entry(lib, &libs, list) {
+ if(lib->tracepoints_start == tracepoints_start) {
+ struct tracepoint_lib *lib2free = lib;
+ list_del(&lib->list);
+ free(lib2free);
+ break;
+ }
+ }
+
+ mutex_unlock(&tracepoints_mutex);
return 0;
}