/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2019, Matthew Macy <[email protected]>4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24* SUCH DAMAGE.25*26*/2728#ifndef _SYS_GCOV_H_29#define _SYS_GCOV_H_3031MALLOC_DECLARE(M_GCOV);3233/*34* Profiling data types used for gcc 3.4 and above - these are defined by35* gcc and need to be kept as close to the original definition as possible to36* remain compatible.37*/38#define GCOV_DATA_MAGIC ((unsigned int) 0x67636461)39#define GCOV_TAG_FUNCTION ((unsigned int) 0x01000000)40#define GCOV_TAG_COUNTER_BASE ((unsigned int) 0x01a10000)41#define GCOV_TAG_FOR_COUNTER(count) \42(GCOV_TAG_COUNTER_BASE + ((unsigned int) (count) << 17))4344typedef uint64_t gcov_type;4546/* Opaque gcov_info. The gcov structures can change as for example in gcc 4.7 so47* we cannot use full definition here and they need to be placed in gcc specific48* implementation of gcov. This also means no direct access to the members in49* generic code and usage of the interface below.*/50struct gcov_info;5152/* Interface to access gcov_info data */53const char *gcov_info_filename(struct gcov_info *info);54unsigned int gcov_info_version(struct gcov_info *info);55struct gcov_info *gcov_info_next(struct gcov_info *info);56void gcov_info_link(struct gcov_info *info);57void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info);5859/* Base interface. */60enum gcov_action {61GCOV_ADD,62GCOV_REMOVE,63};6465/* Iterator control. */66struct gcov_iterator;6768struct gcov_iterator *gcov_iter_new(struct gcov_info *info);69void gcov_iter_free(struct gcov_iterator *iter);70void gcov_iter_start(struct gcov_iterator *iter);71int gcov_iter_next(struct gcov_iterator *iter);72int gcov_iter_write(struct gcov_iterator *iter, struct sbuf *sbuf);73struct gcov_info *gcov_iter_get_info(struct gcov_iterator *iter);7475/* gcov_info control. */76void gcov_info_reset(struct gcov_info *info);77int gcov_info_is_compatible(struct gcov_info *info1, struct gcov_info *info2);78void gcov_info_add(struct gcov_info *dest, struct gcov_info *source);79struct gcov_info *gcov_info_dup(struct gcov_info *info);80void gcov_info_free(struct gcov_info *info);81void gcov_stats_reset(void);82void gcov_enable_events(void);83void gcov_module_unload(void *, module_t);84void gcov_fs_init(void);8586int within_module(vm_offset_t addr, module_t mod);8788struct gcov_link {89enum {90OBJ_TREE,91SRC_TREE,92} dir;93const char *ext;94};95extern const struct gcov_link gcov_link[];96#endif979899