annotate rvinterf/ctracedec/processlog.c @ 965:bd873572ef2c

fc-shell: one-shot command mode implemented
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sat, 07 Nov 2015 00:00:46 +0000
parents 4c6e7ada647b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
858
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module contains the code that processes rvtdump/rvinterf log files
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 * at the high level and identifies which lines are compressed traces.
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 */
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <ctype.h>
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <strings.h>
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <stdlib.h>
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 is_logline_ctrace(line)
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 char *line;
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14 {
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 char *cp = line;
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17 if (*cp++ != '[')
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19 if (!isdigit(*cp++))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 if (!isdigit(*cp++))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 if (*cp++ != ':')
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 if (!isdigit(*cp++))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 if (!isdigit(*cp++))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 if (*cp++ != ':')
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 if (!isdigit(*cp++))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 if (!isdigit(*cp++))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 if (strncmp(cp, "] GPF trace ", 12))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 cp += 12;
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 while (isalpha(*cp)) {
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 while (*cp && !isspace(*cp))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 cp++;
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 if (isspace(*cp))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 cp++;
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 else
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 }
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 if (isdigit(*cp))
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 return(cp - line);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 else
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 }
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 process_log_file(filename)
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 char *filename;
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 {
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 FILE *f;
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 char linebuf[512], *cp;
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 int lineno, i;
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 f = fopen(filename, "r");
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 if (!f) {
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 perror(filename);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 exit(1);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 }
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 for (lineno = 1; fgets(linebuf, sizeof linebuf, f); lineno++) {
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 cp = index(linebuf, '\n');
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 if (!cp) {
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 fprintf(stderr,
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 "error: %s line %d is too long or unterminated\n",
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 filename, lineno);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 exit(1);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 }
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 *cp = '\0';
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 i = is_logline_ctrace(linebuf);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 if (i)
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 process_ctrace_line(linebuf, i, filename, lineno);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 else
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77 puts(linebuf);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 }
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
79 fclose(f);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 return(0);
4c6e7ada647b compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 }