static int gcov_module_notifier(struct notifier_block *nb, unsigned long event, void *data) { struct module *mod = data; struct gcov_info *info; struct gcov_info *prev; if (event != MODULE_STATE_GOING) return NOTIFY_OK; mutex_lock(&gcov_lock); prev = NULL; /* */ for (info = gcov_info_head; info; info = info->next) { if (within(info, mod->module_core, mod->core_size)) { if (prev) prev->next = info->next; else gcov_info_head = info->next; if (gcov_events_enabled) gcov_event(GCOV_REMOVE, info); } else prev = info; } mutex_unlock(&gcov_lock); return NOTIFY_OK; }
/* Update list and generate events when modules are unloaded. */ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event, void *data) { struct module *mod = data; struct gcov_info *info = NULL; struct gcov_info *prev = NULL; if (event != MODULE_STATE_GOING) return NOTIFY_OK; mutex_lock(&gcov_lock); /* Remove entries located in module from linked list. */ while ((info = gcov_info_next(info))) { if (within_module((unsigned long)info, mod)) { gcov_info_unlink(prev, info); if (gcov_events_enabled) gcov_event(GCOV_REMOVE, info); } else prev = info; } mutex_unlock(&gcov_lock); return NOTIFY_OK; }
void gcov_enable_events(void) { struct gcov_info *info; mutex_lock(&gcov_lock); gcov_events_enabled = 1; /* */ for (info = gcov_info_head; info; info = info->next) gcov_event(GCOV_ADD, info); mutex_unlock(&gcov_lock); }
/** * gcov_enable_events - enable event reporting through gcov_event() * * Turn on reporting of profiling data load/unload-events through the * gcov_event() callback. Also replay all previous events once. This function * is needed because some events are potentially generated too early for the * callback implementation to handle them initially. */ void gcov_enable_events(void) { struct gcov_info *info; mutex_lock(&gcov_lock); gcov_events_enabled = 1; /* Perform event callback for previously registered entries. */ for (info = gcov_info_head; info; info = info->next) gcov_event(GCOV_ADD, info); mutex_unlock(&gcov_lock); }
/** * gcov_enable_events - enable event reporting through gcov_event() * * Turn on reporting of profiling data load/unload-events through the * gcov_event() callback. Also replay all previous events once. This function * is needed because some events are potentially generated too early for the * callback implementation to handle them initially. */ void gcov_enable_events(void) { struct gcov_info *info = NULL; mutex_lock(&gcov_lock); gcov_events_enabled = 1; /* Perform event callback for previously registered entries. */ while ((info = gcov_info_next(info))) { gcov_event(GCOV_ADD, info); cond_resched(); } mutex_unlock(&gcov_lock); }
/* * __gcov_init is called by gcc-generated constructor code for each object * file compiled with -fprofile-arcs. */ void __gcov_init(struct gcov_info *info) { static unsigned int gcov_version; mutex_lock(&gcov_lock); if (gcov_version == 0) { gcov_version = gcov_info_version(info); /* * Printing gcc's version magic may prove useful for debugging * incompatibility reports. */ pr_info("version magic: 0x%x\n", gcov_version); } /* * Add new profiling data structure to list and inform event * listener. */ gcov_info_link(info); if (gcov_events_enabled) gcov_event(GCOV_ADD, info); mutex_unlock(&gcov_lock); }
void __gcov_init(struct gcov_info *info) { static unsigned int gcov_version; mutex_lock(&gcov_lock); if (gcov_version == 0) { gcov_version = info->version; /* */ pr_info("version magic: 0x%x\n", gcov_version); } /* */ info->next = gcov_info_head; gcov_info_head = info; if (gcov_events_enabled) gcov_event(GCOV_ADD, info); mutex_unlock(&gcov_lock); }