1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2016, Linaro Limited 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /* 30 * gmon.out file format 31 * 32 * This file is adapted from glibc's gmon/sys/gmon_out.h 33 * Although gmon/sys/gmon_out.h is covered by the LGPL v2.1 license or later 34 * as stated below, please note the following: 35 * (https://www.gnu.org/licenses/lgpl-3.0.en.html#section3) 36 * 37 * "3. Object Code Incorporating Material from Library Header Files. 38 * The object code form of an Application may incorporate material from a 39 * header file that is part of the Library. You may convey such object code 40 * under terms of your choice, provided that, if the incorporated material 41 * is not limited to numerical parameters, data structure layouts and 42 * accessors, or small macros, inline functions and templates (ten or fewer 43 * lines in length), you do both of the following: [...]" 44 * 45 * The code below is indeed limited to data structure layouts. 46 */ 47 48 /* 49 * Copyright (C) 1996-2016 Free Software Foundation, Inc. 50 * This file is part of the GNU C Library. 51 * Contributed by David Mosberger <davidm@cs.arizona.edu>. 52 * 53 * The GNU C Library is free software; you can redistribute it and/or 54 * modify it under the terms of the GNU Lesser General Public 55 * License as published by the Free Software Foundation; either 56 * version 2.1 of the License, or (at your option) any later version. 57 * 58 * The GNU C Library is distributed in the hope that it will be useful, 59 * but WITHOUT ANY WARRANTY; without even the implied warranty of 60 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 61 * Lesser General Public License for more details. 62 * 63 * You should have received a copy of the GNU Lesser General Public 64 * License along with the GNU C Library; if not, see 65 * <http://www.gnu.org/licenses/>. 66 */ 67 68 /* 69 * This file specifies the format of gmon.out files. It should have 70 * as few external dependencies as possible as it is going to be included 71 * in many different programs. That is, minimize the number of #include's. 72 * 73 * A gmon.out file consists of a header (defined by gmon_hdr) followed by 74 * a sequence of records. Each record starts with a one-byte tag 75 * identifying the type of records, followed by records specific data. 76 */ 77 78 #ifndef GMON_OUT_H 79 #define GMON_OUT_H 80 81 #define GMON_MAGIC "gmon" /* magic cookie */ 82 #define GMON_VERSION 1 /* version number */ 83 84 /* 85 * Raw header as it appears on file (without padding). This header 86 * always comes first in gmon.out and is then followed by a series 87 * records defined below. 88 * Virtual addresses are stored as uintptr_t, gprof knows which size to expect 89 * because the executable file is provided. 90 */ 91 struct gmon_hdr { 92 char cookie[4]; 93 int32_t version; 94 char spare[3 * 4]; 95 } __packed; 96 97 /* types of records in this file: */ 98 enum gmon_record_tag { 99 GMON_TAG_TIME_HIST = 0, 100 GMON_TAG_CG_ARC = 1, 101 GMON_TAG_BB_COUNT = 2 102 }; 103 104 struct gmon_hist_hdr { 105 uintptr_t low_pc; /* base pc address of sample buffer */ 106 uintptr_t high_pc; /* max pc address of sampled buffer */ 107 uint32_t hist_size; /* size of sample buffer */ 108 uint32_t prof_rate; /* profiling clock rate */ 109 char dimen[15]; /* phys. dim., usually "seconds" */ 110 char dimen_abbrev; /* usually 's' for "seconds" */ 111 } __packed; 112 113 struct gmon_cg_arc_record { 114 uintptr_t from_pc; /* address within caller's body */ 115 uintptr_t self_pc; /* address within callee's body */ 116 int32_t count; /* number of arc traversals */ 117 } __packed; 118 119 #endif /* GMON_OUT_H */ 120