[prev in list] [next in list] [prev in thread] [next in thread]
List: pcc-list
Subject: Re: Profiling
From: Anders Magnusson <ragge () ludd ! ltu ! se>
Date: 2007-12-23 10:19:15
Message-ID: 200712231019.lBNAJFDP015176 () mother ! ludd ! ltu ! se
[Download RAW message or body]
>
> Here is a patch to add -p option to ccom which enables profiling:
>
Good, OK for me.
There may be different types of profiling (prof/gprof/...) but
it sounds sane to just use -p. It will accept -pg anyway :-)
-- Ragge
> Index: cc/cc/cc.c
> ===================================================================
> RCS file: /cvsroot/pcc/cc/cc/cc.c,v
> retrieving revision 1.79
> diff -u -r1.79 cc.c
> --- cc/cc/cc.c 30 Nov 2007 23:05:15 -0000 1.79
> +++ cc/cc/cc.c 22 Dec 2007 17:23:11 -0000
> @@ -148,6 +148,7 @@
> char *cppadd[] = CPPADD;
> char *dynlinker[] = DYNLINKER;
> char *crt0file = CRT0FILE;
> +char *crt0file_profile = CRT0FILE_PROFILE;
> char *startfiles[] = STARTFILES;
> char *endfiles[] = ENDFILES;
> char *cppmdadd[] = CPPMDADD;
> @@ -156,6 +157,11 @@
> #else
> char *libclibs[] = { "-lc", NULL };
> #endif
> +#ifdef LIBCLIBS_PROFILE
> +char *libclibs_profile[] = LIBCLIBS_PROFILE;
> +#else
> +char *libclibs_profile[] = { "-lc_p", NULL };
> +#endif
> #ifndef STARTLABEL
> #define STARTLABEL "__start"
> #endif
> @@ -449,6 +455,8 @@
> av[na++]= "ccom";
> if (vflag)
> av[na++] = "-v";
> + if (pgflag)
> + av[na++] = "-p";
> if (gflag)
> av[na++] = "-g";
> if (kflag)
> @@ -547,7 +555,7 @@
> av[j++] = outfile;
> }
> if (!nostartfiles) {
> - av[j++] = crt0file;
> + av[j++] = pgflag ? crt0file_profile : crt0file;
> for (i = 0; startfiles[i]; i++)
> av[j++] = startfiles[i];
> }
> @@ -565,9 +573,15 @@
> #endif
> if (pthreads)
> av[j++] = "-lpthread";
> - if (!nostdlib)
> - for (i = 0; libclibs[i]; i++)
> - av[j++] = libclibs[i];
> + if (!nostdlib) {
> + if (pgflag) {
> + for (i = 0; libclibs_profile[i]; i++)
> + av[j++] = libclibs_profile[i];
> + } else {
> + for (i = 0; libclibs[i]; i++)
> + av[j++] = libclibs[i];
> + }
> + }
> if (!nostartfiles) {
> for (i = 0; endfiles[i]; i++)
> av[j++] = endfiles[i];
> Index: cc/ccom/main.c
> ===================================================================
> RCS file: /cvsroot/pcc/cc/ccom/main.c,v
> retrieving revision 1.75
> diff -u -r1.75 main.c
> --- cc/ccom/main.c 26 Nov 2007 00:26:46 -0000 1.75
> +++ cc/ccom/main.c 22 Dec 2007 17:23:11 -0000
> @@ -34,7 +34,7 @@
> #include "pass1.h"
> #include "pass2.h"
>
> -int sflag, nflag, oflag, kflag;
> +int sflag, nflag, oflag, kflag, pflag;
> int lflag, odebug, rdebug, s2debug, udebug, x2debug;
> #if !defined(MULTIPASS) || defined(PASST)
> int iTflag, oTflag;
> @@ -112,7 +116,7 @@
>
> prgname = argv[0];
>
> - while ((ch = getopt(argc, argv, "VlwX:Z:W:sOT:gx:kvm:")) != -1)
> + while ((ch = getopt(argc, argv, "OT:VW:X:Z:gklm:psx:vw")) != -1)
> switch (ch) {
> #if !defined(MULTIPASS) || defined(PASS1)
> case 'X':
> @@ -202,6 +206,10 @@
> gflag = 1;
> break;
>
> + case 'p': /* Profiling */
> + pflag = 1;
> + break;
> +
> case 's': /* Statistics */
> ++sflag;
> break;
> Index: mip/manifest.h
> ===================================================================
> RCS file: /cvsroot/pcc/mip/manifest.h,v
> retrieving revision 1.68
> diff -u -r1.68 manifest.h
> --- mip/manifest.h 26 Nov 2007 00:26:46 -0000 1.68
> +++ mip/manifest.h 22 Dec 2007 17:23:12 -0000
> @@ -175,7 +175,7 @@
> extern int bdebug, tdebug, edebug;
> extern int ddebug, xdebug, f2debug;
> extern int iTflag, oTflag, kflag;
> -extern int sflag, nflag, gflag;
> +extern int sflag, nflag, gflag, pflag;
> extern int Wstrict_prototypes, Wmissing_prototypes, Wimplicit_int,
> Wimplicit_function_declaration;
> extern int xssaflag, xtailcallflag, xtemps, xdeljumps;
> Index: os/darwin/ccconfig.h
> ===================================================================
> RCS file: /cvsroot/pcc/os/darwin/ccconfig.h,v
> retrieving revision 1.4
> diff -u -r1.4 ccconfig.h
> --- os/darwin/ccconfig.h 2 Dec 2007 18:36:21 -0000 1.4
> +++ os/darwin/ccconfig.h 22 Dec 2007 17:23:12 -0000
> @@ -35,9 +35,11 @@
> #define CPPADD { "-D__Darwin__", "-I" INCLUDEDIR "/pcc", NULL }
> #define DYNLINKER { NULL }
> #define CRT0FILE "/usr/lib/crt1.o"
> +#define CRT0FILE_PROFILE "/usr/lib/gcrt1.o"
> #define STARTFILES { "-lcrt2.o", "-L/usr/lib/gcc/powerpc-apple-
> darwin8/4.0.1", NULL }
> #define ENDFILES { NULL }
> -#define LIBCLIBS { "-lc", "-lgcc", NULL }
> +#define LIBCLIBS { "-lSystem", "-lgcc", NULL }
> +#define LIBCLIBS_PROFILE { "-lSystem_profile", "-lgcc", NULL }
> #define STARTLABEL "start"
>
> /*
> Index: os/netbsd/ccconfig.h
> ===================================================================
> RCS file: /cvsroot/pcc/os/netbsd/ccconfig.h,v
> retrieving revision 1.9
> diff -u -r1.9 ccconfig.h
> --- os/netbsd/ccconfig.h 30 Nov 2007 23:13:43 -0000 1.9
> +++ os/netbsd/ccconfig.h 22 Dec 2007 17:23:12 -0000
> @@ -40,6 +40,7 @@
>
> /* host-dependent */
> #define CRT0FILE LIBDIR "crt0.o"
> +#define CRT0FILE_PROFILE LIBDIR "gcrt0.o"
> #define STARTFILES { LIBDIR "crti.o", LIBDIR "crtbegin.o", NULL }
> #define ENDFILES { LIBDIR "crtend.o", LIBDIR "crtn.o", NULL }
>
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic