FreeCalypso > hg > freecalypso-tools
comparison rvinterf/ctracedec/processlog.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 11 Jun 2016 00:13:35 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:e7502631a0f9 |
|---|---|
| 1 /* | |
| 2 * This module contains the code that processes rvtdump/rvinterf log files | |
| 3 * at the high level and identifies which lines are compressed traces. | |
| 4 */ | |
| 5 | |
| 6 #include <stdio.h> | |
| 7 #include <ctype.h> | |
| 8 #include <string.h> | |
| 9 #include <strings.h> | |
| 10 #include <stdlib.h> | |
| 11 | |
| 12 is_logline_ctrace(line) | |
| 13 char *line; | |
| 14 { | |
| 15 char *cp = line; | |
| 16 | |
| 17 if (*cp++ != '[') | |
| 18 return(0); | |
| 19 if (!isdigit(*cp++)) | |
| 20 return(0); | |
| 21 if (!isdigit(*cp++)) | |
| 22 return(0); | |
| 23 if (*cp++ != ':') | |
| 24 return(0); | |
| 25 if (!isdigit(*cp++)) | |
| 26 return(0); | |
| 27 if (!isdigit(*cp++)) | |
| 28 return(0); | |
| 29 if (*cp++ != ':') | |
| 30 return(0); | |
| 31 if (!isdigit(*cp++)) | |
| 32 return(0); | |
| 33 if (!isdigit(*cp++)) | |
| 34 return(0); | |
| 35 if (strncmp(cp, "] GPF trace ", 12)) | |
| 36 return(0); | |
| 37 cp += 12; | |
| 38 while (isalpha(*cp)) { | |
| 39 while (*cp && !isspace(*cp)) | |
| 40 cp++; | |
| 41 if (isspace(*cp)) | |
| 42 cp++; | |
| 43 else | |
| 44 return(0); | |
| 45 } | |
| 46 if (isdigit(*cp)) | |
| 47 return(cp - line); | |
| 48 else | |
| 49 return(0); | |
| 50 } | |
| 51 | |
| 52 process_log_file(filename) | |
| 53 char *filename; | |
| 54 { | |
| 55 FILE *f; | |
| 56 char linebuf[512], *cp; | |
| 57 int lineno, i; | |
| 58 | |
| 59 f = fopen(filename, "r"); | |
| 60 if (!f) { | |
| 61 perror(filename); | |
| 62 exit(1); | |
| 63 } | |
| 64 for (lineno = 1; fgets(linebuf, sizeof linebuf, f); lineno++) { | |
| 65 cp = index(linebuf, '\n'); | |
| 66 if (!cp) { | |
| 67 fprintf(stderr, | |
| 68 "error: %s line %d is too long or unterminated\n", | |
| 69 filename, lineno); | |
| 70 exit(1); | |
| 71 } | |
| 72 *cp = '\0'; | |
| 73 i = is_logline_ctrace(linebuf); | |
| 74 if (i) | |
| 75 process_ctrace_line(linebuf, i, filename, lineno); | |
| 76 else | |
| 77 puts(linebuf); | |
| 78 } | |
| 79 fclose(f); | |
| 80 return(0); | |
| 81 } |
