#ifndef _SGS_GPROF_H
#define _SGS_GPROF_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <elf.h>
#include "sparc.h"
#include "gelf.h"
#include "monv.h"
#include "sgs.h"
extern char *whoami;
typedef Boolean bool;
#define PGSZ 4096
#define STRUCT_ALIGN 8
#define FLOOR(x, align) (((Address) x) & ~((align) - 1l))
#define CEIL(x, align) FLOOR(((Address) x) + (align) - 1l, align)
#define PROFHDR_SZ (CEIL(sizeof (ProfHeader), STRUCT_ALIGN))
#define PROFMODLIST_SZ (CEIL(sizeof (ProfModuleList), STRUCT_ALIGN))
#define PROFMOD_SZ (CEIL(sizeof (ProfModule), STRUCT_ALIGN))
#define PROFBUF_SZ (CEIL(sizeof (ProfBuffer), STRUCT_ALIGN))
#define PROFCGRAPH_SZ (CEIL(sizeof (ProfCallGraph), STRUCT_ALIGN))
#define PROFFUNC_SZ (CEIL(sizeof (ProfFunction), STRUCT_ALIGN))
#define HDR_FILLER (PROFHDR_SZ - sizeof (ProfHeader))
#define MODLIST_FILLER (PROFMODLIST_SZ - sizeof (ProfModuleList))
#define MOD_FILLER (PROFMOD_SZ - sizeof (ProfModule))
#define BUF_FILLER (PROFBUF_SZ - sizeof (ProfBuffer))
#define CGRAPH_FILLER (PROFCGRAPH_SZ - sizeof (ProfCallGraph))
#define FUNC_FILLER (PROFFUNC_SZ - sizeof (ProfFunction))
extern long hz;
typedef short UNIT;
typedef unsigned short unsigned_UNIT;
extern char *a_outname;
extern char *prog_name;
#define A_OUTNAME "a.out"
typedef unsigned long long pctype;
typedef uint32_t pctype32;
typedef size_t sztype;
typedef long long actype;
typedef int32_t actype32;
extern char *gmonname;
#define GMONNAME "gmon.out"
#define GMONSUM "gmon.sum"
#define PRF_ETEXT "_etext"
#define PRF_EXTSYM "<external>"
#define PRF_MEMTERM "_END_OF_VIRTUAL_MEMORY"
#define PRF_SYMCNT 3
#define PRF_END "_end"
#define FLAT_BLURB "/usr/share/lib/ccs/gprof.flat.blurb"
#define CALLG_BLURB "/usr/share/lib/ccs/gprof.callg.blurb"
struct rawarc {
pctype raw_frompc;
pctype raw_selfpc;
actype raw_count;
};
struct rawarc32 {
pctype32 raw_frompc;
pctype32 raw_selfpc;
actype32 raw_count;
};
struct arcstruct {
struct nl *arc_parentp;
struct nl *arc_childp;
actype arc_count;
double arc_time;
double arc_childtime;
struct arcstruct *arc_parentlist;
struct arcstruct *arc_childlist;
};
typedef struct arcstruct arctype;
extern bool old_style;
struct fl_info {
dev_t dev;
ino_t ino;
time_t mtime;
off_t size;
};
typedef struct fl_info fl_info_t;
extern fl_info_t aout_info;
extern fl_info_t gmonout_info;
struct mod_info {
struct mod_info *next;
char *name;
int id;
bool active;
struct nl *nl;
struct nl *npe;
sztype nname;
GElf_Addr txt_origin;
GElf_Addr data_end;
Address load_base;
Address load_end;
};
typedef struct mod_info mod_info_t;
extern sztype total_names;
extern mod_info_t modules;
extern sztype n_modules;
struct nl {
char *name;
mod_info_t *module;
pctype value;
pctype svalue;
unsigned long sz;
unsigned char syminfo;
size_t nticks;
double time;
double childtime;
actype ncall;
actype selfcalls;
double propfraction;
double propself;
double propchild;
bool printflag;
int index;
int toporder;
int cycleno;
struct nl *cyclehead;
struct nl *cnext;
arctype *parents;
arctype *children;
unsigned long ncallers;
};
typedef struct nl nltype;
#define DFN_BUSY -1
#define DFN_NAN 0
extern nltype *cyclenl;
extern int ncycle;
struct hdr {
pctype lowpc;
pctype highpc;
pctype ncnt;
};
struct hdr32 {
pctype32 lowpc;
pctype32 highpc;
pctype32 ncnt;
};
extern struct hdr h;
extern int debug;
extern int number_funcs_toprint;
extern unsigned short *samples;
extern pctype s_lowpc;
extern pctype s_highpc;
extern sztype sampbytes;
extern sztype nsamples;
extern double actime;
extern double totime;
extern double printtime;
extern double scale;
extern unsigned char *textspace;
extern bool first_file;
extern Size n_pcsamples;
extern bool aflag;
extern bool bflag;
extern bool Bflag;
extern bool cflag;
extern bool Cflag;
extern bool dflag;
extern bool Dflag;
extern bool eflag;
extern bool Eflag;
extern bool fflag;
extern bool Fflag;
extern bool lflag;
extern bool sflag;
extern bool zflag;
extern bool nflag;
extern bool rflag;
struct stringlist {
struct stringlist *next;
char *string;
};
extern struct stringlist *elist;
extern struct stringlist *Elist;
extern struct stringlist *flist;
extern struct stringlist *Flist;
void addlist(struct stringlist *, char *);
void addarc(nltype *, nltype *, actype);
int arccmp(arctype *, arctype *);
arctype *arclookup(nltype *, nltype *);
void printblurb(char *);
void dfn(nltype *);
bool dfn_busy(nltype *);
void dfn_findcycle(nltype *);
bool dfn_numbered(nltype *);
void dfn_post_visit(nltype *);
void dfn_pre_visit(nltype *);
void dfn_self_cycle(nltype *);
nltype **doarcs(void);
void done(void);
void findcalls(nltype *, pctype, pctype);
void flatprofheader(void);
void flatprofline(nltype *);
bool is_shared_obj(char *);
void getnfile(char *);
void process_namelist(mod_info_t *);
void gprofheader(void);
void gprofline(nltype *);
int pc_cmp(const void *arg1, const void *arg2);
int membercmp(nltype *, nltype *);
nltype *nllookup(mod_info_t *, pctype, pctype *);
bool onlist(struct stringlist *, char *);
void printchildren(nltype *);
void printcycle(nltype *);
void printgprof(nltype **);
void printindex(void);
void printmembers(nltype *);
void printmodules(void);
void printname(nltype *);
void printparents(nltype *);
void printprof(void);
void sortchildren(nltype *);
void sortmembers(nltype *);
void sortparents(nltype *);
int timecmp(const void *arg1, const void *arg2);
int totalcmp(const void *arg1, const void *arg2);
#define LESSTHAN -1
#define EQUALTO 0
#define GREATERTHAN 1
#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