xref: /titanic_52/usr/src/cmd/sgs/gprof/common/gprof.h (revision 672986541be54a7a471bb088e60780c37e371d7e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*67298654Sdamico  * Common Development and Distribution License (the "License").
6*67298654Sdamico  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
2192ed1782Smike_s 
227c478bd9Sstevel@tonic-gate /*
23*67298654Sdamico  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
2492ed1782Smike_s  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SGS_GPROF_H
287c478bd9Sstevel@tonic-gate #define	_SGS_GPROF_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <stdio.h>
377c478bd9Sstevel@tonic-gate #include <stdlib.h>
387c478bd9Sstevel@tonic-gate #include <string.h>
397c478bd9Sstevel@tonic-gate #include <sys/types.h>
407c478bd9Sstevel@tonic-gate #include <sys/stat.h>
417c478bd9Sstevel@tonic-gate #include <fcntl.h>
427c478bd9Sstevel@tonic-gate #include <sys/mman.h>
437c478bd9Sstevel@tonic-gate #include <elf.h>
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #include "sparc.h"
467c478bd9Sstevel@tonic-gate #include "gelf.h"
477c478bd9Sstevel@tonic-gate #include "monv.h"
4892ed1782Smike_s #include "sgs.h"
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate  * who am i, for error messages.
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate extern char	*whoami;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * booleans
587c478bd9Sstevel@tonic-gate  */
5992ed1782Smike_s typedef Boolean	bool;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * Alignment related constants
637c478bd9Sstevel@tonic-gate  */
647c478bd9Sstevel@tonic-gate #define	PGSZ		4096
657c478bd9Sstevel@tonic-gate #define	STRUCT_ALIGN	8
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * Macros related to structure alignment
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate #define	FLOOR(x, align)	(((Address) x) & ~((align) - 1l))
717c478bd9Sstevel@tonic-gate #define	CEIL(x, align)	FLOOR(((Address) x) + (align) - 1l, align)
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate #define	PROFHDR_SZ	(CEIL(sizeof (ProfHeader), STRUCT_ALIGN))
747c478bd9Sstevel@tonic-gate #define	PROFMODLIST_SZ	(CEIL(sizeof (ProfModuleList), STRUCT_ALIGN))
757c478bd9Sstevel@tonic-gate #define	PROFMOD_SZ	(CEIL(sizeof (ProfModule), STRUCT_ALIGN))
767c478bd9Sstevel@tonic-gate #define	PROFBUF_SZ	(CEIL(sizeof (ProfBuffer), STRUCT_ALIGN))
777c478bd9Sstevel@tonic-gate #define	PROFCGRAPH_SZ	(CEIL(sizeof (ProfCallGraph), STRUCT_ALIGN))
787c478bd9Sstevel@tonic-gate #define	PROFFUNC_SZ	(CEIL(sizeof (ProfFunction), STRUCT_ALIGN))
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #define	HDR_FILLER	(PROFHDR_SZ - sizeof (ProfHeader))
817c478bd9Sstevel@tonic-gate #define	MODLIST_FILLER	(PROFMODLIST_SZ - sizeof (ProfModuleList))
827c478bd9Sstevel@tonic-gate #define	MOD_FILLER	(PROFMOD_SZ - sizeof (ProfModule))
837c478bd9Sstevel@tonic-gate #define	BUF_FILLER	(PROFBUF_SZ - sizeof (ProfBuffer))
847c478bd9Sstevel@tonic-gate #define	CGRAPH_FILLER	(PROFCGRAPH_SZ - sizeof (ProfCallGraph))
857c478bd9Sstevel@tonic-gate #define	FUNC_FILLER	(PROFFUNC_SZ - sizeof (ProfFunction))
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  *	ticks per second
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate long	hz;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate typedef	short UNIT;		/* unit of profiling */
937c478bd9Sstevel@tonic-gate typedef unsigned short	unsigned_UNIT; /* to remove warnings from gprof.c */
947c478bd9Sstevel@tonic-gate char	*a_outname;
957c478bd9Sstevel@tonic-gate char	*prog_name;	/* keep the program name for error messages */
967c478bd9Sstevel@tonic-gate #define	A_OUTNAME		"a.out"
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate typedef unsigned long long pctype;
997c478bd9Sstevel@tonic-gate typedef uint32_t pctype32;
1007c478bd9Sstevel@tonic-gate typedef size_t sztype;
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * Type definition for the arc count.
1047c478bd9Sstevel@tonic-gate  */
1057c478bd9Sstevel@tonic-gate typedef long long actype;
1067c478bd9Sstevel@tonic-gate typedef int32_t actype32;
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate char	*gmonname;
1097c478bd9Sstevel@tonic-gate #define	GMONNAME		"gmon.out"
1107c478bd9Sstevel@tonic-gate #define	GMONSUM			"gmon.sum"
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /*
1137c478bd9Sstevel@tonic-gate  * Special symbols used for profiling of shared libraries through
1147c478bd9Sstevel@tonic-gate  * the run-time linker.
1157c478bd9Sstevel@tonic-gate  */
1167c478bd9Sstevel@tonic-gate #define	PRF_ETEXT		"_etext"
1177c478bd9Sstevel@tonic-gate #define	PRF_EXTSYM		"<external>"
1187c478bd9Sstevel@tonic-gate #define	PRF_MEMTERM		"_END_OF_VIRTUAL_MEMORY"
1197c478bd9Sstevel@tonic-gate #define	PRF_SYMCNT		3
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * Special symbol needed to determine the program exec's end addr.
1237c478bd9Sstevel@tonic-gate  * Note that since this symbol doesn't get added to the nameslist,
1247c478bd9Sstevel@tonic-gate  * it doesn't have to be counted in PRF_SYMCNT
1257c478bd9Sstevel@tonic-gate  */
1267c478bd9Sstevel@tonic-gate #define	PRF_END			"_end"
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate /*
1297c478bd9Sstevel@tonic-gate  *	blurbs on the flat and graph profiles.
1307c478bd9Sstevel@tonic-gate  */
131*67298654Sdamico #define	FLAT_BLURB	"/usr/share/lib/ccs/gprof.flat.blurb"
132*67298654Sdamico #define	CALLG_BLURB	"/usr/share/lib/ccs/gprof.callg.blurb"
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate /*
1357c478bd9Sstevel@tonic-gate  *	a raw arc,
1367c478bd9Sstevel@tonic-gate  *	    with pointers to the calling site and the called site
1377c478bd9Sstevel@tonic-gate  *          and a count.
1387c478bd9Sstevel@tonic-gate  */
1397c478bd9Sstevel@tonic-gate struct rawarc {
1407c478bd9Sstevel@tonic-gate 	pctype		raw_frompc;
1417c478bd9Sstevel@tonic-gate 	pctype		raw_selfpc;
1427c478bd9Sstevel@tonic-gate 	actype		raw_count;
1437c478bd9Sstevel@tonic-gate };
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate struct rawarc32 {
1467c478bd9Sstevel@tonic-gate 	pctype32	raw_frompc;
1477c478bd9Sstevel@tonic-gate 	pctype32	raw_selfpc;
1487c478bd9Sstevel@tonic-gate 	actype32	raw_count;
1497c478bd9Sstevel@tonic-gate };
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  *	a constructed arc,
1537c478bd9Sstevel@tonic-gate  *	    with pointers to the namelist entry of the parent and the child,
1547c478bd9Sstevel@tonic-gate  *	    a count of how many times this arc was traversed,
1557c478bd9Sstevel@tonic-gate  *	    and pointers to the next parent of this child and
1567c478bd9Sstevel@tonic-gate  *	    the next child of this parent.
1577c478bd9Sstevel@tonic-gate  */
1587c478bd9Sstevel@tonic-gate struct arcstruct {
1597c478bd9Sstevel@tonic-gate     struct nl		*arc_parentp;	/* pointer to parent's nl entry */
1607c478bd9Sstevel@tonic-gate     struct nl		*arc_childp;	/* pointer to child's nl entry */
1617c478bd9Sstevel@tonic-gate     actype		arc_count;	/* how calls from parent to child */
1627c478bd9Sstevel@tonic-gate     double		arc_time;	/* time inherited along arc */
1637c478bd9Sstevel@tonic-gate     double		arc_childtime;	/* childtime inherited along arc */
1647c478bd9Sstevel@tonic-gate     struct arcstruct	*arc_parentlist; /* parents-of-this-child list */
1657c478bd9Sstevel@tonic-gate     struct arcstruct	*arc_childlist;	/* children-of-this-parent list */
1667c478bd9Sstevel@tonic-gate };
1677c478bd9Sstevel@tonic-gate typedef struct arcstruct	arctype;
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate /*
1717c478bd9Sstevel@tonic-gate  * Additions for new-style gmon.out
1727c478bd9Sstevel@tonic-gate  */
1737c478bd9Sstevel@tonic-gate bool	old_style;			/* gmon.out versioned/non-versioned ? */
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate /*
1767c478bd9Sstevel@tonic-gate  * Executable file info.
1777c478bd9Sstevel@tonic-gate  *
1787c478bd9Sstevel@tonic-gate  * All info that is required to identify a file or see if it has changed
1797c478bd9Sstevel@tonic-gate  * relative to another file.
1807c478bd9Sstevel@tonic-gate  */
1817c478bd9Sstevel@tonic-gate struct fl_info {
1827c478bd9Sstevel@tonic-gate 	dev_t	dev;			/* device associated with this file */
1837c478bd9Sstevel@tonic-gate 	ino_t	ino;			/* i-number of this file */
1847c478bd9Sstevel@tonic-gate 	time_t	mtime;			/* last modified time of this file */
1857c478bd9Sstevel@tonic-gate 	off_t	size;			/* size of file */
1867c478bd9Sstevel@tonic-gate };
1877c478bd9Sstevel@tonic-gate typedef struct fl_info	fl_info_t;
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate /*
1907c478bd9Sstevel@tonic-gate  * Saved file info.
1917c478bd9Sstevel@tonic-gate  */
1927c478bd9Sstevel@tonic-gate fl_info_t	aout_info;		/* saved file info for program exec */
1937c478bd9Sstevel@tonic-gate fl_info_t	gmonout_info;		/* current gmonout's info */
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate /*
1977c478bd9Sstevel@tonic-gate  * Module info.
1987c478bd9Sstevel@tonic-gate  */
1997c478bd9Sstevel@tonic-gate struct mod_info {
2007c478bd9Sstevel@tonic-gate 	struct mod_info	*next;		/* ptr to next in the modules list */
2017c478bd9Sstevel@tonic-gate 	char		*name;		/* name of this module */
2027c478bd9Sstevel@tonic-gate 	int		id;		/* id, used while printing */
2037c478bd9Sstevel@tonic-gate 	bool		active;		/* is this module active or not ? */
2047c478bd9Sstevel@tonic-gate 	struct nl	*nl;		/* ptr to nameslist for this module */
2057c478bd9Sstevel@tonic-gate 	struct nl	*npe;		/* virtual end of module's namelist */
2067c478bd9Sstevel@tonic-gate 	sztype		nname;		/* number of funcs in this module */
2077c478bd9Sstevel@tonic-gate 	GElf_Addr	txt_origin;	/* module's start as given in file */
2087c478bd9Sstevel@tonic-gate 	GElf_Addr	data_end;	/* module's end addr as in file */
2097c478bd9Sstevel@tonic-gate 	Address		load_base;	/* actual pcaddr where modl's loaded */
2107c478bd9Sstevel@tonic-gate 	Address		load_end;	/* actual pcaddr where modl ends */
2117c478bd9Sstevel@tonic-gate };
2127c478bd9Sstevel@tonic-gate typedef struct mod_info	mod_info_t;
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate sztype		total_names;	/* from all modules */
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate /*
2177c478bd9Sstevel@tonic-gate  * List of shared object modules. Note that this always includes the
2187c478bd9Sstevel@tonic-gate  * program executable as the first element.
2197c478bd9Sstevel@tonic-gate  */
2207c478bd9Sstevel@tonic-gate mod_info_t	modules;
2217c478bd9Sstevel@tonic-gate sztype		n_modules;
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate /*
2267c478bd9Sstevel@tonic-gate  * The symbol table;
2277c478bd9Sstevel@tonic-gate  * for each external in the specified file we gather
2287c478bd9Sstevel@tonic-gate  * its address, the number of calls and compute its share of cpu time.
2297c478bd9Sstevel@tonic-gate  */
2307c478bd9Sstevel@tonic-gate struct nl {
2317c478bd9Sstevel@tonic-gate     char		*name;		/* the name */
2327c478bd9Sstevel@tonic-gate     mod_info_t		*module;	/* module to which this belongs */
2337c478bd9Sstevel@tonic-gate     pctype		value;		/* the pc entry point */
2347c478bd9Sstevel@tonic-gate     pctype		svalue;		/* entry point aligned to histograms */
2357c478bd9Sstevel@tonic-gate     unsigned long	sz;		/* function size */
2367c478bd9Sstevel@tonic-gate     unsigned char	syminfo;	/* sym info */
2377c478bd9Sstevel@tonic-gate     size_t		nticks;		/* ticks in this routine */
2387c478bd9Sstevel@tonic-gate     double		time;		/* ticks in this routine as double */
2397c478bd9Sstevel@tonic-gate     double		childtime;	/* cumulative ticks in children */
2407c478bd9Sstevel@tonic-gate     actype		ncall;		/* how many times called */
2417c478bd9Sstevel@tonic-gate     actype		selfcalls;	/* how many calls to self */
2427c478bd9Sstevel@tonic-gate     double		propfraction;	/* what % of time propagates */
2437c478bd9Sstevel@tonic-gate     double		propself;	/* how much self time propagates */
2447c478bd9Sstevel@tonic-gate     double		propchild;	/* how much child time propagates */
2457c478bd9Sstevel@tonic-gate     bool		printflag;	/* should this be printed? */
2467c478bd9Sstevel@tonic-gate     int			index;		/* index in the graph list */
2477c478bd9Sstevel@tonic-gate     int			toporder;	/* graph call chain top-sort order */
2487c478bd9Sstevel@tonic-gate     int			cycleno;	/* internal number of cycle on */
2497c478bd9Sstevel@tonic-gate     struct nl		*cyclehead;	/* pointer to head of cycle */
2507c478bd9Sstevel@tonic-gate     struct nl		*cnext;		/* pointer to next member of cycle */
2517c478bd9Sstevel@tonic-gate     arctype		*parents;	/* list of caller arcs */
2527c478bd9Sstevel@tonic-gate     arctype		*children;	/* list of callee arcs */
2537c478bd9Sstevel@tonic-gate     unsigned long	ncallers;	/* no. of callers - dumpsum use only */
2547c478bd9Sstevel@tonic-gate };
2557c478bd9Sstevel@tonic-gate typedef struct nl	nltype;
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate /*
2587c478bd9Sstevel@tonic-gate  *	flag which marks a nl entry as topologically ``busy''
2597c478bd9Sstevel@tonic-gate  *	flag which marks a nl entry as topologically ``not_numbered''
2607c478bd9Sstevel@tonic-gate  */
2617c478bd9Sstevel@tonic-gate #define	DFN_BUSY	-1
2627c478bd9Sstevel@tonic-gate #define	DFN_NAN		0
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate /*
2657c478bd9Sstevel@tonic-gate  *	namelist entries for cycle headers.
2667c478bd9Sstevel@tonic-gate  *	the number of discovered cycles.
2677c478bd9Sstevel@tonic-gate  */
2687c478bd9Sstevel@tonic-gate nltype	*cyclenl;		/* cycle header namelist */
2697c478bd9Sstevel@tonic-gate int	ncycle;			/* number of cycles discovered */
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate /*
2727c478bd9Sstevel@tonic-gate  * The header on the gmon.out file.
2737c478bd9Sstevel@tonic-gate  * old-style gmon.out consists of one of these headers,
2747c478bd9Sstevel@tonic-gate  * and then an array of ncnt samples
2757c478bd9Sstevel@tonic-gate  * representing the discretized program counter values.
2767c478bd9Sstevel@tonic-gate  *	this should be a struct phdr, but since everything is done
2777c478bd9Sstevel@tonic-gate  *	as UNITs, this is in UNITs too.
2787c478bd9Sstevel@tonic-gate  */
2797c478bd9Sstevel@tonic-gate struct hdr {
2807c478bd9Sstevel@tonic-gate 	pctype		lowpc;
2817c478bd9Sstevel@tonic-gate 	pctype		highpc;
2827c478bd9Sstevel@tonic-gate 	pctype		ncnt;
2837c478bd9Sstevel@tonic-gate };
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate struct hdr32 {
2867c478bd9Sstevel@tonic-gate 	pctype32	lowpc;
2877c478bd9Sstevel@tonic-gate 	pctype32	highpc;
2887c478bd9Sstevel@tonic-gate 	pctype32	ncnt;
2897c478bd9Sstevel@tonic-gate };
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate struct hdr	h;		/* header of profiled data */
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate int	debug;
2947c478bd9Sstevel@tonic-gate int 	number_funcs_toprint;
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate /*
2977c478bd9Sstevel@tonic-gate  * Each discretized pc sample has
2987c478bd9Sstevel@tonic-gate  * a count of the number of samples in its range
2997c478bd9Sstevel@tonic-gate  */
3007c478bd9Sstevel@tonic-gate unsigned short	*samples;
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate pctype	s_lowpc;		/* lowpc from profile file in o-s gmon.out */
3037c478bd9Sstevel@tonic-gate pctype	s_highpc;		/* highpc from profile file in o-s gmon.out */
3047c478bd9Sstevel@tonic-gate sztype	sampbytes;		/* number of bytes of samples in o-s gmon.out */
3057c478bd9Sstevel@tonic-gate sztype	nsamples;		/* number of samples for old-style gmon.out */
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate double	actime;			/* accumulated time thus far for putprofline */
3087c478bd9Sstevel@tonic-gate double	totime;			/* total time for all routines */
3097c478bd9Sstevel@tonic-gate double	printtime;		/* total of time being printed */
3107c478bd9Sstevel@tonic-gate double	scale;			/* scale factor converting samples to pc */
3117c478bd9Sstevel@tonic-gate 				/* values: each sample covers scale bytes */
3127c478bd9Sstevel@tonic-gate 				/* -- all this is for old-style gmon.out only */
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate unsigned char	*textspace;		/* text space of a.out in core */
3157c478bd9Sstevel@tonic-gate bool	first_file;			/* for difference option */
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate /*
3187c478bd9Sstevel@tonic-gate  * Total number of pcsamples read so far (across gmon.out's)
3197c478bd9Sstevel@tonic-gate  */
3207c478bd9Sstevel@tonic-gate Size	n_pcsamples;
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate /*
3237c478bd9Sstevel@tonic-gate  *	option flags, from a to z.
3247c478bd9Sstevel@tonic-gate  */
3257c478bd9Sstevel@tonic-gate bool	aflag;				/* suppress static functions */
3267c478bd9Sstevel@tonic-gate bool	bflag;				/* blurbs, too */
3277c478bd9Sstevel@tonic-gate bool	Bflag;				/* big pc's (i.e. 64 bits) */
3287c478bd9Sstevel@tonic-gate bool	cflag;				/* discovered call graph, too */
3297c478bd9Sstevel@tonic-gate bool	Cflag;				/* gprofing c++ -- need demangling */
3307c478bd9Sstevel@tonic-gate bool	dflag;				/* debugging options */
3317c478bd9Sstevel@tonic-gate bool	Dflag;				/* difference option */
3327c478bd9Sstevel@tonic-gate bool	eflag;				/* specific functions excluded */
3337c478bd9Sstevel@tonic-gate bool	Eflag;				/* functions excluded with time */
3347c478bd9Sstevel@tonic-gate bool	fflag;				/* specific functions requested */
3357c478bd9Sstevel@tonic-gate bool	Fflag;				/* functions requested with time */
3367c478bd9Sstevel@tonic-gate bool	lflag;				/* exclude LOCAL syms in output */
3377c478bd9Sstevel@tonic-gate bool	sflag;				/* sum multiple gmon.out files */
3387c478bd9Sstevel@tonic-gate bool	zflag;				/* zero time/called functions, too */
3397c478bd9Sstevel@tonic-gate bool 	nflag;				/* print only n functions in report */
3407c478bd9Sstevel@tonic-gate bool	rflag;				/* profiling input generated by */
3417c478bd9Sstevel@tonic-gate 					/* run-time linker */
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate /*
3457c478bd9Sstevel@tonic-gate  *	structure for various string lists
3467c478bd9Sstevel@tonic-gate  */
3477c478bd9Sstevel@tonic-gate struct stringlist {
3487c478bd9Sstevel@tonic-gate     struct stringlist	*next;
3497c478bd9Sstevel@tonic-gate     char		*string;
3507c478bd9Sstevel@tonic-gate };
3517c478bd9Sstevel@tonic-gate extern struct stringlist	*elist;
3527c478bd9Sstevel@tonic-gate extern struct stringlist	*Elist;
3537c478bd9Sstevel@tonic-gate extern struct stringlist	*flist;
3547c478bd9Sstevel@tonic-gate extern struct stringlist	*Flist;
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate /*
3577c478bd9Sstevel@tonic-gate  *	function declarations
3587c478bd9Sstevel@tonic-gate  */
3597c478bd9Sstevel@tonic-gate void	addlist(struct stringlist *, char *);
3607c478bd9Sstevel@tonic-gate void	addarc(nltype *, nltype *, actype);
3617c478bd9Sstevel@tonic-gate int	arccmp(arctype *, arctype *);
3627c478bd9Sstevel@tonic-gate arctype	*arclookup(nltype *, nltype *);
3637c478bd9Sstevel@tonic-gate void	printblurb(char *);
3647c478bd9Sstevel@tonic-gate void	dfn(nltype *);
3657c478bd9Sstevel@tonic-gate bool	dfn_busy(nltype *);
3667c478bd9Sstevel@tonic-gate void	dfn_findcycle(nltype *);
3677c478bd9Sstevel@tonic-gate bool	dfn_numbered(nltype *);
3687c478bd9Sstevel@tonic-gate void	dfn_post_visit(nltype *);
3697c478bd9Sstevel@tonic-gate void	dfn_pre_visit(nltype *);
3707c478bd9Sstevel@tonic-gate void	dfn_self_cycle(nltype *);
3717c478bd9Sstevel@tonic-gate nltype	**doarcs(void);
37292ed1782Smike_s void	done(void);
3737c478bd9Sstevel@tonic-gate void	findcalls(nltype *, pctype, pctype);
3747c478bd9Sstevel@tonic-gate void	flatprofheader(void);
3757c478bd9Sstevel@tonic-gate void	flatprofline(nltype *);
3767c478bd9Sstevel@tonic-gate bool	is_shared_obj(char *);
3777c478bd9Sstevel@tonic-gate void	getnfile(char *);
3787c478bd9Sstevel@tonic-gate void	process_namelist(mod_info_t *);
3797c478bd9Sstevel@tonic-gate void	gprofheader(void);
3807c478bd9Sstevel@tonic-gate void	gprofline(nltype *);
38192ed1782Smike_s int	pc_cmp(const void *arg1, const void *arg2);
3827c478bd9Sstevel@tonic-gate int	membercmp(nltype *, nltype *);
3837c478bd9Sstevel@tonic-gate nltype	*nllookup(mod_info_t *, pctype, pctype *);
3847c478bd9Sstevel@tonic-gate bool	onlist(struct stringlist *, char *);
3857c478bd9Sstevel@tonic-gate void	printchildren(nltype *);
3867c478bd9Sstevel@tonic-gate void	printcycle(nltype *);
3877c478bd9Sstevel@tonic-gate void	printgprof(nltype **);
3887c478bd9Sstevel@tonic-gate void	printindex(void);
3897c478bd9Sstevel@tonic-gate void	printmembers(nltype *);
3907c478bd9Sstevel@tonic-gate void	printmodules(void);
3917c478bd9Sstevel@tonic-gate void	printname(nltype *);
3927c478bd9Sstevel@tonic-gate void	printparents(nltype *);
3937c478bd9Sstevel@tonic-gate void	printprof(void);
3947c478bd9Sstevel@tonic-gate void	sortchildren(nltype *);
3957c478bd9Sstevel@tonic-gate void	sortmembers(nltype *);
3967c478bd9Sstevel@tonic-gate void	sortparents(nltype *);
39792ed1782Smike_s int	timecmp(const void *arg1, const void *arg2);
39892ed1782Smike_s int	totalcmp(const void *arg1, const void *arg2);
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate #define	LESSTHAN	-1
4017c478bd9Sstevel@tonic-gate #define	EQUALTO		0
4027c478bd9Sstevel@tonic-gate #define	GREATERTHAN	1
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate /*
4057c478bd9Sstevel@tonic-gate  * Macros related to debug messages.
4067c478bd9Sstevel@tonic-gate  */
4077c478bd9Sstevel@tonic-gate #define	DFNDEBUG	0x0001
4087c478bd9Sstevel@tonic-gate #define	CYCLEDEBUG	0x0002
4097c478bd9Sstevel@tonic-gate #define	ARCDEBUG	0x0004
4107c478bd9Sstevel@tonic-gate #define	TALLYDEBUG	0x0008
4117c478bd9Sstevel@tonic-gate #define	TIMEDEBUG	0x0010
4127c478bd9Sstevel@tonic-gate #define	SAMPLEDEBUG	0x0020
4137c478bd9Sstevel@tonic-gate #define	ELFDEBUG	0x0040
4147c478bd9Sstevel@tonic-gate #define	CALLSDEBUG	0x0080
4157c478bd9Sstevel@tonic-gate #define	LOOKUPDEBUG	0x0100
4167c478bd9Sstevel@tonic-gate #define	PROPDEBUG	0x0200
4177c478bd9Sstevel@tonic-gate #define	ANYDEBUG	0x0400
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate #define	MONOUTDEBUG	0x0800
4207c478bd9Sstevel@tonic-gate #define	MODULEDEBUG	0x1000
4217c478bd9Sstevel@tonic-gate #define	CGRAPHDEBUG	0x2000
4227c478bd9Sstevel@tonic-gate #define	PCSMPLDEBUG	0x4000
4237c478bd9Sstevel@tonic-gate 
4247c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4257c478bd9Sstevel@tonic-gate }
4267c478bd9Sstevel@tonic-gate #endif
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate #endif	/* _SGS_GPROF_H */
429