1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1990-1998 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SGS_GPROF_H 28*7c478bd9Sstevel@tonic-gate #define _SGS_GPROF_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <stdio.h> 37*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 38*7c478bd9Sstevel@tonic-gate #include <string.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 41*7c478bd9Sstevel@tonic-gate #include <fcntl.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/mman.h> 43*7c478bd9Sstevel@tonic-gate #include <elf.h> 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #include "sparc.h" 46*7c478bd9Sstevel@tonic-gate #include "gelf.h" 47*7c478bd9Sstevel@tonic-gate #include "monv.h" 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate /* 51*7c478bd9Sstevel@tonic-gate * who am i, for error messages. 52*7c478bd9Sstevel@tonic-gate */ 53*7c478bd9Sstevel@tonic-gate extern char *whoami; 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate /* 56*7c478bd9Sstevel@tonic-gate * booleans 57*7c478bd9Sstevel@tonic-gate */ 58*7c478bd9Sstevel@tonic-gate typedef int bool; 59*7c478bd9Sstevel@tonic-gate #define FALSE 0 60*7c478bd9Sstevel@tonic-gate #define TRUE 1 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate /* 63*7c478bd9Sstevel@tonic-gate * Alignment related constants 64*7c478bd9Sstevel@tonic-gate */ 65*7c478bd9Sstevel@tonic-gate #define PGSZ 4096 66*7c478bd9Sstevel@tonic-gate #define STRUCT_ALIGN 8 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* 69*7c478bd9Sstevel@tonic-gate * Macros related to structure alignment 70*7c478bd9Sstevel@tonic-gate */ 71*7c478bd9Sstevel@tonic-gate #define FLOOR(x, align) (((Address) x) & ~((align) - 1l)) 72*7c478bd9Sstevel@tonic-gate #define CEIL(x, align) FLOOR(((Address) x) + (align) - 1l, align) 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate #define PROFHDR_SZ (CEIL(sizeof (ProfHeader), STRUCT_ALIGN)) 75*7c478bd9Sstevel@tonic-gate #define PROFMODLIST_SZ (CEIL(sizeof (ProfModuleList), STRUCT_ALIGN)) 76*7c478bd9Sstevel@tonic-gate #define PROFMOD_SZ (CEIL(sizeof (ProfModule), STRUCT_ALIGN)) 77*7c478bd9Sstevel@tonic-gate #define PROFBUF_SZ (CEIL(sizeof (ProfBuffer), STRUCT_ALIGN)) 78*7c478bd9Sstevel@tonic-gate #define PROFCGRAPH_SZ (CEIL(sizeof (ProfCallGraph), STRUCT_ALIGN)) 79*7c478bd9Sstevel@tonic-gate #define PROFFUNC_SZ (CEIL(sizeof (ProfFunction), STRUCT_ALIGN)) 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate #define HDR_FILLER (PROFHDR_SZ - sizeof (ProfHeader)) 82*7c478bd9Sstevel@tonic-gate #define MODLIST_FILLER (PROFMODLIST_SZ - sizeof (ProfModuleList)) 83*7c478bd9Sstevel@tonic-gate #define MOD_FILLER (PROFMOD_SZ - sizeof (ProfModule)) 84*7c478bd9Sstevel@tonic-gate #define BUF_FILLER (PROFBUF_SZ - sizeof (ProfBuffer)) 85*7c478bd9Sstevel@tonic-gate #define CGRAPH_FILLER (PROFCGRAPH_SZ - sizeof (ProfCallGraph)) 86*7c478bd9Sstevel@tonic-gate #define FUNC_FILLER (PROFFUNC_SZ - sizeof (ProfFunction)) 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* 89*7c478bd9Sstevel@tonic-gate * ticks per second 90*7c478bd9Sstevel@tonic-gate */ 91*7c478bd9Sstevel@tonic-gate long hz; 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate typedef short UNIT; /* unit of profiling */ 94*7c478bd9Sstevel@tonic-gate typedef unsigned short unsigned_UNIT; /* to remove warnings from gprof.c */ 95*7c478bd9Sstevel@tonic-gate char *a_outname; 96*7c478bd9Sstevel@tonic-gate char *prog_name; /* keep the program name for error messages */ 97*7c478bd9Sstevel@tonic-gate #define A_OUTNAME "a.out" 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate typedef unsigned long long pctype; 100*7c478bd9Sstevel@tonic-gate typedef uint32_t pctype32; 101*7c478bd9Sstevel@tonic-gate typedef size_t sztype; 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate /* 104*7c478bd9Sstevel@tonic-gate * Type definition for the arc count. 105*7c478bd9Sstevel@tonic-gate */ 106*7c478bd9Sstevel@tonic-gate typedef long long actype; 107*7c478bd9Sstevel@tonic-gate typedef int32_t actype32; 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate char *gmonname; 110*7c478bd9Sstevel@tonic-gate #define GMONNAME "gmon.out" 111*7c478bd9Sstevel@tonic-gate #define GMONSUM "gmon.sum" 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate /* 114*7c478bd9Sstevel@tonic-gate * Special symbols used for profiling of shared libraries through 115*7c478bd9Sstevel@tonic-gate * the run-time linker. 116*7c478bd9Sstevel@tonic-gate */ 117*7c478bd9Sstevel@tonic-gate #define PRF_ETEXT "_etext" 118*7c478bd9Sstevel@tonic-gate #define PRF_EXTSYM "<external>" 119*7c478bd9Sstevel@tonic-gate #define PRF_MEMTERM "_END_OF_VIRTUAL_MEMORY" 120*7c478bd9Sstevel@tonic-gate #define PRF_SYMCNT 3 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate /* 123*7c478bd9Sstevel@tonic-gate * Special symbol needed to determine the program exec's end addr. 124*7c478bd9Sstevel@tonic-gate * Note that since this symbol doesn't get added to the nameslist, 125*7c478bd9Sstevel@tonic-gate * it doesn't have to be counted in PRF_SYMCNT 126*7c478bd9Sstevel@tonic-gate */ 127*7c478bd9Sstevel@tonic-gate #define PRF_END "_end" 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate /* 130*7c478bd9Sstevel@tonic-gate * blurbs on the flat and graph profiles. 131*7c478bd9Sstevel@tonic-gate */ 132*7c478bd9Sstevel@tonic-gate #define FLAT_BLURB "/gprof.flat.blurb" 133*7c478bd9Sstevel@tonic-gate #define CALLG_BLURB "/gprof.callg.blurb" 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate /* 136*7c478bd9Sstevel@tonic-gate * a raw arc, 137*7c478bd9Sstevel@tonic-gate * with pointers to the calling site and the called site 138*7c478bd9Sstevel@tonic-gate * and a count. 139*7c478bd9Sstevel@tonic-gate */ 140*7c478bd9Sstevel@tonic-gate struct rawarc { 141*7c478bd9Sstevel@tonic-gate pctype raw_frompc; 142*7c478bd9Sstevel@tonic-gate pctype raw_selfpc; 143*7c478bd9Sstevel@tonic-gate actype raw_count; 144*7c478bd9Sstevel@tonic-gate }; 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate struct rawarc32 { 147*7c478bd9Sstevel@tonic-gate pctype32 raw_frompc; 148*7c478bd9Sstevel@tonic-gate pctype32 raw_selfpc; 149*7c478bd9Sstevel@tonic-gate actype32 raw_count; 150*7c478bd9Sstevel@tonic-gate }; 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate /* 153*7c478bd9Sstevel@tonic-gate * a constructed arc, 154*7c478bd9Sstevel@tonic-gate * with pointers to the namelist entry of the parent and the child, 155*7c478bd9Sstevel@tonic-gate * a count of how many times this arc was traversed, 156*7c478bd9Sstevel@tonic-gate * and pointers to the next parent of this child and 157*7c478bd9Sstevel@tonic-gate * the next child of this parent. 158*7c478bd9Sstevel@tonic-gate */ 159*7c478bd9Sstevel@tonic-gate struct arcstruct { 160*7c478bd9Sstevel@tonic-gate struct nl *arc_parentp; /* pointer to parent's nl entry */ 161*7c478bd9Sstevel@tonic-gate struct nl *arc_childp; /* pointer to child's nl entry */ 162*7c478bd9Sstevel@tonic-gate actype arc_count; /* how calls from parent to child */ 163*7c478bd9Sstevel@tonic-gate double arc_time; /* time inherited along arc */ 164*7c478bd9Sstevel@tonic-gate double arc_childtime; /* childtime inherited along arc */ 165*7c478bd9Sstevel@tonic-gate struct arcstruct *arc_parentlist; /* parents-of-this-child list */ 166*7c478bd9Sstevel@tonic-gate struct arcstruct *arc_childlist; /* children-of-this-parent list */ 167*7c478bd9Sstevel@tonic-gate }; 168*7c478bd9Sstevel@tonic-gate typedef struct arcstruct arctype; 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate /* 172*7c478bd9Sstevel@tonic-gate * Additions for new-style gmon.out 173*7c478bd9Sstevel@tonic-gate */ 174*7c478bd9Sstevel@tonic-gate bool old_style; /* gmon.out versioned/non-versioned ? */ 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate /* 177*7c478bd9Sstevel@tonic-gate * Executable file info. 178*7c478bd9Sstevel@tonic-gate * 179*7c478bd9Sstevel@tonic-gate * All info that is required to identify a file or see if it has changed 180*7c478bd9Sstevel@tonic-gate * relative to another file. 181*7c478bd9Sstevel@tonic-gate */ 182*7c478bd9Sstevel@tonic-gate struct fl_info { 183*7c478bd9Sstevel@tonic-gate dev_t dev; /* device associated with this file */ 184*7c478bd9Sstevel@tonic-gate ino_t ino; /* i-number of this file */ 185*7c478bd9Sstevel@tonic-gate time_t mtime; /* last modified time of this file */ 186*7c478bd9Sstevel@tonic-gate off_t size; /* size of file */ 187*7c478bd9Sstevel@tonic-gate }; 188*7c478bd9Sstevel@tonic-gate typedef struct fl_info fl_info_t; 189*7c478bd9Sstevel@tonic-gate 190*7c478bd9Sstevel@tonic-gate /* 191*7c478bd9Sstevel@tonic-gate * Saved file info. 192*7c478bd9Sstevel@tonic-gate */ 193*7c478bd9Sstevel@tonic-gate fl_info_t aout_info; /* saved file info for program exec */ 194*7c478bd9Sstevel@tonic-gate fl_info_t gmonout_info; /* current gmonout's info */ 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate /* 198*7c478bd9Sstevel@tonic-gate * Module info. 199*7c478bd9Sstevel@tonic-gate */ 200*7c478bd9Sstevel@tonic-gate struct mod_info { 201*7c478bd9Sstevel@tonic-gate struct mod_info *next; /* ptr to next in the modules list */ 202*7c478bd9Sstevel@tonic-gate char *name; /* name of this module */ 203*7c478bd9Sstevel@tonic-gate int id; /* id, used while printing */ 204*7c478bd9Sstevel@tonic-gate bool active; /* is this module active or not ? */ 205*7c478bd9Sstevel@tonic-gate struct nl *nl; /* ptr to nameslist for this module */ 206*7c478bd9Sstevel@tonic-gate struct nl *npe; /* virtual end of module's namelist */ 207*7c478bd9Sstevel@tonic-gate sztype nname; /* number of funcs in this module */ 208*7c478bd9Sstevel@tonic-gate GElf_Addr txt_origin; /* module's start as given in file */ 209*7c478bd9Sstevel@tonic-gate GElf_Addr data_end; /* module's end addr as in file */ 210*7c478bd9Sstevel@tonic-gate Address load_base; /* actual pcaddr where modl's loaded */ 211*7c478bd9Sstevel@tonic-gate Address load_end; /* actual pcaddr where modl ends */ 212*7c478bd9Sstevel@tonic-gate }; 213*7c478bd9Sstevel@tonic-gate typedef struct mod_info mod_info_t; 214*7c478bd9Sstevel@tonic-gate 215*7c478bd9Sstevel@tonic-gate sztype total_names; /* from all modules */ 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate /* 218*7c478bd9Sstevel@tonic-gate * List of shared object modules. Note that this always includes the 219*7c478bd9Sstevel@tonic-gate * program executable as the first element. 220*7c478bd9Sstevel@tonic-gate */ 221*7c478bd9Sstevel@tonic-gate mod_info_t modules; 222*7c478bd9Sstevel@tonic-gate sztype n_modules; 223*7c478bd9Sstevel@tonic-gate 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate /* 227*7c478bd9Sstevel@tonic-gate * The symbol table; 228*7c478bd9Sstevel@tonic-gate * for each external in the specified file we gather 229*7c478bd9Sstevel@tonic-gate * its address, the number of calls and compute its share of cpu time. 230*7c478bd9Sstevel@tonic-gate */ 231*7c478bd9Sstevel@tonic-gate struct nl { 232*7c478bd9Sstevel@tonic-gate char *name; /* the name */ 233*7c478bd9Sstevel@tonic-gate mod_info_t *module; /* module to which this belongs */ 234*7c478bd9Sstevel@tonic-gate pctype value; /* the pc entry point */ 235*7c478bd9Sstevel@tonic-gate pctype svalue; /* entry point aligned to histograms */ 236*7c478bd9Sstevel@tonic-gate unsigned long sz; /* function size */ 237*7c478bd9Sstevel@tonic-gate unsigned char syminfo; /* sym info */ 238*7c478bd9Sstevel@tonic-gate size_t nticks; /* ticks in this routine */ 239*7c478bd9Sstevel@tonic-gate double time; /* ticks in this routine as double */ 240*7c478bd9Sstevel@tonic-gate double childtime; /* cumulative ticks in children */ 241*7c478bd9Sstevel@tonic-gate actype ncall; /* how many times called */ 242*7c478bd9Sstevel@tonic-gate actype selfcalls; /* how many calls to self */ 243*7c478bd9Sstevel@tonic-gate double propfraction; /* what % of time propagates */ 244*7c478bd9Sstevel@tonic-gate double propself; /* how much self time propagates */ 245*7c478bd9Sstevel@tonic-gate double propchild; /* how much child time propagates */ 246*7c478bd9Sstevel@tonic-gate bool printflag; /* should this be printed? */ 247*7c478bd9Sstevel@tonic-gate int index; /* index in the graph list */ 248*7c478bd9Sstevel@tonic-gate int toporder; /* graph call chain top-sort order */ 249*7c478bd9Sstevel@tonic-gate int cycleno; /* internal number of cycle on */ 250*7c478bd9Sstevel@tonic-gate struct nl *cyclehead; /* pointer to head of cycle */ 251*7c478bd9Sstevel@tonic-gate struct nl *cnext; /* pointer to next member of cycle */ 252*7c478bd9Sstevel@tonic-gate arctype *parents; /* list of caller arcs */ 253*7c478bd9Sstevel@tonic-gate arctype *children; /* list of callee arcs */ 254*7c478bd9Sstevel@tonic-gate unsigned long ncallers; /* no. of callers - dumpsum use only */ 255*7c478bd9Sstevel@tonic-gate }; 256*7c478bd9Sstevel@tonic-gate typedef struct nl nltype; 257*7c478bd9Sstevel@tonic-gate 258*7c478bd9Sstevel@tonic-gate /* 259*7c478bd9Sstevel@tonic-gate * flag which marks a nl entry as topologically ``busy'' 260*7c478bd9Sstevel@tonic-gate * flag which marks a nl entry as topologically ``not_numbered'' 261*7c478bd9Sstevel@tonic-gate */ 262*7c478bd9Sstevel@tonic-gate #define DFN_BUSY -1 263*7c478bd9Sstevel@tonic-gate #define DFN_NAN 0 264*7c478bd9Sstevel@tonic-gate 265*7c478bd9Sstevel@tonic-gate /* 266*7c478bd9Sstevel@tonic-gate * namelist entries for cycle headers. 267*7c478bd9Sstevel@tonic-gate * the number of discovered cycles. 268*7c478bd9Sstevel@tonic-gate */ 269*7c478bd9Sstevel@tonic-gate nltype *cyclenl; /* cycle header namelist */ 270*7c478bd9Sstevel@tonic-gate int ncycle; /* number of cycles discovered */ 271*7c478bd9Sstevel@tonic-gate 272*7c478bd9Sstevel@tonic-gate /* 273*7c478bd9Sstevel@tonic-gate * The header on the gmon.out file. 274*7c478bd9Sstevel@tonic-gate * old-style gmon.out consists of one of these headers, 275*7c478bd9Sstevel@tonic-gate * and then an array of ncnt samples 276*7c478bd9Sstevel@tonic-gate * representing the discretized program counter values. 277*7c478bd9Sstevel@tonic-gate * this should be a struct phdr, but since everything is done 278*7c478bd9Sstevel@tonic-gate * as UNITs, this is in UNITs too. 279*7c478bd9Sstevel@tonic-gate */ 280*7c478bd9Sstevel@tonic-gate struct hdr { 281*7c478bd9Sstevel@tonic-gate pctype lowpc; 282*7c478bd9Sstevel@tonic-gate pctype highpc; 283*7c478bd9Sstevel@tonic-gate pctype ncnt; 284*7c478bd9Sstevel@tonic-gate }; 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate struct hdr32 { 287*7c478bd9Sstevel@tonic-gate pctype32 lowpc; 288*7c478bd9Sstevel@tonic-gate pctype32 highpc; 289*7c478bd9Sstevel@tonic-gate pctype32 ncnt; 290*7c478bd9Sstevel@tonic-gate }; 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate struct hdr h; /* header of profiled data */ 293*7c478bd9Sstevel@tonic-gate 294*7c478bd9Sstevel@tonic-gate int debug; 295*7c478bd9Sstevel@tonic-gate int number_funcs_toprint; 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate /* 298*7c478bd9Sstevel@tonic-gate * Each discretized pc sample has 299*7c478bd9Sstevel@tonic-gate * a count of the number of samples in its range 300*7c478bd9Sstevel@tonic-gate */ 301*7c478bd9Sstevel@tonic-gate unsigned short *samples; 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate pctype s_lowpc; /* lowpc from profile file in o-s gmon.out */ 304*7c478bd9Sstevel@tonic-gate pctype s_highpc; /* highpc from profile file in o-s gmon.out */ 305*7c478bd9Sstevel@tonic-gate sztype sampbytes; /* number of bytes of samples in o-s gmon.out */ 306*7c478bd9Sstevel@tonic-gate sztype nsamples; /* number of samples for old-style gmon.out */ 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate double actime; /* accumulated time thus far for putprofline */ 309*7c478bd9Sstevel@tonic-gate double totime; /* total time for all routines */ 310*7c478bd9Sstevel@tonic-gate double printtime; /* total of time being printed */ 311*7c478bd9Sstevel@tonic-gate double scale; /* scale factor converting samples to pc */ 312*7c478bd9Sstevel@tonic-gate /* values: each sample covers scale bytes */ 313*7c478bd9Sstevel@tonic-gate /* -- all this is for old-style gmon.out only */ 314*7c478bd9Sstevel@tonic-gate 315*7c478bd9Sstevel@tonic-gate off_t ssiz; /* size of the string table */ 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate unsigned char *textspace; /* text space of a.out in core */ 318*7c478bd9Sstevel@tonic-gate bool first_file; /* for difference option */ 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate /* 321*7c478bd9Sstevel@tonic-gate * Total number of pcsamples read so far (across gmon.out's) 322*7c478bd9Sstevel@tonic-gate */ 323*7c478bd9Sstevel@tonic-gate Size n_pcsamples; 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate /* 326*7c478bd9Sstevel@tonic-gate * option flags, from a to z. 327*7c478bd9Sstevel@tonic-gate */ 328*7c478bd9Sstevel@tonic-gate bool aflag; /* suppress static functions */ 329*7c478bd9Sstevel@tonic-gate bool bflag; /* blurbs, too */ 330*7c478bd9Sstevel@tonic-gate bool Bflag; /* big pc's (i.e. 64 bits) */ 331*7c478bd9Sstevel@tonic-gate bool cflag; /* discovered call graph, too */ 332*7c478bd9Sstevel@tonic-gate bool Cflag; /* gprofing c++ -- need demangling */ 333*7c478bd9Sstevel@tonic-gate bool dflag; /* debugging options */ 334*7c478bd9Sstevel@tonic-gate bool Dflag; /* difference option */ 335*7c478bd9Sstevel@tonic-gate bool eflag; /* specific functions excluded */ 336*7c478bd9Sstevel@tonic-gate bool Eflag; /* functions excluded with time */ 337*7c478bd9Sstevel@tonic-gate bool fflag; /* specific functions requested */ 338*7c478bd9Sstevel@tonic-gate bool Fflag; /* functions requested with time */ 339*7c478bd9Sstevel@tonic-gate bool lflag; /* exclude LOCAL syms in output */ 340*7c478bd9Sstevel@tonic-gate bool sflag; /* sum multiple gmon.out files */ 341*7c478bd9Sstevel@tonic-gate bool zflag; /* zero time/called functions, too */ 342*7c478bd9Sstevel@tonic-gate bool nflag; /* print only n functions in report */ 343*7c478bd9Sstevel@tonic-gate bool rflag; /* profiling input generated by */ 344*7c478bd9Sstevel@tonic-gate /* run-time linker */ 345*7c478bd9Sstevel@tonic-gate 346*7c478bd9Sstevel@tonic-gate 347*7c478bd9Sstevel@tonic-gate /* 348*7c478bd9Sstevel@tonic-gate * structure for various string lists 349*7c478bd9Sstevel@tonic-gate */ 350*7c478bd9Sstevel@tonic-gate struct stringlist { 351*7c478bd9Sstevel@tonic-gate struct stringlist *next; 352*7c478bd9Sstevel@tonic-gate char *string; 353*7c478bd9Sstevel@tonic-gate }; 354*7c478bd9Sstevel@tonic-gate extern struct stringlist *elist; 355*7c478bd9Sstevel@tonic-gate extern struct stringlist *Elist; 356*7c478bd9Sstevel@tonic-gate extern struct stringlist *flist; 357*7c478bd9Sstevel@tonic-gate extern struct stringlist *Flist; 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate /* 360*7c478bd9Sstevel@tonic-gate * function declarations 361*7c478bd9Sstevel@tonic-gate */ 362*7c478bd9Sstevel@tonic-gate void addlist(struct stringlist *, char *); 363*7c478bd9Sstevel@tonic-gate void addarc(nltype *, nltype *, actype); 364*7c478bd9Sstevel@tonic-gate int arccmp(arctype *, arctype *); 365*7c478bd9Sstevel@tonic-gate arctype *arclookup(nltype *, nltype *); 366*7c478bd9Sstevel@tonic-gate void printblurb(char *); 367*7c478bd9Sstevel@tonic-gate void dfn(nltype *); 368*7c478bd9Sstevel@tonic-gate bool dfn_busy(nltype *); 369*7c478bd9Sstevel@tonic-gate void dfn_findcycle(nltype *); 370*7c478bd9Sstevel@tonic-gate bool dfn_numbered(nltype *); 371*7c478bd9Sstevel@tonic-gate void dfn_post_visit(nltype *); 372*7c478bd9Sstevel@tonic-gate void dfn_pre_visit(nltype *); 373*7c478bd9Sstevel@tonic-gate void dfn_self_cycle(nltype *); 374*7c478bd9Sstevel@tonic-gate nltype **doarcs(void); 375*7c478bd9Sstevel@tonic-gate void done(); 376*7c478bd9Sstevel@tonic-gate void findcalls(nltype *, pctype, pctype); 377*7c478bd9Sstevel@tonic-gate void flatprofheader(void); 378*7c478bd9Sstevel@tonic-gate void flatprofline(nltype *); 379*7c478bd9Sstevel@tonic-gate bool is_shared_obj(char *); 380*7c478bd9Sstevel@tonic-gate void getnfile(char *); 381*7c478bd9Sstevel@tonic-gate void process_namelist(mod_info_t *); 382*7c478bd9Sstevel@tonic-gate void gprofheader(void); 383*7c478bd9Sstevel@tonic-gate void gprofline(nltype *); 384*7c478bd9Sstevel@tonic-gate int pc_cmp(Address *, Address *); 385*7c478bd9Sstevel@tonic-gate int main(); 386*7c478bd9Sstevel@tonic-gate int membercmp(nltype *, nltype *); 387*7c478bd9Sstevel@tonic-gate nltype *nllookup(mod_info_t *, pctype, pctype *); 388*7c478bd9Sstevel@tonic-gate bool onlist(struct stringlist *, char *); 389*7c478bd9Sstevel@tonic-gate void printchildren(nltype *); 390*7c478bd9Sstevel@tonic-gate void printcycle(nltype *); 391*7c478bd9Sstevel@tonic-gate void printgprof(nltype **); 392*7c478bd9Sstevel@tonic-gate void printindex(void); 393*7c478bd9Sstevel@tonic-gate void printmembers(nltype *); 394*7c478bd9Sstevel@tonic-gate void printmodules(void); 395*7c478bd9Sstevel@tonic-gate void printname(nltype *); 396*7c478bd9Sstevel@tonic-gate void printparents(nltype *); 397*7c478bd9Sstevel@tonic-gate void printprof(void); 398*7c478bd9Sstevel@tonic-gate void sortchildren(nltype *); 399*7c478bd9Sstevel@tonic-gate void sortmembers(nltype *); 400*7c478bd9Sstevel@tonic-gate void sortparents(nltype *); 401*7c478bd9Sstevel@tonic-gate int timecmp(nltype **, nltype **); 402*7c478bd9Sstevel@tonic-gate int totalcmp(nltype **, nltype **); 403*7c478bd9Sstevel@tonic-gate 404*7c478bd9Sstevel@tonic-gate #define LESSTHAN -1 405*7c478bd9Sstevel@tonic-gate #define EQUALTO 0 406*7c478bd9Sstevel@tonic-gate #define GREATERTHAN 1 407*7c478bd9Sstevel@tonic-gate 408*7c478bd9Sstevel@tonic-gate /* 409*7c478bd9Sstevel@tonic-gate * Macros related to debug messages. 410*7c478bd9Sstevel@tonic-gate */ 411*7c478bd9Sstevel@tonic-gate #define DFNDEBUG 0x0001 412*7c478bd9Sstevel@tonic-gate #define CYCLEDEBUG 0x0002 413*7c478bd9Sstevel@tonic-gate #define ARCDEBUG 0x0004 414*7c478bd9Sstevel@tonic-gate #define TALLYDEBUG 0x0008 415*7c478bd9Sstevel@tonic-gate #define TIMEDEBUG 0x0010 416*7c478bd9Sstevel@tonic-gate #define SAMPLEDEBUG 0x0020 417*7c478bd9Sstevel@tonic-gate #define ELFDEBUG 0x0040 418*7c478bd9Sstevel@tonic-gate #define CALLSDEBUG 0x0080 419*7c478bd9Sstevel@tonic-gate #define LOOKUPDEBUG 0x0100 420*7c478bd9Sstevel@tonic-gate #define PROPDEBUG 0x0200 421*7c478bd9Sstevel@tonic-gate #define ANYDEBUG 0x0400 422*7c478bd9Sstevel@tonic-gate 423*7c478bd9Sstevel@tonic-gate #define MONOUTDEBUG 0x0800 424*7c478bd9Sstevel@tonic-gate #define MODULEDEBUG 0x1000 425*7c478bd9Sstevel@tonic-gate #define CGRAPHDEBUG 0x2000 426*7c478bd9Sstevel@tonic-gate #define PCSMPLDEBUG 0x4000 427*7c478bd9Sstevel@tonic-gate 428*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 429*7c478bd9Sstevel@tonic-gate } 430*7c478bd9Sstevel@tonic-gate #endif 431*7c478bd9Sstevel@tonic-gate 432*7c478bd9Sstevel@tonic-gate #endif /* _SGS_GPROF_H */ 433