diff options
author | Toomas Soome <tsoome@me.com> | 2020-05-25 20:02:32 +0300 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2021-03-12 09:30:03 +0200 |
commit | 144488712135c03d546fb15b718e6a21f4f6d4cf (patch) | |
tree | 87fc53d71648168e321f07ad0b0a304671c2816c | |
parent | 28ab0ca48b3e331cbbb231b1c8325f9f24f9af95 (diff) | |
download | illumos-joyent-144488712135c03d546fb15b718e6a21f4f6d4cf.tar.gz |
13550 gprof: multiply-defined symbols
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r-- | usr/src/cmd/sgs/gprof/common/arcs.c | 31 | ||||
-rw-r--r-- | usr/src/cmd/sgs/gprof/common/gprof.c | 42 | ||||
-rw-r--r-- | usr/src/cmd/sgs/gprof/common/gprof.h | 90 | ||||
-rw-r--r-- | usr/src/cmd/sgs/gprof/common/printgprof.c | 4 |
4 files changed, 101 insertions, 66 deletions
diff --git a/usr/src/cmd/sgs/gprof/common/arcs.c b/usr/src/cmd/sgs/gprof/common/arcs.c index 8b5fb24801..cd3ad2a482 100644 --- a/usr/src/cmd/sgs/gprof/common/arcs.c +++ b/usr/src/cmd/sgs/gprof/common/arcs.c @@ -25,11 +25,14 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdlib.h> #include "gprof.h" +double printtime; +sztype total_names; +int ncycle; +nltype *cyclenl; + /* * add (or just increment) an arc */ @@ -334,11 +337,13 @@ cyclelink(void) continue; if (arcp->arc_parentp->cycleno == - cycle) { - cyclenlp->selfcalls += - arcp->arc_count; - } else - cyclenlp->ncall += arcp->arc_count; + cycle) { + cyclenlp->selfcalls += + arcp->arc_count; + } else { + cyclenlp->ncall += + arcp->arc_count; + } } } } @@ -607,10 +612,8 @@ doarcs(void) * the program executable. */ if (cflag && (mi == &modules)) { - findcalls( - parentp, - parentp->value, - parentp->value + parentp->sz); + findcalls(parentp, parentp->value, + parentp->value + parentp->sz); } } } @@ -643,7 +646,7 @@ doarcs(void) index = 0; for (mi = &modules; mi; mi = mi->next) { for (i = 0; i < mi->nname; i++) - topsortnlp[index++] = &(mi->nl[i]); + topsortnlp[index++] = &(mi->nl[i]); } qsort(topsortnlp, total_names, sizeof (nltype *), topcmp); @@ -677,7 +680,7 @@ doarcs(void) * and cycle headers. */ timesortnlp = (nltype **) calloc(total_names + ncycle, - sizeof (nltype *)); + sizeof (nltype *)); if (timesortnlp == (nltype **) 0) { (void) fprintf(stderr, "%s: ran out of memory for sorting\n", whoami); @@ -686,7 +689,7 @@ doarcs(void) index = 0; for (mi = &modules; mi; mi = mi->next) { for (i = 0; i < mi->nname; i++) - timesortnlp[index++] = &(mi->nl[i]); + timesortnlp[index++] = &(mi->nl[i]); } for (index = 1; index <= ncycle; index++) diff --git a/usr/src/cmd/sgs/gprof/common/gprof.c b/usr/src/cmd/sgs/gprof/common/gprof.c index 9bdd429183..2cb0720f8b 100644 --- a/usr/src/cmd/sgs/gprof/common/gprof.c +++ b/usr/src/cmd/sgs/gprof/common/gprof.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sysexits.h> #include <stdlib.h> #include <stdio.h> @@ -32,6 +30,44 @@ #include "gprof.h" #include "profile.h" +bool aflag; +bool bflag; +bool Bflag; +bool cflag; +bool Cflag; +bool dflag; +bool Dflag; +bool eflag; +bool Eflag; +bool fflag; +bool Fflag; +bool lflag; +bool sflag; +bool zflag; +bool nflag; +bool rflag; +bool first_file; +bool old_style; +double scale; +double totime; +Size n_pcsamples; +mod_info_t modules; +pctype s_lowpc; +pctype s_highpc; +sztype n_modules; +sztype sampbytes; +sztype nsamples; +unsigned short *samples; +fl_info_t aout_info; +fl_info_t gmonout_info; +long hz; +struct hdr h; +unsigned char *textspace; +int debug; +int number_funcs_toprint; +char *a_outname; +char *prog_name; +char *gmonname; char *whoami = "gprof"; static pctype lowpc, highpc; /* range profiled, in UNIT's */ @@ -1896,7 +1932,7 @@ main(int argc, char **argv) int i; (void) printf(" Name, pc_entry_pt, svalue, tix_in_routine, " "#calls, selfcalls, index \n"); - for (i = 0; i < modules.nname; i++) { /* Print each symbol */ + for (i = 0; i < modules.nname; i++) { /* Print each symbol */ if (timesortnlp[i]->name) (void) printf(" %s ", timesortnlp[i]->name); else diff --git a/usr/src/cmd/sgs/gprof/common/gprof.h b/usr/src/cmd/sgs/gprof/common/gprof.h index e62ddaf45c..a22f06df34 100644 --- a/usr/src/cmd/sgs/gprof/common/gprof.h +++ b/usr/src/cmd/sgs/gprof/common/gprof.h @@ -27,8 +27,6 @@ #ifndef _SGS_GPROF_H #define _SGS_GPROF_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -87,12 +85,12 @@ typedef Boolean bool; /* * ticks per second */ -long hz; +extern 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 */ +extern char *a_outname; +extern char *prog_name; /* keep the program name for error messages */ #define A_OUTNAME "a.out" typedef unsigned long long pctype; @@ -105,7 +103,7 @@ typedef size_t sztype; typedef long long actype; typedef int32_t actype32; -char *gmonname; +extern char *gmonname; #define GMONNAME "gmon.out" #define GMONSUM "gmon.sum" @@ -170,7 +168,7 @@ typedef struct arcstruct arctype; /* * Additions for new-style gmon.out */ -bool old_style; /* gmon.out versioned/non-versioned ? */ +extern bool old_style; /* gmon.out versioned/non-versioned ? */ /* * Executable file info. @@ -189,8 +187,8 @@ typedef struct fl_info fl_info_t; /* * Saved file info. */ -fl_info_t aout_info; /* saved file info for program exec */ -fl_info_t gmonout_info; /* current gmonout's info */ +extern fl_info_t aout_info; /* saved file info for program exec */ +extern fl_info_t gmonout_info; /* current gmonout's info */ /* @@ -211,16 +209,14 @@ struct mod_info { }; typedef struct mod_info mod_info_t; -sztype total_names; /* from all modules */ +extern sztype total_names; /* from all modules */ /* * List of shared object modules. Note that this always includes the * program executable as the first element. */ -mod_info_t modules; -sztype n_modules; - - +extern mod_info_t modules; +extern sztype n_modules; /* * The symbol table; @@ -265,8 +261,8 @@ typedef struct nl nltype; * namelist entries for cycle headers. * the number of discovered cycles. */ -nltype *cyclenl; /* cycle header namelist */ -int ncycle; /* number of cycles discovered */ +extern nltype *cyclenl; /* cycle header namelist */ +extern int ncycle; /* number of cycles discovered */ /* * The header on the gmon.out file. @@ -288,56 +284,56 @@ struct hdr32 { pctype32 ncnt; }; -struct hdr h; /* header of profiled data */ +extern struct hdr h; /* header of profiled data */ -int debug; -int number_funcs_toprint; +extern int debug; +extern int number_funcs_toprint; /* * Each discretized pc sample has * a count of the number of samples in its range */ -unsigned short *samples; +extern unsigned short *samples; -pctype s_lowpc; /* lowpc from profile file in o-s gmon.out */ -pctype s_highpc; /* highpc from profile file in o-s gmon.out */ -sztype sampbytes; /* number of bytes of samples in o-s gmon.out */ -sztype nsamples; /* number of samples for old-style gmon.out */ +extern pctype s_lowpc; /* lowpc from profile file in o-s gmon.out */ +extern pctype s_highpc; /* highpc from profile file in o-s gmon.out */ +extern sztype sampbytes; /* number of bytes of samples in o-s gmon.out */ +extern sztype nsamples; /* number of samples for old-style gmon.out */ -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 */ +extern double actime; /* accumulated time thus far for putprofline */ +extern double totime; /* total time for all routines */ +extern double printtime; /* total of time being printed */ +extern 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 */ +extern unsigned char *textspace; /* text space of a.out in core */ +extern bool first_file; /* for difference option */ /* * Total number of pcsamples read so far (across gmon.out's) */ -Size n_pcsamples; +extern Size n_pcsamples; /* * 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 zflag; /* zero time/called functions, too */ -bool nflag; /* print only n functions in report */ -bool rflag; /* profiling input generated by */ +extern bool aflag; /* suppress static functions */ +extern bool bflag; /* blurbs, too */ +extern bool Bflag; /* big pc's (i.e. 64 bits) */ +extern bool cflag; /* discovered call graph, too */ +extern bool Cflag; /* gprofing c++ -- need demangling */ +extern bool dflag; /* debugging options */ +extern bool Dflag; /* difference option */ +extern bool eflag; /* specific functions excluded */ +extern bool Eflag; /* functions excluded with time */ +extern bool fflag; /* specific functions requested */ +extern bool Fflag; /* functions requested with time */ +extern bool lflag; /* exclude LOCAL syms in output */ +extern bool sflag; /* sum multiple gmon.out files */ +extern bool zflag; /* zero time/called functions, too */ +extern bool nflag; /* print only n functions in report */ +extern bool rflag; /* profiling input generated by */ /* run-time linker */ diff --git a/usr/src/cmd/sgs/gprof/common/printgprof.c b/usr/src/cmd/sgs/gprof/common/printgprof.c index acabccaedd..bbd8673ec7 100644 --- a/usr/src/cmd/sgs/gprof/common/printgprof.c +++ b/usr/src/cmd/sgs/gprof/common/printgprof.c @@ -34,11 +34,11 @@ #include "conv.h" #include "gprof.h" +double actime; + void print_demangled_name(int, nltype *); static void stripped_name(char **, size_t *, nltype **); -extern long hz; - /* * Symbols that must never be printed, no matter what. */ |