gprof.h revision 672986541be54a7a471bb088e60780c37e371d7e
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SGS_GPROF_H
#define _SGS_GPROF_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <elf.h>
#include "sparc.h"
#include "gelf.h"
#include "monv.h"
#include "sgs.h"
/*
* who am i, for error messages.
*/
extern char *whoami;
/*
* booleans
*/
typedef Boolean bool;
/*
* Alignment related constants
*/
#define PGSZ 4096
#define STRUCT_ALIGN 8
/*
* Macros related to structure alignment
*/
/*
* ticks per second
*/
long hz;
typedef short UNIT; /* unit of profiling */
typedef unsigned short unsigned_UNIT; /* to remove warnings from gprof.c */
char *a_outname;
char *prog_name; /* keep the program name for error messages */
#define A_OUTNAME "a.out"
typedef unsigned long long pctype;
/*
* Type definition for the arc count.
*/
typedef long long actype;
char *gmonname;
#define GMONNAME "gmon.out"
/*
* Special symbols used for profiling of shared libraries through
* the run-time linker.
*/
#define PRF_ETEXT "_etext"
#define PRF_EXTSYM "<external>"
#define PRF_MEMTERM "_END_OF_VIRTUAL_MEMORY"
#define PRF_SYMCNT 3
/*
* Special symbol needed to determine the program exec's end addr.
* Note that since this symbol doesn't get added to the nameslist,
* it doesn't have to be counted in PRF_SYMCNT
*/
#define PRF_END "_end"
/*
* blurbs on the flat and graph profiles.
*/
#define FLAT_BLURB "/usr/share/lib/ccs/gprof.flat.blurb"
#define CALLG_BLURB "/usr/share/lib/ccs/gprof.callg.blurb"
/*
* a raw arc,
* with pointers to the calling site and the called site
* and a count.
*/
struct rawarc {
};
struct rawarc32 {
};
/*
* a constructed arc,
* with pointers to the namelist entry of the parent and the child,
* a count of how many times this arc was traversed,
* and pointers to the next parent of this child and
* the next child of this parent.
*/
struct arcstruct {
double arc_time; /* time inherited along arc */
double arc_childtime; /* childtime inherited along arc */
};
/*
* Additions for new-style gmon.out
*/
bool old_style; /* gmon.out versioned/non-versioned ? */
/*
* Executable file info.
*
* All info that is required to identify a file or see if it has changed
* relative to another file.
*/
struct fl_info {
};
/*
* Saved file info.
*/
/*
* Module info.
*/
struct mod_info {
char *name; /* name of this module */
int id; /* id, used while printing */
bool active; /* is this module active or not ? */
};
typedef struct mod_info mod_info_t;
/*
* List of shared object modules. Note that this always includes the
* program executable as the first element.
*/
/*
* The symbol table;
* for each external in the specified file we gather
* its address, the number of calls and compute its share of cpu time.
*/
struct nl {
char *name; /* the name */
unsigned long sz; /* function size */
unsigned char syminfo; /* sym info */
double time; /* ticks in this routine as double */
double childtime; /* cumulative ticks in children */
double propfraction; /* what % of time propagates */
double propself; /* how much self time propagates */
double propchild; /* how much child time propagates */
bool printflag; /* should this be printed? */
int index; /* index in the graph list */
int toporder; /* graph call chain top-sort order */
int cycleno; /* internal number of cycle on */
unsigned long ncallers; /* no. of callers - dumpsum use only */
};
/*
* flag which marks a nl entry as topologically ``busy''
* flag which marks a nl entry as topologically ``not_numbered''
*/
#define DFN_BUSY -1
#define DFN_NAN 0
/*
* namelist entries for cycle headers.
* the number of discovered cycles.
*/
int ncycle; /* number of cycles discovered */
/*
* The header on the gmon.out file.
* old-style gmon.out consists of one of these headers,
* and then an array of ncnt samples
* representing the discretized program counter values.
* this should be a struct phdr, but since everything is done
* as UNITs, this is in UNITs too.
*/
struct hdr {
};
struct hdr32 {
};
struct hdr h; /* header of profiled data */
int debug;
int number_funcs_toprint;
/*
* Each discretized pc sample has
* a count of the number of samples in its range
*/
unsigned short *samples;
double actime; /* accumulated time thus far for putprofline */
double totime; /* total time for all routines */
double printtime; /* total of time being printed */
double scale; /* scale factor converting samples to pc */
/* values: each sample covers scale bytes */
/* -- all this is for old-style gmon.out only */
unsigned char *textspace; /* text space of a.out in core */
bool first_file; /* for difference option */
/*
* Total number of pcsamples read so far (across gmon.out's)
*/
/*
* option flags, from a to z.
*/
bool aflag; /* suppress static functions */
bool bflag; /* blurbs, too */
bool Bflag; /* big pc's (i.e. 64 bits) */
bool cflag; /* discovered call graph, too */
bool Cflag; /* gprofing c++ -- need demangling */
bool dflag; /* debugging options */
bool Dflag; /* difference option */
bool eflag; /* specific functions excluded */
bool Eflag; /* functions excluded with time */
bool fflag; /* specific functions requested */
bool Fflag; /* functions requested with time */
bool lflag; /* exclude LOCAL syms in output */
bool sflag; /* sum multiple gmon.out files */
bool nflag; /* print only n functions in report */
bool rflag; /* profiling input generated by */
/* run-time linker */
/*
* structure for various string lists
*/
struct stringlist {
struct stringlist *next;
char *string;
};
extern struct stringlist *elist;
extern struct stringlist *Elist;
extern struct stringlist *flist;
extern struct stringlist *Flist;
/*
* function declarations
*/
void addlist(struct stringlist *, char *);
void printblurb(char *);
void dfn_findcycle(nltype *);
bool dfn_numbered(nltype *);
void dfn_post_visit(nltype *);
void dfn_pre_visit(nltype *);
void dfn_self_cycle(nltype *);
void done(void);
void flatprofheader(void);
void flatprofline(nltype *);
bool is_shared_obj(char *);
void getnfile(char *);
void process_namelist(mod_info_t *);
void gprofheader(void);
bool onlist(struct stringlist *, char *);
void printchildren(nltype *);
void printcycle(nltype *);
void printgprof(nltype **);
void printindex(void);
void printmembers(nltype *);
void printmodules(void);
void printparents(nltype *);
void printprof(void);
void sortchildren(nltype *);
void sortmembers(nltype *);
void sortparents(nltype *);
#define LESSTHAN -1
#define EQUALTO 0
#define GREATERTHAN 1
/*
* Macros related to debug messages.
*/
#define DFNDEBUG 0x0001
#define CYCLEDEBUG 0x0002
#define ARCDEBUG 0x0004
#define TALLYDEBUG 0x0008
#define TIMEDEBUG 0x0010
#define SAMPLEDEBUG 0x0020
#define ELFDEBUG 0x0040
#define CALLSDEBUG 0x0080
#define LOOKUPDEBUG 0x0100
#define PROPDEBUG 0x0200
#define ANYDEBUG 0x0400
#define MONOUTDEBUG 0x0800
#define MODULEDEBUG 0x1000
#define CGRAPHDEBUG 0x2000
#define PCSMPLDEBUG 0x4000
#ifdef __cplusplus
}
#endif
#endif /* _SGS_GPROF_H */