dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / sgs / prof / common / profv.h
blob11e997584d368293945c43a4a7252007c20ccfd1
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SGS_PROFV_H
28 #define _SGS_PROFV_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Header file for processing versioned, *new-style* mon.out files.
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 #include <stdio.h>
41 #include <sys/types.h>
42 #include <sys/mman.h>
43 #include <sys/stat.h>
44 #include <fcntl.h>
45 #include <unistd.h>
46 #include <sys/elf.h>
47 #include "gelf.h"
48 #include "monv.h"
49 #include "_machelf.h"
52 * Booleans.
54 typedef int bool;
56 #define TRUE 1
57 #define FALSE 0
60 * Bit macro and flag bit definitions. These and the sort_flags below,
61 * need to be always in sync with the set in prof.c
63 extern int flags;
65 #define F_SORT 0x1
66 #define F_VERBOSE 0x2
67 #define F_ZSYMS 0x4
68 #define F_PADDR 0x8
69 #define F_NHEAD 0x10
72 * Sort flags. Mutually exclusive.
74 extern unsigned char sort_flag;
76 #define BY_ADDRESS 0x1
77 #define BY_NCALLS 0x2
78 #define BY_NAME 0x4
79 #define BY_TIME 0x8
82 * Error codes
84 #define ERR_SYSCALL 1
85 #define ERR_INPUT 2
86 #define ERR_ELF 3
87 #define ERR_MEMORY 4
90 * Other useful macros.
92 #define BUCKET_SZ 4096
93 #define PRF_END "_end"
95 extern int gflag, Cflag;
96 extern char *atitle, *aformat,
97 *cmdname, *sym_fn, *mon_fn;
100 * Module info.
102 struct mod_info {
103 char *path; /* pathname of module */
104 int id; /* id (used while printing) */
105 bool active; /* is this module active or not ? */
106 Address load_base; /* base addr where module is loaded */
107 Address load_end; /* end addr of loaded module */
108 GElf_Addr txt_origin; /* txt start as given in PHT */
109 GElf_Addr data_end; /* data end as found from `_end' */
110 struct nl *nl; /* ptr to module's namelist */
111 size_t nfuncs; /* number of functions in `nl' */
112 struct mod_info *next; /* link to next module */
114 typedef struct mod_info mod_info_t;
117 * List of shared objects. Note that this always includes the program
118 * executable as the first element.
120 extern mod_info_t modules;
121 extern size_t n_modules;
124 * The symbol table.
126 struct nl {
127 char *name; /* name of the symbol */
128 GElf_Addr value; /* value of the symbol */
129 unsigned char info; /* symbol's bind/type info */
130 GElf_Xword size; /* size of the symbol */
131 size_t ncalls; /* number of calls to this func */
132 size_t nticks; /* number of ticks spent here */
134 typedef struct nl nltype;
137 * The profile output record. There is some duplication of fields from
138 * the namelist, but the profsym contains just the symbols we're going
139 * to print, and that makes a lot of things easier.
141 struct profrec {
142 GElf_Addr addr; /* symbol value */
143 double percent_time; /* percentage time spent here */
144 double seconds; /* time spent here in seconds */
145 size_t ncalls; /* calls to this function */
146 double msecs_per_call; /* milliseconds per call */
147 char *demangled_name; /* demangled name if C++ */
148 bool print_mid; /* print module id ? */
149 char *name; /* bookkeeping, not printed */
150 mod_info_t *module; /* bookkeeping, not printed */
152 typedef struct profrec profrec_t;
153 extern profrec_t *profsym;
156 * Names in profile output need to be sorted to figure out if there'll
157 * be any duplicate names in the output.
159 struct profnames {
160 char *name;
161 profrec_t *pfrec;
163 typedef struct profnames profnames_t;
166 * File status.
168 extern struct stat aout_stat, monout_stat;
171 * Timing related externs.
173 extern bool time_in_ticks;
174 extern size_t n_pcsamples, n_accounted_ticks, n_zeros, total_funcs;
175 extern double total_time;
178 * Other declarations
180 extern void profver(void);
181 extern nltype *nllookup(mod_info_t *, Address, Address *);
182 extern Address *locate(Address *, size_t, Address);
183 extern void get_syms(char *, mod_info_t *);
184 extern int cmp_by_address(const void *arg1, const void *arg2);
185 extern bool is_shared_obj(char *);
187 #ifdef __cplusplus
189 #endif
191 #endif /* _SGS_PROFV_H */