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