--- ray/src/util/rtcontrib.c 2005/05/26 21:35:35 1.5 +++ ray/src/util/rtcontrib.c 2005/06/02 04:47:27 1.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rtcontrib.c,v 1.5 2005/05/26 21:35:35 greg Exp $"; +static const char RCSid[] = "$Id: rtcontrib.c,v 1.10 2005/06/02 04:47:27 greg Exp $"; #endif /* * Gather rtrace output to compute contributions from particular sources @@ -7,6 +7,7 @@ static const char RCSid[] = "$Id: rtcontrib.c,v 1.5 20 #include "standard.h" #include +#include #include "platform.h" #include "rtprocess.h" #include "selcall.h" @@ -66,13 +67,12 @@ struct rtproc { }; /* rtrace process buffer */ /* rtrace command and defaults */ -char *rtargv[256] = { "rtrace", "-dt", "0", "-dj", ".5", "-dr", "3", - "-ab", "1", "-ad", "128", }; +char *rtargv[256] = { "rtrace", "-dj", ".5", "-dr", "3", + "-ab", "1", "-ad", "128", "-lr", "-10", }; int rtargc = 11; /* overriding rtrace options */ -char *myrtopts[] = { "-o~~TmWdp", "-h-", - "-x", "1", "-y", "0", - "-as", "0", "-aa", "0", NULL }; +char *myrtopts[] = { "-o~~TmWdp", "-h-", "-x", "1", "-y", "0", + "-dt", "0", "-as", "0", "-aa", "0", NULL }; struct rtproc rt0; /* head of rtrace process list */ @@ -123,9 +123,11 @@ static void setformat(const char *fmt) { switch (fmt[0]) { - case 'a': case 'f': case 'd': + SET_FILE_BINARY(stdin); + /* fall through */ + case 'a': inpfmt = fmt[0]; break; default: @@ -202,8 +204,17 @@ main(int argc, char *argv[]) break; case 'f': /* file or i/o format */ if (!argv[i][2]) { + char *fpath; if (i >= argc-1) break; - fcompile(argv[++i]); + fpath = getpath(argv[++i], + getrlibpath(), R_OK); + if (fpath == NULL) { + sprintf(errmsg, + "cannot find file '%s'", + argv[i]); + error(USER, errmsg); + } + fcompile(fpath); continue; } setformat(argv[i]+2); @@ -489,8 +500,12 @@ getofile(const char *ospec, const char *mname, int bn) LUENT *lep; if (ospec == NULL) { /* use stdout? */ - if (!using_stdout && header) - printheader(stdout); + if (!using_stdout) { + if (outfmt != 'a') + SET_FILE_BINARY(stdout); + if (header) + printheader(stdout); + } using_stdout = 1; return stdout; } @@ -532,12 +547,18 @@ getofile(const char *ospec, const char *mname, int bn) if (lep->key == NULL) /* new entry */ lep->key = strcpy((char *)malloc(strlen(ofname)+1), ofname); if (lep->data == NULL) { /* open output file */ - FILE *fp = fopen(ofname, "w"); + FILE *fp; int i; + if (ofname[0] == '!') /* output to command */ + fp = popen(ofname+1, "w"); + else + fp = fopen(ofname, "w"); if (fp == NULL) { sprintf(errmsg, "cannot open '%s' for writing", ofname); error(SYSTEM, errmsg); } + if (outfmt != 'a') + SET_FILE_BINARY(fp); if (header) printheader(fp); /* play catch-up */