xref: /illumos-gate/usr/src/cmd/sgs/gprof/common/gprof.h (revision 14448871)
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
567298654Sdamico  * Common Development and Distribution License (the "License").
667298654Sdamico  * 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 /*
2367298654Sdamico  * 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 #ifdef	__cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <stdio.h>
357c478bd9Sstevel@tonic-gate #include <stdlib.h>
367c478bd9Sstevel@tonic-gate #include <string.h>
377c478bd9Sstevel@tonic-gate #include <sys/types.h>
387c478bd9Sstevel@tonic-gate #include <sys/stat.h>
397c478bd9Sstevel@tonic-gate #include <fcntl.h>
407c478bd9Sstevel@tonic-gate #include <sys/mman.h>
417c478bd9Sstevel@tonic-gate #include <elf.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #include "sparc.h"
447c478bd9Sstevel@tonic-gate #include "gelf.h"
457c478bd9Sstevel@tonic-gate #include "monv.h"
4692ed1782Smike_s #include "sgs.h"
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * who am i, for error messages.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate extern char	*whoami;
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * booleans
567c478bd9Sstevel@tonic-gate  */
5792ed1782Smike_s typedef Boolean	bool;
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /*
607c478bd9Sstevel@tonic-gate  * Alignment related constants
617c478bd9Sstevel@tonic-gate  */
627c478bd9Sstevel@tonic-gate #define	PGSZ		4096
637c478bd9Sstevel@tonic-gate #define	STRUCT_ALIGN	8
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate /*
667c478bd9Sstevel@tonic-gate  * Macros related to structure alignment
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate #define	FLOOR(x, align)	(((Address) x) & ~((align) - 1l))
697c478bd9Sstevel@tonic-gate #define	CEIL(x, align)	FLOOR(((Address) x) + (align) - 1l, align)
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #define	PROFHDR_SZ	(CEIL(sizeof (ProfHeader), STRUCT_ALIGN))
727c478bd9Sstevel@tonic-gate #define	PROFMODLIST_SZ	(CEIL(sizeof (ProfModuleList), STRUCT_ALIGN))
737c478bd9Sstevel@tonic-gate #define	PROFMOD_SZ	(CEIL(sizeof (ProfModule), STRUCT_ALIGN))
747c478bd9Sstevel@tonic-gate #define	PROFBUF_SZ	(CEIL(sizeof (ProfBuffer), STRUCT_ALIGN))
757c478bd9Sstevel@tonic-gate #define	PROFCGRAPH_SZ	(CEIL(sizeof (ProfCallGraph), STRUCT_ALIGN))
767c478bd9Sstevel@tonic-gate #define	PROFFUNC_SZ	(CEIL(sizeof (ProfFunction), STRUCT_ALIGN))
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate #define	HDR_FILLER	(PROFHDR_SZ - sizeof (ProfHeader))
797c478bd9Sstevel@tonic-gate #define	MODLIST_FILLER	(PROFMODLIST_SZ - sizeof (ProfModuleList))
807c478bd9Sstevel@tonic-gate #define	MOD_FILLER	(PROFMOD_SZ - sizeof (ProfModule))
817c478bd9Sstevel@tonic-gate #define	BUF_FILLER	(PROFBUF_SZ - sizeof (ProfBuffer))
827c478bd9Sstevel@tonic-gate #define	CGRAPH_FILLER	(PROFCGRAPH_SZ - sizeof (ProfCallGraph))
837c478bd9Sstevel@tonic-gate #define	FUNC_FILLER	(PROFFUNC_SZ - sizeof (ProfFunction))
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate  *	ticks per second
877c478bd9Sstevel@tonic-gate  */
88*14448871SToomas Soome extern long	hz;
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate typedef	short UNIT;		/* unit of profiling */
917c478bd9Sstevel@tonic-gate typedef unsigned short	unsigned_UNIT; /* to remove warnings from gprof.c */
92*14448871SToomas Soome extern char	*a_outname;
93*14448871SToomas Soome extern char	*prog_name;	/* keep the program name for error messages */
947c478bd9Sstevel@tonic-gate #define	A_OUTNAME		"a.out"
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate typedef unsigned long long pctype;
977c478bd9Sstevel@tonic-gate typedef uint32_t pctype32;
987c478bd9Sstevel@tonic-gate typedef size_t sztype;
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * Type definition for the arc count.
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate typedef long long actype;
1047c478bd9Sstevel@tonic-gate typedef int32_t actype32;
1057c478bd9Sstevel@tonic-gate 
106*14448871SToomas Soome extern char	*gmonname;
1077c478bd9Sstevel@tonic-gate #define	GMONNAME		"gmon.out"
1087c478bd9Sstevel@tonic-gate #define	GMONSUM			"gmon.sum"
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * Special symbols used for profiling of shared libraries through
1127c478bd9Sstevel@tonic-gate  * the run-time linker.
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate #define	PRF_ETEXT		"_etext"
1157c478bd9Sstevel@tonic-gate #define	PRF_EXTSYM		"<external>"
1167c478bd9Sstevel@tonic-gate #define	PRF_MEMTERM		"_END_OF_VIRTUAL_MEMORY"
1177c478bd9Sstevel@tonic-gate #define	PRF_SYMCNT		3
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate  * Special symbol needed to determine the program exec's end addr.
1217c478bd9Sstevel@tonic-gate  * Note that since this symbol doesn't get added to the nameslist,
1227c478bd9Sstevel@tonic-gate  * it doesn't have to be counted in PRF_SYMCNT
1237c478bd9Sstevel@tonic-gate  */
1247c478bd9Sstevel@tonic-gate #define	PRF_END			"_end"
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate /*
1277c478bd9Sstevel@tonic-gate  *	blurbs on the flat and graph profiles.
1287c478bd9Sstevel@tonic-gate  */
12967298654Sdamico #define	FLAT_BLURB	"/usr/share/lib/ccs/gprof.flat.blurb"
13067298654Sdamico #define	CALLG_BLURB	"/usr/share/lib/ccs/gprof.callg.blurb"
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate /*
1337c478bd9Sstevel@tonic-gate  *	a raw arc,
1347c478bd9Sstevel@tonic-gate  *	    with pointers to the calling site and the called site
1357c478bd9Sstevel@tonic-gate  *          and a count.
1367c478bd9Sstevel@tonic-gate  */
1377c478bd9Sstevel@tonic-gate struct rawarc {
1387c478bd9Sstevel@tonic-gate 	pctype		raw_frompc;
1397c478bd9Sstevel@tonic-gate 	pctype		raw_selfpc;
1407c478bd9Sstevel@tonic-gate 	actype		raw_count;
1417c478bd9Sstevel@tonic-gate };
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate struct rawarc32 {
1447c478bd9Sstevel@tonic-gate 	pctype32	raw_frompc;
1457c478bd9Sstevel@tonic-gate 	pctype32	raw_selfpc;
1467c478bd9Sstevel@tonic-gate 	actype32	raw_count;
1477c478bd9Sstevel@tonic-gate };
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate  *	a constructed arc,
1517c478bd9Sstevel@tonic-gate  *	    with pointers to the namelist entry of the parent and the child,
1527c478bd9Sstevel@tonic-gate  *	    a count of how many times this arc was traversed,
1537c478bd9Sstevel@tonic-gate  *	    and pointers to the next parent of this child and
1547c478bd9Sstevel@tonic-gate  *	    the next child of this parent.
1557c478bd9Sstevel@tonic-gate  */
1567c478bd9Sstevel@tonic-gate struct arcstruct {
1577c478bd9Sstevel@tonic-gate     struct nl		*arc_parentp;	/* pointer to parent's nl entry */
1587c478bd9Sstevel@tonic-gate     struct nl		*arc_childp;	/* pointer to child's nl entry */
1597c478bd9Sstevel@tonic-gate     actype		arc_count;	/* how calls from parent to child */
1607c478bd9Sstevel@tonic-gate     double		arc_time;	/* time inherited along arc */
1617c478bd9Sstevel@tonic-gate     double		arc_childtime;	/* childtime inherited along arc */
1627c478bd9Sstevel@tonic-gate     struct arcstruct	*arc_parentlist; /* parents-of-this-child list */
1637c478bd9Sstevel@tonic-gate     struct arcstruct	*arc_childlist;	/* children-of-this-parent list */
1647c478bd9Sstevel@tonic-gate };
1657c478bd9Sstevel@tonic-gate typedef struct arcstruct	arctype;
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate /*
1697c478bd9Sstevel@tonic-gate  * Additions for new-style gmon.out
1707c478bd9Sstevel@tonic-gate  */
171*14448871SToomas Soome extern bool	old_style;		/* gmon.out versioned/non-versioned ? */
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate /*
1747c478bd9Sstevel@tonic-gate  * Executable file info.
1757c478bd9Sstevel@tonic-gate  *
1767c478bd9Sstevel@tonic-gate  * All info that is required to identify a file or see if it has changed
1777c478bd9Sstevel@tonic-gate  * relative to another file.
1787c478bd9Sstevel@tonic-gate  */
1797c478bd9Sstevel@tonic-gate struct fl_info {
1807c478bd9Sstevel@tonic-gate 	dev_t	dev;			/* device associated with this file */
1817c478bd9Sstevel@tonic-gate 	ino_t	ino;			/* i-number of this file */
1827c478bd9Sstevel@tonic-gate 	time_t	mtime;			/* last modified time of this file */
1837c478bd9Sstevel@tonic-gate 	off_t	size;			/* size of file */
1847c478bd9Sstevel@tonic-gate };
1857c478bd9Sstevel@tonic-gate typedef struct fl_info	fl_info_t;
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate /*
1887c478bd9Sstevel@tonic-gate  * Saved file info.
1897c478bd9Sstevel@tonic-gate  */
190*14448871SToomas Soome extern fl_info_t	aout_info;	/* saved file info for program exec */
191*14448871SToomas Soome extern fl_info_t	gmonout_info;	/* current gmonout's info */
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate /*
1957c478bd9Sstevel@tonic-gate  * Module info.
1967c478bd9Sstevel@tonic-gate  */
1977c478bd9Sstevel@tonic-gate struct mod_info {
1987c478bd9Sstevel@tonic-gate 	struct mod_info	*next;		/* ptr to next in the modules list */
1997c478bd9Sstevel@tonic-gate 	char		*name;		/* name of this module */
2007c478bd9Sstevel@tonic-gate 	int		id;		/* id, used while printing */
2017c478bd9Sstevel@tonic-gate 	bool		active;		/* is this module active or not ? */
2027c478bd9Sstevel@tonic-gate 	struct nl	*nl;		/* ptr to nameslist for this module */
2037c478bd9Sstevel@tonic-gate 	struct nl	*npe;		/* virtual end of module's namelist */
2047c478bd9Sstevel@tonic-gate 	sztype		nname;		/* number of funcs in this module */
2057c478bd9Sstevel@tonic-gate 	GElf_Addr	txt_origin;	/* module's start as given in file */
2067c478bd9Sstevel@tonic-gate 	GElf_Addr	data_end;	/* module's end addr as in file */
2077c478bd9Sstevel@tonic-gate 	Address		load_base;	/* actual pcaddr where modl's loaded */
2087c478bd9Sstevel@tonic-gate 	Address		load_end;	/* actual pcaddr where modl ends */
2097c478bd9Sstevel@tonic-gate };
2107c478bd9Sstevel@tonic-gate typedef struct mod_info	mod_info_t;
2117c478bd9Sstevel@tonic-gate 
212*14448871SToomas Soome extern sztype		total_names;	/* from all modules */
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate /*
2157c478bd9Sstevel@tonic-gate  * List of shared object modules. Note that this always includes the
2167c478bd9Sstevel@tonic-gate  * program executable as the first element.
2177c478bd9Sstevel@tonic-gate  */
218*14448871SToomas Soome extern mod_info_t	modules;
219*14448871SToomas Soome extern sztype		n_modules;
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate /*
2227c478bd9Sstevel@tonic-gate  * The symbol table;
2237c478bd9Sstevel@tonic-gate  * for each external in the specified file we gather
2247c478bd9Sstevel@tonic-gate  * its address, the number of calls and compute its share of cpu time.
2257c478bd9Sstevel@tonic-gate  */
2267c478bd9Sstevel@tonic-gate struct nl {
2277c478bd9Sstevel@tonic-gate     char		*name;		/* the name */
2287c478bd9Sstevel@tonic-gate     mod_info_t		*module;	/* module to which this belongs */
2297c478bd9Sstevel@tonic-gate     pctype		value;		/* the pc entry point */
2307c478bd9Sstevel@tonic-gate     pctype		svalue;		/* entry point aligned to histograms */
2317c478bd9Sstevel@tonic-gate     unsigned long	sz;		/* function size */
2327c478bd9Sstevel@tonic-gate     unsigned char	syminfo;	/* sym info */
2337c478bd9Sstevel@tonic-gate     size_t		nticks;		/* ticks in this routine */
2347c478bd9Sstevel@tonic-gate     double		time;		/* ticks in this routine as double */
2357c478bd9Sstevel@tonic-gate     double		childtime;	/* cumulative ticks in children */
2367c478bd9Sstevel@tonic-gate     actype		ncall;		/* how many times called */
2377c478bd9Sstevel@tonic-gate     actype		selfcalls;	/* how many calls to self */
2387c478bd9Sstevel@tonic-gate     double		propfraction;	/* what % of time propagates */
2397c478bd9Sstevel@tonic-gate     double		propself;	/* how much self time propagates */
2407c478bd9Sstevel@tonic-gate     double		propchild;	/* how much child time propagates */
2417c478bd9Sstevel@tonic-gate     bool		printflag;	/* should this be printed? */
2427c478bd9Sstevel@tonic-gate     int			index;		/* index in the graph list */
2437c478bd9Sstevel@tonic-gate     int			toporder;	/* graph call chain top-sort order */
2447c478bd9Sstevel@tonic-gate     int			cycleno;	/* internal number of cycle on */
2457c478bd9Sstevel@tonic-gate     struct nl		*cyclehead;	/* pointer to head of cycle */
2467c478bd9Sstevel@tonic-gate     struct nl		*cnext;		/* pointer to next member of cycle */
2477c478bd9Sstevel@tonic-gate     arctype		*parents;	/* list of caller arcs */
2487c478bd9Sstevel@tonic-gate     arctype		*children;	/* list of callee arcs */
2497c478bd9Sstevel@tonic-gate     unsigned long	ncallers;	/* no. of callers - dumpsum use only */
2507c478bd9Sstevel@tonic-gate };
2517c478bd9Sstevel@tonic-gate typedef struct nl	nltype;
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate /*
2547c478bd9Sstevel@tonic-gate  *	flag which marks a nl entry as topologically ``busy''
2557c478bd9Sstevel@tonic-gate  *	flag which marks a nl entry as topologically ``not_numbered''
2567c478bd9Sstevel@tonic-gate  */
2577c478bd9Sstevel@tonic-gate #define	DFN_BUSY	-1
2587c478bd9Sstevel@tonic-gate #define	DFN_NAN		0
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate /*
2617c478bd9Sstevel@tonic-gate  *	namelist entries for cycle headers.
2627c478bd9Sstevel@tonic-gate  *	the number of discovered cycles.
2637c478bd9Sstevel@tonic-gate  */
264*14448871SToomas Soome extern nltype	*cyclenl;		/* cycle header namelist */
265*14448871SToomas Soome extern int	ncycle;			/* number of cycles discovered */
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /*
2687c478bd9Sstevel@tonic-gate  * The header on the gmon.out file.
2697c478bd9Sstevel@tonic-gate  * old-style gmon.out consists of one of these headers,
2707c478bd9Sstevel@tonic-gate  * and then an array of ncnt samples
2717c478bd9Sstevel@tonic-gate  * representing the discretized program counter values.
2727c478bd9Sstevel@tonic-gate  *	this should be a struct phdr, but since everything is done
2737c478bd9Sstevel@tonic-gate  *	as UNITs, this is in UNITs too.
2747c478bd9Sstevel@tonic-gate  */
2757c478bd9Sstevel@tonic-gate struct hdr {
2767c478bd9Sstevel@tonic-gate 	pctype		lowpc;
2777c478bd9Sstevel@tonic-gate 	pctype		highpc;
2787c478bd9Sstevel@tonic-gate 	pctype		ncnt;
2797c478bd9Sstevel@tonic-gate };
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate struct hdr32 {
2827c478bd9Sstevel@tonic-gate 	pctype32	lowpc;
2837c478bd9Sstevel@tonic-gate 	pctype32	highpc;
2847c478bd9Sstevel@tonic-gate 	pctype32	ncnt;
2857c478bd9Sstevel@tonic-gate };
2867c478bd9Sstevel@tonic-gate 
287*14448871SToomas Soome extern struct hdr	h;		/* header of profiled data */
2887c478bd9Sstevel@tonic-gate 
289*14448871SToomas Soome extern int	debug;
290*14448871SToomas Soome extern int	number_funcs_toprint;
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate /*
2937c478bd9Sstevel@tonic-gate  * Each discretized pc sample has
2947c478bd9Sstevel@tonic-gate  * a count of the number of samples in its range
2957c478bd9Sstevel@tonic-gate  */
296*14448871SToomas Soome extern unsigned short	*samples;
2977c478bd9Sstevel@tonic-gate 
298*14448871SToomas Soome extern pctype	s_lowpc;	/* lowpc from profile file in o-s gmon.out */
299*14448871SToomas Soome extern pctype	s_highpc;	/* highpc from profile file in o-s gmon.out */
300*14448871SToomas Soome extern sztype	sampbytes;	/* number of bytes of samples in o-s gmon.out */
301*14448871SToomas Soome extern sztype	nsamples;	/* number of samples for old-style gmon.out */
3027c478bd9Sstevel@tonic-gate 
303*14448871SToomas Soome extern double	actime;		/* accumulated time thus far for putprofline */
304*14448871SToomas Soome extern double	totime;		/* total time for all routines */
305*14448871SToomas Soome extern double	printtime;	/* total of time being printed */
306*14448871SToomas Soome extern double	scale;		/* scale factor converting samples to pc */
3077c478bd9Sstevel@tonic-gate 				/* values: each sample covers scale bytes */
3087c478bd9Sstevel@tonic-gate 				/* -- all this is for old-style gmon.out only */
3097c478bd9Sstevel@tonic-gate 
310*14448871SToomas Soome extern unsigned char	*textspace;	/* text space of a.out in core */
311*14448871SToomas Soome extern bool	first_file;		/* for difference option */
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate /*
3147c478bd9Sstevel@tonic-gate  * Total number of pcsamples read so far (across gmon.out's)
3157c478bd9Sstevel@tonic-gate  */
316*14448871SToomas Soome extern Size	n_pcsamples;
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate /*
3197c478bd9Sstevel@tonic-gate  *	option flags, from a to z.
3207c478bd9Sstevel@tonic-gate  */
321*14448871SToomas Soome extern bool	aflag;			/* suppress static functions */
322*14448871SToomas Soome extern bool	bflag;			/* blurbs, too */
323*14448871SToomas Soome extern bool	Bflag;			/* big pc's (i.e. 64 bits) */
324*14448871SToomas Soome extern bool	cflag;			/* discovered call graph, too */
325*14448871SToomas Soome extern bool	Cflag;			/* gprofing c++ -- need demangling */
326*14448871SToomas Soome extern bool	dflag;			/* debugging options */
327*14448871SToomas Soome extern bool	Dflag;			/* difference option */
328*14448871SToomas Soome extern bool	eflag;			/* specific functions excluded */
329*14448871SToomas Soome extern bool	Eflag;			/* functions excluded with time */
330*14448871SToomas Soome extern bool	fflag;			/* specific functions requested */
331*14448871SToomas Soome extern bool	Fflag;			/* functions requested with time */
332*14448871SToomas Soome extern bool	lflag;			/* exclude LOCAL syms in output */
333*14448871SToomas Soome extern bool	sflag;			/* sum multiple gmon.out files */
334*14448871SToomas Soome extern bool	zflag;			/* zero time/called functions, too */
335*14448871SToomas Soome extern bool	nflag;			/* print only n functions in report */
336*14448871SToomas Soome extern bool	rflag;			/* profiling input generated by */
3377c478bd9Sstevel@tonic-gate 					/* run-time linker */
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate 
3407c478bd9Sstevel@tonic-gate /*
3417c478bd9Sstevel@tonic-gate  *	structure for various string lists
3427c478bd9Sstevel@tonic-gate  */
3437c478bd9Sstevel@tonic-gate struct stringlist {
3447c478bd9Sstevel@tonic-gate     struct stringlist	*next;
3457c478bd9Sstevel@tonic-gate     char		*string;
3467c478bd9Sstevel@tonic-gate };
3477c478bd9Sstevel@tonic-gate extern struct stringlist	*elist;
3487c478bd9Sstevel@tonic-gate extern struct stringlist	*Elist;
3497c478bd9Sstevel@tonic-gate extern struct stringlist	*flist;
3507c478bd9Sstevel@tonic-gate extern struct stringlist	*Flist;
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate /*
3537c478bd9Sstevel@tonic-gate  *	function declarations
3547c478bd9Sstevel@tonic-gate  */
3557c478bd9Sstevel@tonic-gate void	addlist(struct stringlist *, char *);
3567c478bd9Sstevel@tonic-gate void	addarc(nltype *, nltype *, actype);
3577c478bd9Sstevel@tonic-gate int	arccmp(arctype *, arctype *);
3587c478bd9Sstevel@tonic-gate arctype	*arclookup(nltype *, nltype *);
3597c478bd9Sstevel@tonic-gate void	printblurb(char *);
3607c478bd9Sstevel@tonic-gate void	dfn(nltype *);
3617c478bd9Sstevel@tonic-gate bool	dfn_busy(nltype *);
3627c478bd9Sstevel@tonic-gate void	dfn_findcycle(nltype *);
3637c478bd9Sstevel@tonic-gate bool	dfn_numbered(nltype *);
3647c478bd9Sstevel@tonic-gate void	dfn_post_visit(nltype *);
3657c478bd9Sstevel@tonic-gate void	dfn_pre_visit(nltype *);
3667c478bd9Sstevel@tonic-gate void	dfn_self_cycle(nltype *);
3677c478bd9Sstevel@tonic-gate nltype	**doarcs(void);
36892ed1782Smike_s void	done(void);
3697c478bd9Sstevel@tonic-gate void	findcalls(nltype *, pctype, pctype);
3707c478bd9Sstevel@tonic-gate void	flatprofheader(void);
3717c478bd9Sstevel@tonic-gate void	flatprofline(nltype *);
3727c478bd9Sstevel@tonic-gate bool	is_shared_obj(char *);
3737c478bd9Sstevel@tonic-gate void	getnfile(char *);
3747c478bd9Sstevel@tonic-gate void	process_namelist(mod_info_t *);
3757c478bd9Sstevel@tonic-gate void	gprofheader(void);
3767c478bd9Sstevel@tonic-gate void	gprofline(nltype *);
37792ed1782Smike_s int	pc_cmp(const void *arg1, const void *arg2);
3787c478bd9Sstevel@tonic-gate int	membercmp(nltype *, nltype *);
3797c478bd9Sstevel@tonic-gate nltype	*nllookup(mod_info_t *, pctype, pctype *);
3807c478bd9Sstevel@tonic-gate bool	onlist(struct stringlist *, char *);
3817c478bd9Sstevel@tonic-gate void	printchildren(nltype *);
3827c478bd9Sstevel@tonic-gate void	printcycle(nltype *);
3837c478bd9Sstevel@tonic-gate void	printgprof(nltype **);
3847c478bd9Sstevel@tonic-gate void	printindex(void);
3857c478bd9Sstevel@tonic-gate void	printmembers(nltype *);
3867c478bd9Sstevel@tonic-gate void	printmodules(void);
3877c478bd9Sstevel@tonic-gate void	printname(nltype *);
3887c478bd9Sstevel@tonic-gate void	printparents(nltype *);
3897c478bd9Sstevel@tonic-gate void	printprof(void);
3907c478bd9Sstevel@tonic-gate void	sortchildren(nltype *);
3917c478bd9Sstevel@tonic-gate void	sortmembers(nltype *);
3927c478bd9Sstevel@tonic-gate void	sortparents(nltype *);
39392ed1782Smike_s int	timecmp(const void *arg1, const void *arg2);
39492ed1782Smike_s int	totalcmp(const void *arg1, const void *arg2);
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate #define	LESSTHAN	-1
3977c478bd9Sstevel@tonic-gate #define	EQUALTO		0
3987c478bd9Sstevel@tonic-gate #define	GREATERTHAN	1
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate /*
4017c478bd9Sstevel@tonic-gate  * Macros related to debug messages.
4027c478bd9Sstevel@tonic-gate  */
4037c478bd9Sstevel@tonic-gate #define	DFNDEBUG	0x0001
4047c478bd9Sstevel@tonic-gate #define	CYCLEDEBUG	0x0002
4057c478bd9Sstevel@tonic-gate #define	ARCDEBUG	0x0004
4067c478bd9Sstevel@tonic-gate #define	TALLYDEBUG	0x0008
4077c478bd9Sstevel@tonic-gate #define	TIMEDEBUG	0x0010
4087c478bd9Sstevel@tonic-gate #define	SAMPLEDEBUG	0x0020
4097c478bd9Sstevel@tonic-gate #define	ELFDEBUG	0x0040
4107c478bd9Sstevel@tonic-gate #define	CALLSDEBUG	0x0080
4117c478bd9Sstevel@tonic-gate #define	LOOKUPDEBUG	0x0100
4127c478bd9Sstevel@tonic-gate #define	PROPDEBUG	0x0200
4137c478bd9Sstevel@tonic-gate #define	ANYDEBUG	0x0400
4147c478bd9Sstevel@tonic-gate 
4157c478bd9Sstevel@tonic-gate #define	MONOUTDEBUG	0x0800
4167c478bd9Sstevel@tonic-gate #define	MODULEDEBUG	0x1000
4177c478bd9Sstevel@tonic-gate #define	CGRAPHDEBUG	0x2000
4187c478bd9Sstevel@tonic-gate #define	PCSMPLDEBUG	0x4000
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4217c478bd9Sstevel@tonic-gate }
4227c478bd9Sstevel@tonic-gate #endif
4237c478bd9Sstevel@tonic-gate 
4247c478bd9Sstevel@tonic-gate #endif	/* _SGS_GPROF_H */
425