diff options
author | hunt <hunt> | 2005-07-28 17:35:11 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-07-28 17:35:11 +0000 |
commit | b290c791d701b5841ed824fddfce3f949b0a7b61 (patch) | |
tree | 81c1f974a95bff44ee53ea026fd4e106d7e0ed91 | |
parent | 42ee08b55b2f7a12b26f2049d672a1b563f064a4 (diff) | |
download | systemtap-steved-b290c791d701b5841ed824fddfce3f949b0a7b61.tar.gz systemtap-steved-b290c791d701b5841ed824fddfce3f949b0a7b61.tar.xz systemtap-steved-b290c791d701b5841ed824fddfce3f949b0a7b61.zip |
2005-07-28 Martin Hunt <hunt@redhat.com>
* stp_dump.c: New file.
-rw-r--r-- | runtime/stpd/Makefile | 5 | ||||
-rw-r--r-- | runtime/stpd/stp_dump.c | 82 | ||||
-rw-r--r-- | runtime/stpd/stp_merge.c | 3 |
3 files changed, 88 insertions, 2 deletions
diff --git a/runtime/stpd/Makefile b/runtime/stpd/Makefile index 3446ac7b..8aaabb49 100644 --- a/runtime/stpd/Makefile +++ b/runtime/stpd/Makefile @@ -1,4 +1,4 @@ -all: stpd stp_merge +all: stpd stp_merge stp_dump stpd: stpd.c librelay.c gcc -Wall -O3 -o stpd stpd.c librelay.c -lpthread @@ -6,5 +6,8 @@ stpd: stpd.c librelay.c stp_merge: stp_merge.c gcc -Wall -O3 -o stp_merge stp_merge.c +stp_dump: stp_dump.c + gcc -Wall -O3 -o stp_dump stp_dump.c + clean: /bin/rm -f stpd stp_merge *.o *~ diff --git a/runtime/stpd/stp_dump.c b/runtime/stpd/stp_dump.c new file mode 100644 index 00000000..74dbc012 --- /dev/null +++ b/runtime/stpd/stp_dump.c @@ -0,0 +1,82 @@ +/* + * stp_dump.c - stp data dump 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) Redhat Inc, 2005 + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> + +static void usage (char *prog) +{ + fprintf(stderr, "%s input_file \n", prog); + exit(1); +} + +#define TIMESTAMP_SIZE 11 + +int main (int argc, char *argv[]) +{ + char buf[32]; + int c, seq, lastseq = 0; + FILE *fp; + + if (argc != 2) + usage(argv[0]); + + fp = fopen(argv[1], "r"); + if (!fp) { + fprintf(stderr, "ERROR: couldn't open input file %s: errcode = %s\n", + argv[1], strerror(errno)); + return -1; + } + + while (1) { + int numbytes = 0; + + if (fread (buf, TIMESTAMP_SIZE, 1, fp)) + seq = strtoul (buf, NULL, 10); + else + break; + + if (seq < lastseq) + fprintf(stderr, "WARNING: seq %d followed by %d\n", lastseq, seq); + lastseq = seq; + + while (1) { + c = fgetc_unlocked(fp); + if (c == 0 || c == EOF) + break; + numbytes++; + } + printf ("<%d><%d BYTES>", seq, numbytes); + if (c == 0) + printf ("<0>\n"); + else { + printf ("<EOF>\n"); + break; + } + } + + printf ("DONE\n"); + fclose (fp); + return 0; +} diff --git a/runtime/stpd/stp_merge.c b/runtime/stpd/stp_merge.c index e9b449d2..e9c8b98c 100644 --- a/runtime/stpd/stp_merge.c +++ b/runtime/stpd/stp_merge.c @@ -98,8 +98,9 @@ int main (int argc, char *argv[]) break; fputc_unlocked (c, ofp); } + if (min && ++count != min) { - //fprintf(stderr, "got %ld. expected %ld\n", min, count); + fprintf(stderr, "got %ld. expected %ld\n", min, count); dropped += min - count ; count = min; } |