// SPDX-License-Identifier: GPL-2.0 /* * This code maintains a list of active profiling data structures. * * Copyright IBM Corp. 2009 * Author(s): Peter Oberparleiter <[email protected]> * * Uses gcc-internal data definitions. * Based on the gcov-kernel patch by: * Hubertus Franke <[email protected]> * Nigel Hinds <[email protected]> * Rajan Ravindran <[email protected]> * Peter Oberparleiter <[email protected]> * Paul Larson */ #define pr_fmt(fmt) … #include <linux/init.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/sched.h> #include "gcov.h" int gcov_events_enabled; DEFINE_MUTEX(…) …; /** * 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) { … } /** * store_gcov_u32 - store 32 bit number in gcov format to buffer * @buffer: target buffer or NULL * @off: offset into the buffer * @v: value to be stored * * Number format defined by gcc: numbers are recorded in the 32 bit * unsigned binary form of the endianness of the machine generating the * file. Returns the number of bytes stored. If @buffer is %NULL, doesn't * store anything. */ size_t store_gcov_u32(void *buffer, size_t off, u32 v) { … } /** * store_gcov_u64 - store 64 bit number in gcov format to buffer * @buffer: target buffer or NULL * @off: offset into the buffer * @v: value to be stored * * Number format defined by gcc: numbers are recorded in the 32 bit * unsigned binary form of the endianness of the machine generating the * file. 64 bit numbers are stored as two 32 bit numbers, the low part * first. Returns the number of bytes stored. If @buffer is %NULL, doesn't store * anything. */ size_t store_gcov_u64(void *buffer, size_t off, u64 v) { … } #ifdef CONFIG_MODULES /* Update list and generate events when modules are unloaded. */ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event, void *data) { … } static struct notifier_block gcov_nb = …; static int __init gcov_init(void) { … } device_initcall(gcov_init); #endif /* CONFIG_MODULES */