From 99b48d8cb4dbce3c56c5e4293c701edf1ae675d0 Mon Sep 17 00:00:00 2001 From: hunt Date: Fri, 6 Apr 2007 16:44:54 +0000 Subject: 2007-04-06 Martin Hunt * stp_merge.c (main): Remove extra newline in output. * stap_merge.c: Renamed from stp_merge.c. * Makefile: Updated. --- runtime/staprun/ChangeLog | 6 +++ runtime/staprun/Makefile | 8 +-- runtime/staprun/stap_merge.c | 117 ++++++++++++++++++++++++++++++++++++++++++ runtime/staprun/stp_merge.c | 119 ------------------------------------------- 4 files changed, 127 insertions(+), 123 deletions(-) create mode 100644 runtime/staprun/stap_merge.c delete mode 100644 runtime/staprun/stp_merge.c diff --git a/runtime/staprun/ChangeLog b/runtime/staprun/ChangeLog index b948db55..a50c2779 100644 --- a/runtime/staprun/ChangeLog +++ b/runtime/staprun/ChangeLog @@ -1,3 +1,9 @@ +2007-04-06 Martin Hunt + + * stp_merge.c (main): Remove extra newline in output. + * stap_merge.c: Renamed from stp_merge.c. + * Makefile: Updated. + 2007-04-02 Martin Hunt * relay_old.c (close_oldrelayfs): If just detaching, call diff --git a/runtime/staprun/Makefile b/runtime/staprun/Makefile index e8dd680d..b0329d3e 100644 --- a/runtime/staprun/Makefile +++ b/runtime/staprun/Makefile @@ -1,15 +1,15 @@ CFLAGS = -Wall -std=gnu99 -D_GNU_SOURCE -fexceptions -Wall -Werror -Wshadow -Wunused -all: staprun stp_merge +all: staprun stap_merge staprun: staprun.c mainloop.c relay.c ctl.c symbols.c ../transport/transport_msgs.h staprun.h gcc -O3 $(CFLAGS) -o staprun staprun.c mainloop.c symbols.c ctl.c relay.c relay_old.c -lpthread -stp_merge: stp_merge.c - gcc -O3 $(CFLAGS) -o stp_merge stp_merge.c +stap_merge: stap_merge.c + gcc -O3 $(CFLAGS) -o stap_merge stap_merge.c debug: staprun.c mainloop.c relay.c ctl.c symbols.c ../transport/transport_msgs.h staprun.h gcc -g -D DEBUG $(CFLAGS) -o staprun staprun.c mainloop.c symbols.c ctl.c relay.c relay_old.c -lpthread clean: - /bin/rm -f staprun stp_merge *.o *~ + /bin/rm -f staprun stap_merge *.o *~ diff --git a/runtime/staprun/stap_merge.c b/runtime/staprun/stap_merge.c new file mode 100644 index 00000000..20de1f2a --- /dev/null +++ b/runtime/staprun/stap_merge.c @@ -0,0 +1,117 @@ +/* + * stap_merge.c - systemtap merge program + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright (C) Red Hat Inc, 2005-2007 + * + */ + +#include +#include +#include +#include +#include + +static void usage (char *prog) +{ + fprintf(stderr, "%s [-o output_filename] input_files ...\n", prog); + exit(1); +} + +#define TIMESTAMP_SIZE (sizeof(int)) +#define NR_CPUS 256 + +int main (int argc, char *argv[]) +{ + char *outfile_name = NULL; + char buf[8192]; + int c, i, j, dropped=0; + long count=0, min, num[NR_CPUS]; + FILE *ofp, *fp[NR_CPUS]; + int ncpus, len; + + while ((c = getopt (argc, argv, "o:")) != EOF) { + switch (c) { + case 'o': + outfile_name = optarg; + break; + default: + usage(argv[0]); + } + } + + if (optind == argc) + usage (argv[0]); + + i = 0; + while (optind < argc) { + fp[i] = fopen(argv[optind++], "r"); + if (!fp[i]) { + fprintf(stderr, "error opening file %s.\n", argv[optind - 1]); + return -1; + } + if (fread (buf, TIMESTAMP_SIZE, 1, fp[i])) + num[i] = *((int *)buf); + else + num[i] = 0; + i++; + } + ncpus = i; + + if (!outfile_name) + ofp = stdout; + else { + ofp = fopen(outfile_name, "w"); + if (!ofp) { + fprintf(stderr, "ERROR: couldn't open output file %s: errcode = %s\n", + outfile_name, strerror(errno)); + return -1; + } + } + + do { + min = num[0]; + j = 0; + for (i = 1; i < ncpus; i++) { + if (min == 0 || (num[i] && num[i] < min)) { + min = num[i]; + j = i; + } + } + + if (fread(&len, sizeof(int), 1, fp[j])) { + fread(buf, len, 1, fp[j]); + fwrite(buf, len, 1, ofp); + } + + if (min && ++count != min) { + fprintf(stderr, "got %ld. expected %ld\n", min, count); + dropped += min - count ; + count = min; + } + + if (fread (buf, TIMESTAMP_SIZE, 1, fp[j])) + num[j] = *((int *)buf); + else + num[j] = 0; + } while (min); + + for (i = 0; i < ncpus; i++) + fclose (fp[i]); + fclose (ofp); + printf ("sequence had %d drops\n", dropped); + return 0; +} diff --git a/runtime/staprun/stp_merge.c b/runtime/staprun/stp_merge.c deleted file mode 100644 index 225d8d79..00000000 --- a/runtime/staprun/stp_merge.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * stap_merge.c - systemtap merge program - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (C) Red Hat Inc, 2005-2007 - * - */ - -#include -#include -#include -#include -#include - -static void usage (char *prog) -{ - fprintf(stderr, "%s [-o output_filename] input_files ...\n", prog); - exit(1); -} - -#define TIMESTAMP_SIZE (sizeof(int)) -#define NR_CPUS 256 - -int main (int argc, char *argv[]) -{ - char *outfile_name = NULL; - char buf[8192]; - int c, i, j, dropped=0; - long count=0, min, num[NR_CPUS]; - FILE *ofp, *fp[NR_CPUS]; - int ncpus, len; - - while ((c = getopt (argc, argv, "o:")) != EOF) { - switch (c) { - case 'o': - outfile_name = optarg; - break; - default: - usage(argv[0]); - } - } - - if (optind == argc) - usage (argv[0]); - - i = 0; - while (optind < argc) { - fp[i] = fopen(argv[optind++], "r"); - if (!fp[i]) { - fprintf(stderr, "error opening file %s.\n", argv[optind - 1]); - return -1; - } - if (fread (buf, TIMESTAMP_SIZE, 1, fp[i])) - num[i] = *((int *)buf); - else - num[i] = 0; - i++; - } - ncpus = i; - - if (!outfile_name) - ofp = stdout; - else { - ofp = fopen(outfile_name, "w"); - if (!ofp) { - fprintf(stderr, "ERROR: couldn't open output file %s: errcode = %s\n", - outfile_name, strerror(errno)); - return -1; - } - } - - do { - min = num[0]; - j = 0; - for (i = 1; i < ncpus; i++) { - if (min == 0 || (num[i] && num[i] < min)) { - min = num[i]; - j = i; - } - } - - if (fread(&len, sizeof(int), 1, fp[j])) { - fread(buf, len, 1, fp[j]); - fwrite(buf, len, 1, ofp); - } - - if (min && ++count != min) { - fprintf(stderr, "got %ld. expected %ld\n", min, count); - dropped += min - count ; - count = min; - } - - if (fread (buf, TIMESTAMP_SIZE, 1, fp[j])) - num[j] = *((int *)buf); - else - num[j] = 0; - } while (min); - - fputs ("\n", ofp); - - for (i = 0; i < ncpus; i++) - fclose (fp[i]); - fclose (ofp); - printf ("sequence had %d drops\n", dropped); - return 0; -} -- cgit