xref: /optee_os/lib/libutee/arch/arm/gprof/gmon_out.h (revision 1bb929836182ecb96d2d9d268daa807c67596396)
1*1bb92983SJerome Forissier /* SPDX-License-Identifier: BSD-2-Clause */
2883c4be3SJerome Forissier /*
3883c4be3SJerome Forissier  * Copyright (c) 2016, Linaro Limited
4883c4be3SJerome Forissier  * All rights reserved.
5883c4be3SJerome Forissier  *
6883c4be3SJerome Forissier  * Redistribution and use in source and binary forms, with or without
7883c4be3SJerome Forissier  * modification, are permitted provided that the following conditions are met:
8883c4be3SJerome Forissier  *
9883c4be3SJerome Forissier  * 1. Redistributions of source code must retain the above copyright notice,
10883c4be3SJerome Forissier  * this list of conditions and the following disclaimer.
11883c4be3SJerome Forissier  *
12883c4be3SJerome Forissier  * 2. Redistributions in binary form must reproduce the above copyright notice,
13883c4be3SJerome Forissier  * this list of conditions and the following disclaimer in the documentation
14883c4be3SJerome Forissier  * and/or other materials provided with the distribution.
15883c4be3SJerome Forissier  *
16883c4be3SJerome Forissier  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17883c4be3SJerome Forissier  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18883c4be3SJerome Forissier  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19883c4be3SJerome Forissier  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20883c4be3SJerome Forissier  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21883c4be3SJerome Forissier  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22883c4be3SJerome Forissier  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23883c4be3SJerome Forissier  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24883c4be3SJerome Forissier  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25883c4be3SJerome Forissier  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26883c4be3SJerome Forissier  * POSSIBILITY OF SUCH DAMAGE.
27883c4be3SJerome Forissier  */
28883c4be3SJerome Forissier 
29883c4be3SJerome Forissier /*
30883c4be3SJerome Forissier  * gmon.out file format
31883c4be3SJerome Forissier  *
32883c4be3SJerome Forissier  * This file is adapted from glibc's gmon/sys/gmon_out.h
33883c4be3SJerome Forissier  * Although gmon/sys/gmon_out.h is covered by the LGPL v2.1 license or later
34883c4be3SJerome Forissier  * as stated below, please note the following:
35883c4be3SJerome Forissier  * (https://www.gnu.org/licenses/lgpl-3.0.en.html#section3)
36883c4be3SJerome Forissier  *
37883c4be3SJerome Forissier  * "3. Object Code Incorporating Material from Library Header Files.
38883c4be3SJerome Forissier  *  The object code form of an Application may incorporate material from a
39883c4be3SJerome Forissier  *  header file that is part of the Library. You may convey such object code
40883c4be3SJerome Forissier  *  under terms of your choice, provided that, if the incorporated material
41883c4be3SJerome Forissier  *  is not limited to numerical parameters, data structure layouts and
42883c4be3SJerome Forissier  *  accessors, or small macros, inline functions and templates (ten or fewer
43883c4be3SJerome Forissier  *  lines in length), you do both of the following: [...]"
44883c4be3SJerome Forissier  *
45883c4be3SJerome Forissier  * The code below is indeed limited to data structure layouts.
46883c4be3SJerome Forissier  */
47883c4be3SJerome Forissier 
48883c4be3SJerome Forissier /*
49883c4be3SJerome Forissier  * Copyright (C) 1996-2016 Free Software Foundation, Inc.
50883c4be3SJerome Forissier  * This file is part of the GNU C Library.
51883c4be3SJerome Forissier  * Contributed by David Mosberger <davidm@cs.arizona.edu>.
52883c4be3SJerome Forissier  *
53883c4be3SJerome Forissier  * The GNU C Library is free software; you can redistribute it and/or
54883c4be3SJerome Forissier  * modify it under the terms of the GNU Lesser General Public
55883c4be3SJerome Forissier  * License as published by the Free Software Foundation; either
56883c4be3SJerome Forissier  * version 2.1 of the License, or (at your option) any later version.
57883c4be3SJerome Forissier  *
58883c4be3SJerome Forissier  * The GNU C Library is distributed in the hope that it will be useful,
59883c4be3SJerome Forissier  * but WITHOUT ANY WARRANTY; without even the implied warranty of
60883c4be3SJerome Forissier  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
61883c4be3SJerome Forissier  * Lesser General Public License for more details.
62883c4be3SJerome Forissier  *
63883c4be3SJerome Forissier  * You should have received a copy of the GNU Lesser General Public
64883c4be3SJerome Forissier  * License along with the GNU C Library; if not, see
65883c4be3SJerome Forissier  * <http://www.gnu.org/licenses/>.
66883c4be3SJerome Forissier  */
67883c4be3SJerome Forissier 
68883c4be3SJerome Forissier /*
69883c4be3SJerome Forissier  * This file specifies the format of gmon.out files.  It should have
70883c4be3SJerome Forissier  * as few external dependencies as possible as it is going to be included
71883c4be3SJerome Forissier  * in many different programs.  That is, minimize the number of #include's.
72883c4be3SJerome Forissier  *
73883c4be3SJerome Forissier  * A gmon.out file consists of a header (defined by gmon_hdr) followed by
74883c4be3SJerome Forissier  * a sequence of records.  Each record starts with a one-byte tag
75883c4be3SJerome Forissier  * identifying the type of records, followed by records specific data.
76883c4be3SJerome Forissier  */
77883c4be3SJerome Forissier 
78883c4be3SJerome Forissier #ifndef GMON_OUT_H
79883c4be3SJerome Forissier #define GMON_OUT_H
80883c4be3SJerome Forissier 
81883c4be3SJerome Forissier #define	GMON_MAGIC	"gmon"	/* magic cookie */
82883c4be3SJerome Forissier #define GMON_VERSION	1	/* version number */
83883c4be3SJerome Forissier 
84883c4be3SJerome Forissier /*
85883c4be3SJerome Forissier  * Raw header as it appears on file (without padding).  This header
86883c4be3SJerome Forissier  * always comes first in gmon.out and is then followed by a series
87883c4be3SJerome Forissier  * records defined below.
88883c4be3SJerome Forissier  * Virtual addresses are stored as uintptr_t, gprof knows which size to expect
89883c4be3SJerome Forissier  * because the executable file is provided.
90883c4be3SJerome Forissier  */
91883c4be3SJerome Forissier struct gmon_hdr {
92883c4be3SJerome Forissier 	char cookie[4];
93883c4be3SJerome Forissier 	int32_t version;
94883c4be3SJerome Forissier 	char spare[3 * 4];
95883c4be3SJerome Forissier } __packed;
96883c4be3SJerome Forissier 
97883c4be3SJerome Forissier /* types of records in this file: */
98883c4be3SJerome Forissier enum gmon_record_tag {
99883c4be3SJerome Forissier 	GMON_TAG_TIME_HIST = 0,
100883c4be3SJerome Forissier 	GMON_TAG_CG_ARC = 1,
101883c4be3SJerome Forissier 	GMON_TAG_BB_COUNT = 2
102883c4be3SJerome Forissier };
103883c4be3SJerome Forissier 
104883c4be3SJerome Forissier struct gmon_hist_hdr {
105883c4be3SJerome Forissier 	uintptr_t low_pc;	/* base pc address of sample buffer */
106883c4be3SJerome Forissier 	uintptr_t high_pc;	/* max pc address of sampled buffer */
107883c4be3SJerome Forissier 	uint32_t hist_size;	/* size of sample buffer */
108883c4be3SJerome Forissier 	uint32_t prof_rate;	/* profiling clock rate */
109883c4be3SJerome Forissier 	char dimen[15];		/* phys. dim., usually "seconds" */
110883c4be3SJerome Forissier 	char dimen_abbrev;	/* usually 's' for "seconds" */
111883c4be3SJerome Forissier } __packed;
112883c4be3SJerome Forissier 
113883c4be3SJerome Forissier struct gmon_cg_arc_record {
114883c4be3SJerome Forissier 	uintptr_t from_pc;	/* address within caller's body */
115883c4be3SJerome Forissier 	uintptr_t self_pc;	/* address within callee's body */
116883c4be3SJerome Forissier 	int32_t count;		/* number of arc traversals */
117883c4be3SJerome Forissier } __packed;
118883c4be3SJerome Forissier 
119883c4be3SJerome Forissier #endif /* GMON_OUT_H */
120