FreeCalypso > hg > freecalypso-sw
annotate rvinterf/ctracedec/decode.c @ 875:dab341e172de
fc-shell: sysprim sending (sp command) implemented
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 30 May 2015 07:41:23 +0000 |
parents | 4c6e7ada647b |
children |
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 implements the actual decoding of compressed traces. |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
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 #include <sys/types.h> |
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 extern char *str2ind_tab_filename; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 extern int str2ind_array_size; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 extern char **str2ind_orig_strings; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 extern char **str2ind_param_strings; |
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 #define MAX_PRINTF_PARAMS 16 |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 static int cindex, cindex_nchars; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 static u_char param_bytes_array[256]; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 static int param_bytes_count; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 static char *format_string, *param_type_string; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 static int num_printf_params; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 static u_long printf_params[MAX_PRINTF_PARAMS]; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 static char output_buf[2048]; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 decode_hex_digit(c) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 if (isdigit(c)) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 return(c - '0'); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 else if (isupper(c)) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 return(c - 'A' + 10); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 else |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 return(c - 'a' + 10); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 static int |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 decode_idx_and_params(line) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 char *line; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 char *cp; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 u_char *dp; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 for (cp = line; isdigit(*cp); cp++) |
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 (*cp && *cp != ' ') |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 return(-1); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 cindex = atoi(line); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 cindex_nchars = cp - line; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 for (dp = param_bytes_array; *cp; ) { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 if (*cp++ != ' ') |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 return(-1); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 if (!isxdigit(cp[0]) || !isxdigit(cp[1])) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 return(-1); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 *dp++ = decode_hex_digit(cp[0]) << 4 | decode_hex_digit(cp[1]); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 cp += 2; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 param_bytes_count = dp - param_bytes_array; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 return(0); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 static void |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 decode_parameters(filename_for_errs, lineno_for_errs) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 char *filename_for_errs; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 int pi, type; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 u_char *bp, *endp; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 bp = param_bytes_array; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 endp = bp + param_bytes_count; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 for (pi = 0; pi < num_printf_params; pi++) { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 type = param_type_string[pi]; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 switch (type) { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 case 'c': |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 if (bp >= endp) { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 wrong_param_byte_count: fprintf(stderr, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 "%s line %d: wrong number of parameter bytes for %s entry #%d\n", |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 filename_for_errs, lineno_for_errs, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 str2ind_tab_filename, cindex); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 exit(1); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 printf_params[pi] = *bp++; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 continue; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 case 'i': |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 case 'p': |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 case '*': |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 if (bp > endp - 4) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 goto wrong_param_byte_count; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 printf_params[pi] = (u_long) bp[0] | |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 (u_long) bp[1] << 8 | |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 (u_long) bp[2] << 16 | |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 (u_long) bp[3] << 24; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 bp += 4; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 continue; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 case 's': |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 printf_params[pi] = (u_long) bp; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 for (;;) { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 if (bp >= endp) { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 fprintf(stderr, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 "%s line %d: unterminated string parameter in compressed trace\n", |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 filename_for_errs, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 lineno_for_errs); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 exit(1); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 if (!*bp++) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 break; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 continue; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 default: |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 fprintf(stderr, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 "%s entry #%d: parameter type \'%c\' not supported\n", |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 str2ind_tab_filename, cindex, type); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 exit(1); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 if (bp != endp) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 goto wrong_param_byte_count; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 process_ctrace_line(line, cindex_offset, filename_for_errs, lineno_for_errs) |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 char *line, *filename_for_errs; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 if (decode_idx_and_params(line + cindex_offset) < 0) { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 fprintf(stderr, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 "%s line %d: unable to decode compressed trace line\n", |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 filename_for_errs, lineno_for_errs); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 exit(1); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 if (cindex >= str2ind_array_size) { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 fprintf(stderr, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 "%s line %d: index %d exceeds the range of %s\n", |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 filename_for_errs, lineno_for_errs, cindex, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 str2ind_tab_filename); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 exit(1); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 format_string = str2ind_orig_strings[cindex]; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 param_type_string = str2ind_param_strings[cindex]; |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 num_printf_params = strlen(param_type_string); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 if (num_printf_params > MAX_PRINTF_PARAMS) { |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 fprintf(stderr, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 "error: entry #%d in %s has too many parameters\n", |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 cindex, str2ind_tab_filename); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 exit(1); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 } |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 decode_parameters(filename_for_errs, lineno_for_errs); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 ind2str_doprnt(format_string, printf_params, output_buf); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 printf("%.*s \"%s\"\n", cindex_offset + cindex_nchars, line, |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 output_buf); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 return(0); |
4c6e7ada647b
compressed trace decoder almost fully implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 } |