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