Bug Summary

File:src/usr.sbin/btrace/obj/bt_parse.c
Warning:line 1498, column 26
Use of zero-allocated memory

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name bt_parse.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/usr.sbin/btrace/obj -resource-dir /usr/local/lib/clang/13.0.0 -D PTRACE -D KTRACE -D ACCOUNTING -D NFSCLIENT -D SYSVSHM -D SYSVSEM -D SYSVMSG -I /usr/src/usr.sbin/btrace -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -Wno-unused -fdebug-compilation-dir=/usr/src/usr.sbin/btrace/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c bt_parse.c
1#include <stdlib.h>
2#include <string.h>
3#define YYBYACC1 1
4#define YYMAJOR1 1
5#define YYMINOR9 9
6#define YYLEXyylex() yylex()
7#define YYEMPTY-1 -1
8#define yyclearin(yychar=(-1)) (yychar=(YYEMPTY-1))
9#define yyerrok(yyerrflag=0) (yyerrflag=0)
10#define YYRECOVERING()(yyerrflag!=0) (yyerrflag!=0)
11#define YYPREFIX"yy" "yy"
12#line 32 "/usr/src/usr.sbin/btrace/bt_parse.y"
13#include <sys/queue.h>
14
15#include <assert.h>
16#include <ctype.h>
17#include <err.h>
18#include <limits.h>
19#include <stdarg.h>
20#include <stdint.h>
21#include <stdio.h>
22
23#include "bt_parser.h"
24
25/* Name for the default map @[], hopefully nobody will use this one ;) */
26#define UNNAMED_MAP"___unnamed_map_doesnt_have_any_name" "___unnamed_map_doesnt_have_any_name"
27
28/* Number of rules to evaluate. */
29struct bt_ruleq g_rules = TAILQ_HEAD_INITIALIZER(g_rules){ ((void *)0), &(g_rules).tqh_first };
30
31/* Number of probes except BEGIN/END. */
32int g_nprobes;
33
34/* List of global variables, including maps. */
35SLIST_HEAD(, bt_var)struct { struct bt_var *slh_first; } g_variables;
36
37/* List of local variables, cleaned for each new rule. */
38SLIST_HEAD(, bt_var)struct { struct bt_var *slh_first; } l_variables;
39
40struct bt_arg g_nullba = BA_INITIALIZER(0, B_AT_LONG){ { ((void *)0) }, (void *)(0), ((void *)0), (B_AT_LONG) };
41struct bt_arg g_maxba = BA_INITIALIZER(LONG_MAX, B_AT_LONG){ { ((void *)0) }, (void *)(9223372036854775807L), ((void *)0
), (B_AT_LONG) }
;
42
43struct bt_rule *br_new(struct bt_probe *, struct bt_filter *,
44 struct bt_stmt *);
45struct bt_probe *bp_new(const char *, const char *, const char *, int32_t);
46struct bt_arg *ba_append(struct bt_arg *, struct bt_arg *);
47struct bt_arg *ba_op(enum bt_argtype, struct bt_arg *, struct bt_arg *);
48struct bt_stmt *bs_new(enum bt_action, struct bt_arg *, struct bt_var *);
49struct bt_stmt *bs_append(struct bt_stmt *, struct bt_stmt *);
50
51struct bt_var *bg_lookup(const char *);
52struct bt_stmt *bg_store(const char *, struct bt_arg *);
53struct bt_arg *bg_find(const char *);
54struct bt_var *bg_get(const char *);
55
56struct bt_var *bl_lookup(const char *);
57struct bt_stmt *bl_store(const char *, struct bt_arg *);
58struct bt_arg *bl_find(const char *);
59
60struct bt_arg *bm_find(const char *, struct bt_arg *);
61struct bt_stmt *bm_insert(const char *, struct bt_arg *, struct bt_arg *);
62struct bt_stmt *bm_op(enum bt_action, struct bt_arg *, struct bt_arg *);
63
64struct bt_stmt *bh_inc(const char *, struct bt_arg *, struct bt_arg *);
65
66/*
67 * Lexer
68 */
69const char *pbuf;
70size_t plen;
71size_t pindex;
72int perrors = 0;
73
74typedef struct {
75 union {
76 long number;
77 int i;
78 const char *string;
79 struct bt_probe *probe;
80 struct bt_filter *filter;
81 struct bt_stmt *stmt;
82 struct bt_arg *arg;
83 } v;
84 const char *filename;
85 int lineno;
86 int colno;
87} yystype;
88#define YYSTYPEyystype yystype
89
90static void yyerror(const char *, ...);
91static int yylex(void);
92
93static int pflag;
94#line 95 "bt_parse.c"
95#define ERROR257 257
96#define ENDFILT258 258
97#define OP_EQ259 259
98#define OP_NE260 260
99#define OP_LE261 261
100#define OP_LT262 262
101#define OP_GE263 263
102#define OP_GT264 264
103#define OP_LAND265 265
104#define OP_LOR266 266
105#define BUILTIN267 267
106#define BEGIN268 268
107#define END269 269
108#define HZ270 270
109#define IF271 271
110#define F_DELETE272 272
111#define F_PRINT273 273
112#define MFUNC274 274
113#define FUNC0275 275
114#define FUNC1276 276
115#define FUNCN277 277
116#define OP1278 278
117#define OP2279 279
118#define OP4280 280
119#define MOP0281 281
120#define MOP1282 282
121#define STRING283 283
122#define CSTRING284 284
123#define NUMBER285 285
124#define STR286 286
125#define YYERRCODE256 256
126const short yylhs[] =
127 { -1,
128 0, 0, 0, 0, 25, 3, 3, 4, 4, 26,
129 5, 5, 6, 6, 18, 18, 1, 1, 2, 15,
130 16, 16, 16, 13, 13, 7, 7, 19, 19, 19,
131 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
132 20, 20, 21, 21, 21, 22, 22, 23, 23, 23,
133 23, 23, 23, 23, 24, 24, 14, 14, 17, 17,
134 27, 27, 9, 9, 9, 9, 9, 9, 9, 9,
135 9, 9, 9, 9, 10, 11, 11, 11, 11, 12,
136 12, 8,
137};
138const short yylen[] =
139 { 2,
140 0, 2, 2, 2, 3, 1, 1, 3, 1, 0,
141 2, 1, 5, 5, 2, 2, 2, 1, 2, 4,
142 3, 4, 1, 1, 1, 0, 3, 3, 3, 1,
143 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
144 3, 1, 3, 3, 1, 1, 1, 3, 1, 1,
145 1, 1, 1, 1, 4, 6, 1, 3, 1, 3,
146 0, 1, 2, 3, 3, 6, 4, 4, 4, 3,
147 4, 4, 6, 8, 5, 2, 2, 1, 1, 4,
148 2, 3,
149};
150const short yydefred[] =
151 { 1,
152 0, 4, 6, 7, 2, 12, 0, 9, 3, 0,
153 0, 0, 0, 0, 11, 8, 50, 49, 0, 0,
154 0, 0, 0, 46, 53, 51, 0, 0, 0, 52,
155 45, 54, 0, 5, 0, 19, 15, 16, 17, 0,
156 0, 0, 27, 0, 0, 0, 0, 0, 0, 0,
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 0, 0, 0, 0, 0, 0, 0, 0, 0, 79,
159 78, 0, 0, 0, 48, 0, 0, 24, 57, 0,
160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
161 0, 0, 0, 0, 44, 43, 0, 0, 0, 0,
162 0, 0, 0, 62, 63, 0, 0, 0, 82, 77,
163 76, 0, 0, 0, 55, 0, 20, 0, 0, 0,
164 0, 0, 0, 47, 0, 70, 0, 0, 0, 0,
165 0, 64, 65, 14, 13, 0, 58, 0, 71, 0,
166 72, 69, 68, 67, 0, 0, 0, 56, 0, 0,
167 75, 60, 0, 0, 0, 0, 81, 0, 0, 23,
168 66, 73, 0, 0, 0, 0, 0, 80, 21, 0,
169 74, 22,
170};
171const short yydgoto[] =
172 { 1,
173 23, 24, 6, 7, 8, 15, 13, 34, 70, 71,
174 72, 151, 79, 80, 25, 161, 122, 26, 81, 28,
175 29, 30, 31, 32, 9, 10, 105,
176};
177const short yysindex[] =
178 { 0,
179 -10, 0, 0, 0, 0, 0, -17, 0, 0, -247,
180 -259, -20, -76, 4, 0, 0, 0, 0, -16, -241,
181 -20, 9, -40, 0, 0, 0, -226, 838, -14, 0,
182 0, 0, 127, 0, -252, 0, 0, 0, 0, -39,
183 48, -23, 0, -20, -20, -20, -20, -20, -20, -20,
184 -20, -20, -20, -20, -20, -20, -20, -20, 45, 49,
185 52, 53, 56, 57, 61, -181, 94, -53, 46, 0,
186 0, 85, 55, 58, 0, -31, -7, 0, 0, -30,
187 -201, 838, 838, -14, -14, -14, -14, -14, -14, -14,
188 -14, -14, -14, -14, 0, 0, -20, 44, -20, -12,
189 79, -23, -23, 0, 0, -23, -35, -23, 0, 0,
190 0, -162, -159, -23, 0, -23, 0, -26, -40, 87,
191 -21, 90, -201, 0, 91, 0, 93, 2, -18, 95,
192 99, 0, 0, 0, 0, 100, 0, 330, 0, -23,
193 0, 0, 0, 0, 81, -23, -23, 0, 482, 86,
194 0, 0, -29, 106, 96, 97, 0, 112, 117, 0,
195 0, 0, -23, 25, 118, -23, 17, 0, 0, 121,
196 0, 0,};
197const short yyrindex[] =
198 { 0,
199 -125, 0, 0, 0, 0, 0, 41, 0, 0, 0,
200 -125, 0, 0, 0, 0, 0, 0, 0, 0, 12,
201 0, 0, 36, 0, 0, 0, 0, 796, 74, 0,
202 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
203 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
204 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
205 0, 0, 0, 0, 0, 0, 154, 0, 0, 0,
206 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
207 50, 818, 849, 110, 352, 374, 396, 420, 442, 464,
208 706, 728, 750, 774, 0, 0, 0, 0, 0, 0,
209 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
210 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
211 882, 0, 125, 0, 0, 0, 0, 0, 0, 0,
212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
214 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
215 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
216 0, 0,};
217const short yygindex[] =
218 { 0,
219 27, -27, 0, 0, 159, 0, 0, 0, -51, 101,
220 0, 0, 408, -81, 73, 0, 0, 131, -9, 22,
221 529, 77, 11, 0, 0, 0, 0,
222};
223#define YYTABLESIZE1148 1148
224const short yytable[] =
225 { 5,
226 19, 75, 27, 38, 21, 69, 19, 107, 3, 4,
227 21, 40, 19, 116, 138, 19, 21, 73, 38, 21,
228 110, 128, 140, 66, 129, 116, 11, 58, 20, 12,
229 74, 43, 57, 115, 20, 14, 114, 106, 44, 45,
230 20, 39, 144, 20, 69, 116, 33, 18, 41, 18,
231 42, 20, 18, 18, 18, 18, 18, 171, 18, 68,
232 116, 35, 117, 44, 45, 82, 83, 95, 96, 42,
233 18, 47, 18, 47, 145, 18, 47, 47, 47, 47,
234 47, 167, 47, 76, 97, 25, 150, 118, 98, 123,
235 25, 99, 100, 25, 47, 101, 102, 156, 68, 47,
236 103, 36, 18, 104, 18, 18, 108, 20, 25, 42,
237 69, 42, 112, 25, 42, 113, 42, 42, 42, 126,
238 66, 69, 134, 135, 119, 121, 124, 139, 47, 47,
239 141, 142, 42, 143, 146, 18, 18, 42, 147, 163,
240 148, 153, 25, 67, 157, 31, 162, 31, 20, 168,
241 31, 165, 31, 31, 31, 164, 166, 10, 169, 47,
242 47, 172, 66, 26, 68, 59, 42, 42, 31, 16,
243 120, 77, 111, 31, 25, 68, 125, 0, 0, 0,
244 0, 0, 0, 0, 0, 67, 0, 0, 0, 61,
245 20, 0, 0, 0, 0, 0, 0, 42, 42, 0,
246 0, 0, 31, 31, 0, 0, 0, 0, 0, 109,
247 0, 0, 61, 0, 0, 0, 0, 61, 0, 0,
248 0, 0, 0, 0, 0, 44, 45, 0, 0, 0,
249 0, 17, 0, 31, 31, 0, 0, 17, 44, 45,
250 0, 0, 130, 17, 131, 2, 17, 0, 78, 18,
251 22, 158, 159, 37, 78, 18, 22, 3, 4, 0,
252 78, 18, 22, 0, 18, 22, 36, 0, 37, 18,
253 18, 18, 18, 18, 18, 18, 18, 18, 61, 0,
254 0, 0, 18, 18, 18, 18, 18, 18, 18, 0,
255 0, 0, 0, 47, 47, 47, 47, 47, 47, 47,
256 47, 47, 0, 0, 0, 0, 47, 47, 47, 47,
257 47, 47, 47, 0, 0, 0, 0, 0, 0, 0,
258 25, 25, 25, 25, 25, 25, 25, 0, 0, 0,
259 0, 42, 42, 42, 42, 42, 42, 42, 42, 42,
260 0, 0, 0, 0, 42, 42, 42, 42, 42, 42,
261 42, 0, 0, 0, 0, 59, 60, 61, 62, 63,
262 64, 65, 0, 0, 0, 66, 0, 31, 31, 31,
263 31, 31, 31, 31, 31, 31, 0, 0, 0, 0,
264 31, 31, 31, 31, 31, 31, 31, 32, 67, 32,
265 0, 0, 32, 20, 32, 32, 32, 59, 60, 61,
266 62, 63, 64, 65, 0, 0, 0, 0, 0, 33,
267 32, 33, 0, 0, 33, 32, 33, 33, 33, 0,
268 0, 0, 0, 0, 61, 61, 61, 61, 61, 61,
269 61, 34, 33, 34, 0, 0, 34, 33, 34, 34,
270 34, 0, 0, 0, 32, 32, 0, 0, 0, 0,
271 0, 0, 149, 0, 34, 35, 0, 35, 0, 34,
272 35, 0, 35, 35, 35, 0, 33, 33, 0, 0,
273 0, 0, 0, 0, 0, 32, 32, 36, 35, 36,
274 0, 0, 36, 35, 36, 36, 36, 0, 34, 34,
275 0, 0, 0, 0, 0, 0, 0, 33, 33, 37,
276 36, 37, 0, 0, 37, 36, 37, 37, 37, 127,
277 0, 0, 35, 35, 132, 133, 0, 66, 0, 34,
278 34, 136, 37, 137, 0, 0, 0, 37, 0, 0,
279 0, 0, 0, 0, 36, 36, 0, 0, 0, 0,
280 67, 0, 0, 35, 35, 20, 0, 152, 0, 0,
281 0, 0, 0, 154, 155, 0, 37, 37, 0, 0,
282 160, 0, 0, 0, 0, 36, 36, 0, 0, 0,
283 0, 0, 0, 170, 84, 85, 86, 87, 88, 89,
284 90, 91, 92, 93, 94, 0, 0, 37, 37, 0,
285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
286 0, 60, 61, 62, 63, 64, 65, 0, 0, 32,
287 32, 32, 32, 32, 32, 32, 32, 32, 0, 0,
288 0, 0, 32, 32, 32, 32, 32, 32, 32, 0,
289 0, 33, 33, 33, 33, 33, 33, 33, 33, 33,
290 0, 0, 0, 0, 33, 33, 33, 33, 33, 33,
291 33, 0, 0, 34, 34, 34, 34, 34, 34, 34,
292 34, 34, 0, 0, 0, 0, 34, 34, 34, 34,
293 34, 34, 34, 0, 0, 0, 0, 35, 35, 35,
294 35, 35, 35, 35, 35, 35, 0, 0, 0, 0,
295 35, 35, 35, 35, 35, 35, 35, 0, 0, 36,
296 36, 36, 36, 36, 36, 36, 36, 36, 0, 0,
297 0, 0, 36, 36, 36, 36, 36, 36, 36, 0,
298 0, 37, 37, 37, 37, 37, 37, 37, 37, 37,
299 0, 0, 0, 0, 37, 37, 37, 37, 37, 37,
300 37, 38, 0, 38, 0, 0, 38, 0, 38, 38,
301 38, 0, 0, 60, 61, 62, 63, 64, 65, 0,
302 0, 0, 0, 39, 38, 39, 0, 0, 39, 38,
303 39, 39, 39, 0, 0, 0, 0, 0, 0, 0,
304 0, 0, 0, 0, 0, 40, 39, 40, 0, 0,
305 40, 39, 40, 40, 40, 0, 0, 0, 38, 38,
306 0, 0, 0, 0, 0, 0, 0, 0, 40, 41,
307 0, 41, 0, 40, 41, 0, 41, 41, 41, 0,
308 39, 39, 0, 0, 0, 0, 0, 0, 0, 38,
309 38, 30, 41, 0, 0, 0, 30, 41, 0, 30,
310 0, 0, 40, 40, 0, 0, 0, 0, 0, 0,
311 0, 39, 39, 28, 30, 0, 0, 0, 28, 30,
312 0, 28, 0, 0, 0, 0, 41, 41, 0, 0,
313 0, 0, 0, 40, 40, 54, 28, 0, 0, 0,
314 52, 28, 53, 0, 29, 0, 0, 0, 30, 29,
315 0, 0, 29, 0, 0, 0, 0, 41, 41, 0,
316 0, 0, 0, 0, 0, 0, 0, 29, 0, 0,
317 28, 0, 29, 0, 0, 0, 0, 0, 0, 47,
318 30, 0, 47, 47, 47, 0, 47, 0, 47, 0,
319 0, 55, 0, 0, 0, 0, 0, 0, 0, 0,
320 0, 29, 28, 0, 0, 0, 0, 0, 0, 0,
321 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
322 0, 56, 0, 38, 38, 38, 38, 38, 38, 38,
323 38, 38, 0, 29, 0, 47, 38, 38, 38, 38,
324 38, 38, 38, 0, 0, 39, 39, 39, 39, 39,
325 39, 39, 39, 39, 0, 0, 0, 0, 39, 39,
326 39, 39, 39, 39, 39, 47, 0, 40, 40, 40,
327 40, 40, 40, 40, 40, 40, 0, 0, 0, 0,
328 40, 40, 40, 40, 40, 40, 40, 0, 0, 0,
329 0, 41, 41, 41, 41, 41, 41, 41, 41, 41,
330 0, 0, 0, 0, 41, 41, 41, 41, 41, 41,
331 41, 0, 0, 30, 0, 0, 0, 0, 0, 0,
332 30, 30, 0, 0, 0, 0, 30, 30, 30, 30,
333 30, 30, 30, 0, 0, 28, 0, 0, 0, 0,
334 0, 0, 28, 28, 0, 0, 0, 0, 28, 28,
335 28, 28, 28, 28, 28, 0, 46, 47, 48, 49,
336 50, 51, 0, 0, 0, 0, 29, 0, 0, 0,
337 0, 0, 0, 29, 29, 0, 0, 0, 0, 29,
338 29, 29, 29, 29, 29, 29, 0, 0, 0, 0,
339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
340 47, 47, 47, 47, 47, 47, 47, 47,
341};
342const short yycheck[] =
343 { 10,
344 36, 41, 12, 35, 40, 33, 36, 61, 268, 269,
345 40, 21, 36, 44, 41, 36, 40, 270, 35, 40,
346 72, 103, 44, 36, 106, 44, 44, 42, 64, 47,
347 283, 258, 47, 41, 64, 283, 44, 91, 265, 266,
348 64, 283, 41, 64, 72, 44, 123, 36, 40, 38,
349 91, 64, 41, 42, 43, 44, 45, 41, 47, 33,
350 44, 58, 93, 265, 266, 44, 45, 57, 58, 91,
351 59, 36, 61, 38, 93, 64, 41, 42, 43, 44,
352 45, 163, 47, 36, 40, 36, 138, 97, 40, 99,
353 41, 40, 40, 44, 59, 40, 40, 149, 72, 64,
354 40, 283, 91, 10, 93, 94, 61, 64, 59, 36,
355 138, 38, 58, 64, 41, 58, 43, 44, 45, 41,
356 36, 149, 285, 283, 98, 99, 100, 41, 93, 94,
357 41, 41, 59, 41, 40, 124, 125, 64, 40, 44,
358 41, 61, 93, 59, 59, 36, 41, 38, 64, 125,
359 41, 40, 43, 44, 45, 59, 40, 283, 41, 124,
360 125, 41, 36, 123, 138, 41, 93, 94, 59, 11,
361 98, 41, 72, 64, 125, 149, 100, -1, -1, -1,
362 -1, -1, -1, -1, -1, 59, -1, -1, -1, 36,
363 64, -1, -1, -1, -1, -1, -1, 124, 125, -1,
364 -1, -1, 93, 94, -1, -1, -1, -1, -1, 125,
365 -1, -1, 59, -1, -1, -1, -1, 64, -1, -1,
366 -1, -1, -1, -1, -1, 265, 266, -1, -1, -1,
367 -1, 267, -1, 124, 125, -1, -1, 267, 265, 266,
368 -1, -1, 278, 267, 280, 256, 267, -1, 284, 285,
369 286, 281, 282, 285, 284, 285, 286, 268, 269, -1,
370 284, 285, 286, -1, 285, 286, 283, -1, 285, 258,
371 259, 260, 261, 262, 263, 264, 265, 266, 125, -1,
372 -1, -1, 271, 272, 273, 274, 275, 276, 277, -1,
373 -1, -1, -1, 258, 259, 260, 261, 262, 263, 264,
374 265, 266, -1, -1, -1, -1, 271, 272, 273, 274,
375 275, 276, 277, -1, -1, -1, -1, -1, -1, -1,
376 271, 272, 273, 274, 275, 276, 277, -1, -1, -1,
377 -1, 258, 259, 260, 261, 262, 263, 264, 265, 266,
378 -1, -1, -1, -1, 271, 272, 273, 274, 275, 276,
379 277, -1, -1, -1, -1, 271, 272, 273, 274, 275,
380 276, 277, -1, -1, -1, 36, -1, 258, 259, 260,
381 261, 262, 263, 264, 265, 266, -1, -1, -1, -1,
382 271, 272, 273, 274, 275, 276, 277, 36, 59, 38,
383 -1, -1, 41, 64, 43, 44, 45, 271, 272, 273,
384 274, 275, 276, 277, -1, -1, -1, -1, -1, 36,
385 59, 38, -1, -1, 41, 64, 43, 44, 45, -1,
386 -1, -1, -1, -1, 271, 272, 273, 274, 275, 276,
387 277, 36, 59, 38, -1, -1, 41, 64, 43, 44,
388 45, -1, -1, -1, 93, 94, -1, -1, -1, -1,
389 -1, -1, 123, -1, 59, 36, -1, 38, -1, 64,
390 41, -1, 43, 44, 45, -1, 93, 94, -1, -1,
391 -1, -1, -1, -1, -1, 124, 125, 36, 59, 38,
392 -1, -1, 41, 64, 43, 44, 45, -1, 93, 94,
393 -1, -1, -1, -1, -1, -1, -1, 124, 125, 36,
394 59, 38, -1, -1, 41, 64, 43, 44, 45, 102,
395 -1, -1, 93, 94, 107, 108, -1, 36, -1, 124,
396 125, 114, 59, 116, -1, -1, -1, 64, -1, -1,
397 -1, -1, -1, -1, 93, 94, -1, -1, -1, -1,
398 59, -1, -1, 124, 125, 64, -1, 140, -1, -1,
399 -1, -1, -1, 146, 147, -1, 93, 94, -1, -1,
400 153, -1, -1, -1, -1, 124, 125, -1, -1, -1,
401 -1, -1, -1, 166, 46, 47, 48, 49, 50, 51,
402 52, 53, 54, 55, 56, -1, -1, 124, 125, -1,
403 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
404 -1, 272, 273, 274, 275, 276, 277, -1, -1, 258,
405 259, 260, 261, 262, 263, 264, 265, 266, -1, -1,
406 -1, -1, 271, 272, 273, 274, 275, 276, 277, -1,
407 -1, 258, 259, 260, 261, 262, 263, 264, 265, 266,
408 -1, -1, -1, -1, 271, 272, 273, 274, 275, 276,
409 277, -1, -1, 258, 259, 260, 261, 262, 263, 264,
410 265, 266, -1, -1, -1, -1, 271, 272, 273, 274,
411 275, 276, 277, -1, -1, -1, -1, 258, 259, 260,
412 261, 262, 263, 264, 265, 266, -1, -1, -1, -1,
413 271, 272, 273, 274, 275, 276, 277, -1, -1, 258,
414 259, 260, 261, 262, 263, 264, 265, 266, -1, -1,
415 -1, -1, 271, 272, 273, 274, 275, 276, 277, -1,
416 -1, 258, 259, 260, 261, 262, 263, 264, 265, 266,
417 -1, -1, -1, -1, 271, 272, 273, 274, 275, 276,
418 277, 36, -1, 38, -1, -1, 41, -1, 43, 44,
419 45, -1, -1, 272, 273, 274, 275, 276, 277, -1,
420 -1, -1, -1, 36, 59, 38, -1, -1, 41, 64,
421 43, 44, 45, -1, -1, -1, -1, -1, -1, -1,
422 -1, -1, -1, -1, -1, 36, 59, 38, -1, -1,
423 41, 64, 43, 44, 45, -1, -1, -1, 93, 94,
424 -1, -1, -1, -1, -1, -1, -1, -1, 59, 36,
425 -1, 38, -1, 64, 41, -1, 43, 44, 45, -1,
426 93, 94, -1, -1, -1, -1, -1, -1, -1, 124,
427 125, 36, 59, -1, -1, -1, 41, 64, -1, 44,
428 -1, -1, 93, 94, -1, -1, -1, -1, -1, -1,
429 -1, 124, 125, 36, 59, -1, -1, -1, 41, 64,
430 -1, 44, -1, -1, -1, -1, 93, 94, -1, -1,
431 -1, -1, -1, 124, 125, 38, 59, -1, -1, -1,
432 43, 64, 45, -1, 36, -1, -1, -1, 93, 41,
433 -1, -1, 44, -1, -1, -1, -1, 124, 125, -1,
434 -1, -1, -1, -1, -1, -1, -1, 59, -1, -1,
435 93, -1, 64, -1, -1, -1, -1, -1, -1, 38,
436 125, -1, 41, 42, 43, -1, 45, -1, 47, -1,
437 -1, 94, -1, -1, -1, -1, -1, -1, -1, -1,
438 -1, 93, 125, -1, -1, -1, -1, -1, -1, -1,
439 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
440 -1, 124, -1, 258, 259, 260, 261, 262, 263, 264,
441 265, 266, -1, 125, -1, 94, 271, 272, 273, 274,
442 275, 276, 277, -1, -1, 258, 259, 260, 261, 262,
443 263, 264, 265, 266, -1, -1, -1, -1, 271, 272,
444 273, 274, 275, 276, 277, 124, -1, 258, 259, 260,
445 261, 262, 263, 264, 265, 266, -1, -1, -1, -1,
446 271, 272, 273, 274, 275, 276, 277, -1, -1, -1,
447 -1, 258, 259, 260, 261, 262, 263, 264, 265, 266,
448 -1, -1, -1, -1, 271, 272, 273, 274, 275, 276,
449 277, -1, -1, 258, -1, -1, -1, -1, -1, -1,
450 265, 266, -1, -1, -1, -1, 271, 272, 273, 274,
451 275, 276, 277, -1, -1, 258, -1, -1, -1, -1,
452 -1, -1, 265, 266, -1, -1, -1, -1, 271, 272,
453 273, 274, 275, 276, 277, -1, 259, 260, 261, 262,
454 263, 264, -1, -1, -1, -1, 258, -1, -1, -1,
455 -1, -1, -1, 265, 266, -1, -1, -1, -1, 271,
456 272, 273, 274, 275, 276, 277, -1, -1, -1, -1,
457 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
458 259, 260, 261, 262, 263, 264, 265, 266,
459};
460#define YYFINAL1 1
461#ifndef YYDEBUG0
462#define YYDEBUG0 0
463#endif
464#define YYMAXTOKEN286 286
465#if YYDEBUG0
466const char * const yyname[] =
467 {
468"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
4690,0,0,0,"'#'","'$'",0,"'&'",0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,
4700,0,0,0,0,0,0,"':'","';'",0,"'='",0,0,"'@'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
4710,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
4720,0,0,0,0,0,"'{'","'|'","'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
4730,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
4740,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
4750,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"ERROR","ENDFILT","OP_EQ",
476"OP_NE","OP_LE","OP_LT","OP_GE","OP_GT","OP_LAND","OP_LOR","BUILTIN","BEGIN",
477"END","HZ","IF","F_DELETE","F_PRINT","MFUNC","FUNC0","FUNC1","FUNCN","OP1",
478"OP2","OP4","MOP0","MOP1","STRING","CSTRING","NUMBER","STR",
479};
480const char * const yyrule[] =
481 {"$accept : grammar",
482"grammar :",
483"grammar : grammar '\\n'",
484"grammar : grammar rule",
485"grammar : grammar error",
486"rule : plist filter action",
487"beginend : BEGIN",
488"beginend : END",
489"plist : plist ',' probe",
490"plist : probe",
491"$$1 :",
492"probe : $$1 pname",
493"probe : beginend",
494"pname : STRING ':' STRING ':' STRING",
495"pname : STRING ':' HZ ':' NUMBER",
496"staticv : '$' NUMBER",
497"staticv : '$' '#'",
498"gvar : '@' STRING",
499"gvar : '@'",
500"lvar : '$' STRING",
501"mentry : gvar '[' vargs ']'",
502"mpat : MOP0 '(' ')'",
503"mpat : MOP1 '(' pat ')'",
504"mpat : pat",
505"pat : CSTRING",
506"pat : expr",
507"filter :",
508"filter : '/' expr ENDFILT",
509"expr : expr OP_LAND term",
510"expr : expr OP_LOR term",
511"expr : term",
512"term : term OP_EQ fterm",
513"term : term OP_NE fterm",
514"term : term OP_LE fterm",
515"term : term OP_LT fterm",
516"term : term OP_GE fterm",
517"term : term OP_GT fterm",
518"term : term '+' fterm",
519"term : term '-' fterm",
520"term : term '&' fterm",
521"term : term '^' fterm",
522"term : term '|' fterm",
523"term : fterm",
524"fterm : fterm '*' factor",
525"fterm : fterm '/' factor",
526"fterm : factor",
527"variable : lvar",
528"variable : gvar",
529"factor : '(' expr ')'",
530"factor : NUMBER",
531"factor : BUILTIN",
532"factor : staticv",
533"factor : variable",
534"factor : mentry",
535"factor : func",
536"func : STR '(' staticv ')'",
537"func : STR '(' staticv ',' pat ')'",
538"vargs : pat",
539"vargs : vargs ',' pat",
540"pargs : expr",
541"pargs : gvar ',' pat",
542"NL :",
543"NL : '\\n'",
544"stmt : ';' NL",
545"stmt : gvar '=' pat",
546"stmt : lvar '=' pat",
547"stmt : gvar '[' vargs ']' '=' mpat",
548"stmt : FUNCN '(' vargs ')'",
549"stmt : FUNC1 '(' pat ')'",
550"stmt : MFUNC '(' variable ')'",
551"stmt : FUNC0 '(' ')'",
552"stmt : F_DELETE '(' mentry ')'",
553"stmt : F_PRINT '(' pargs ')'",
554"stmt : gvar '=' OP1 '(' pat ')'",
555"stmt : gvar '=' OP4 '(' pat ',' vargs ')'",
556"stmtblck : IF '(' expr ')' block",
557"stmtlist : stmtlist stmtblck",
558"stmtlist : stmtlist stmt",
559"stmtlist : stmtblck",
560"stmtlist : stmt",
561"block : '{' stmt ';' '}'",
562"block : stmt ';'",
563"action : '{' stmtlist '}'",
564};
565#endif
566#ifdef YYSTACKSIZE10000
567#undef YYMAXDEPTH10000
568#define YYMAXDEPTH10000 YYSTACKSIZE10000
569#else
570#ifdef YYMAXDEPTH10000
571#define YYSTACKSIZE10000 YYMAXDEPTH10000
572#else
573#define YYSTACKSIZE10000 10000
574#define YYMAXDEPTH10000 10000
575#endif
576#endif
577#define YYINITSTACKSIZE200 200
578/* LINTUSED */
579int yydebug;
580int yynerrs;
581int yyerrflag;
582int yychar;
583short *yyssp;
584YYSTYPEyystype *yyvsp;
585YYSTYPEyystype yyval;
586YYSTYPEyystype yylval;
587short *yyss;
588short *yysslim;
589YYSTYPEyystype *yyvs;
590unsigned int yystacksize;
591int yyparse(void);
592#line 274 "/usr/src/usr.sbin/btrace/bt_parse.y"
593
594struct bt_arg*
595get_varg(int index)
596{
597 extern int nargs;
598 extern char **vargs;
599 const char *errstr = NULL((void *)0);
600 long val;
601
602 if (0 < index && index <= nargs) {
603 val = (long)strtonum(vargs[index-1], LONG_MIN(-9223372036854775807L -1L), LONG_MAX9223372036854775807L,
604 &errstr);
605 if (errstr == NULL((void *)0))
606 return ba_new(val, B_AT_LONG)ba_new0((void *)(val), (B_AT_LONG));
607 return ba_new(vargs[index-1], B_AT_STR)ba_new0((void *)(vargs[index-1]), (B_AT_STR));
608 }
609
610 return ba_new(0L, B_AT_NIL)ba_new0((void *)(0L), (B_AT_NIL));
611}
612
613struct bt_arg*
614get_nargs(void)
615{
616 extern int nargs;
617
618 return ba_new((long) nargs, B_AT_LONG)ba_new0((void *)((long) nargs), (B_AT_LONG));
619}
620
621/* Create a new rule, representing "probe / filter / { action }" */
622struct bt_rule *
623br_new(struct bt_probe *probe, struct bt_filter *filter, struct bt_stmt *head)
624{
625 struct bt_rule *br;
626
627 br = calloc(1, sizeof(*br));
628 if (br == NULL((void *)0))
629 err(1, "bt_rule: calloc");
630 /* SLIST_INSERT_HEAD() nullify the next pointer. */
631 SLIST_FIRST(&br->br_probes)((&br->br_probes)->slh_first) = probe;
632 br->br_filter = filter;
633 /* SLIST_INSERT_HEAD() nullify the next pointer. */
634 SLIST_FIRST(&br->br_action)((&br->br_action)->slh_first) = head;
635
636 SLIST_FIRST(&br->br_variables)((&br->br_variables)->slh_first) = SLIST_FIRST(&l_variables)((&l_variables)->slh_first);
637 SLIST_INIT(&l_variables){ ((&l_variables)->slh_first) = ((void *)0); };
638
639 do {
640 if (probe->bp_type != B_PT_PROBE)
641 continue;
642 g_nprobes++;
643 } while ((probe = SLIST_NEXT(probe, bp_next)((probe)->bp_next.sle_next)) != NULL((void *)0));
644
645 TAILQ_INSERT_TAIL(&g_rules, br, br_next)do { (br)->br_next.tqe_next = ((void *)0); (br)->br_next
.tqe_prev = (&g_rules)->tqh_last; *(&g_rules)->
tqh_last = (br); (&g_rules)->tqh_last = &(br)->
br_next.tqe_next; } while (0)
;
646
647 return br;
648}
649
650/* Create a new condition */
651struct bt_filter *
652bc_new(struct bt_arg *term, enum bt_argtype op, struct bt_arg *ba)
653{
654 struct bt_filter *bf;
655
656 bf = calloc(1, sizeof(*bf));
657 if (bf == NULL((void *)0))
658 err(1, "bt_filter: calloc");
659
660 bf->bf_condition = bs_new(B_AC_TEST, ba_op(op, term, ba), NULL((void *)0));
661
662 return bf;
663}
664
665/* Create a new if/else test */
666struct bt_stmt *
667bt_new(struct bt_arg *ba, struct bt_stmt *condbs)
668{
669 struct bt_arg *bop;
670
671 bop = ba_op(B_AT_OP_NE, NULL((void *)0), ba);
672
673 return bs_new(B_AC_TEST, bop, (struct bt_var *)condbs);
674
675}
676/* Create a new probe */
677struct bt_probe *
678bp_new(const char *prov, const char *func, const char *name, int32_t rate)
679{
680 struct bt_probe *bp;
681 enum bt_ptype ptype;
682
683 if (rate < 0 || rate > INT32_MAX0x7fffffff)
684 errx(1, "only positive values permitted");
685
686 if (prov == NULL((void *)0) && func == NULL((void *)0) && name == NULL((void *)0))
687 ptype = rate; /* BEGIN or END */
688 else
689 ptype = B_PT_PROBE;
690
691 bp = calloc(1, sizeof(*bp));
692 if (bp == NULL((void *)0))
693 err(1, "bt_probe: calloc");
694 bp->bp_prov = prov;
695 bp->bp_func = func;
696 bp->bp_name = name;
697 bp->bp_rate = rate;
698 bp->bp_type = ptype;
699
700 return bp;
701}
702
703/*
704 * Link two probes together, to build a probe list attached to
705 * a single action.
706 */
707struct bt_probe *
708bp_append(struct bt_probe *bp0, struct bt_probe *bp1)
709{
710 struct bt_probe *bp = bp0;
711
712 assert(bp1 != NULL)((bp1 != ((void *)0)) ? (void)0 : __assert2("/usr/src/usr.sbin/btrace/bt_parse.y"
, 393, __func__, "bp1 != NULL"))
;
713
714 if (bp0 == NULL((void *)0))
715 return bp1;
716
717 while (SLIST_NEXT(bp, bp_next)((bp)->bp_next.sle_next) != NULL((void *)0))
718 bp = SLIST_NEXT(bp, bp_next)((bp)->bp_next.sle_next);
719
720 SLIST_INSERT_AFTER(bp, bp1, bp_next)do { (bp1)->bp_next.sle_next = (bp)->bp_next.sle_next; (
bp)->bp_next.sle_next = (bp1); } while (0)
;
721
722 return bp0;
723}
724
725/* Create a new argument */
726struct bt_arg *
727ba_new0(void *val, enum bt_argtype type)
728{
729 struct bt_arg *ba;
730
731 ba = calloc(1, sizeof(*ba));
732 if (ba == NULL((void *)0))
733 err(1, "bt_arg: calloc");
734 ba->ba_value = val;
735 ba->ba_type = type;
736
737 return ba;
738}
739
740/*
741 * Link two arguments together, to build an argument list used in
742 * function calls.
743 */
744struct bt_arg *
745ba_append(struct bt_arg *da0, struct bt_arg *da1)
746{
747 struct bt_arg *ba = da0;
748
749 assert(da1 != NULL)((da1 != ((void *)0)) ? (void)0 : __assert2("/usr/src/usr.sbin/btrace/bt_parse.y"
, 430, __func__, "da1 != NULL"))
;
750
751 if (da0 == NULL((void *)0))
752 return da1;
753
754 while (SLIST_NEXT(ba, ba_next)((ba)->ba_next.sle_next) != NULL((void *)0))
755 ba = SLIST_NEXT(ba, ba_next)((ba)->ba_next.sle_next);
756
757 SLIST_INSERT_AFTER(ba, da1, ba_next)do { (da1)->ba_next.sle_next = (ba)->ba_next.sle_next; (
ba)->ba_next.sle_next = (da1); } while (0)
;
758
759 return da0;
760}
761
762/* Create an operator argument */
763struct bt_arg *
764ba_op(enum bt_argtype op, struct bt_arg *da0, struct bt_arg *da1)
765{
766 return ba_new(ba_append(da0, da1), op)ba_new0((void *)(ba_append(da0, da1)), (op));
767}
768
769/* Create a new statement: function call or assignment. */
770struct bt_stmt *
771bs_new(enum bt_action act, struct bt_arg *head, struct bt_var *var)
772{
773 struct bt_stmt *bs;
774
775 bs = calloc(1, sizeof(*bs));
776 if (bs == NULL((void *)0))
777 err(1, "bt_stmt: calloc");
778 bs->bs_act = act;
779 bs->bs_var = var;
780 /* SLIST_INSERT_HEAD() nullify the next pointer. */
781 SLIST_FIRST(&bs->bs_args)((&bs->bs_args)->slh_first) = head;
782
783 return bs;
784}
785
786/* Link two statements together, to build an 'action'. */
787struct bt_stmt *
788bs_append(struct bt_stmt *ds0, struct bt_stmt *ds1)
789{
790 struct bt_stmt *bs = ds0;
791
792 if (ds0 == NULL((void *)0))
793 return ds1;
794
795 if (ds1 == NULL((void *)0))
796 return ds0;
797
798 while (SLIST_NEXT(bs, bs_next)((bs)->bs_next.sle_next) != NULL((void *)0))
799 bs = SLIST_NEXT(bs, bs_next)((bs)->bs_next.sle_next);
800
801 SLIST_INSERT_AFTER(bs, ds1, bs_next)do { (ds1)->bs_next.sle_next = (bs)->bs_next.sle_next; (
bs)->bs_next.sle_next = (ds1); } while (0)
;
802
803 return ds0;
804}
805
806const char *
807bv_name(struct bt_var *bv)
808{
809 if (strncmp(bv->bv_name, UNNAMED_MAP"___unnamed_map_doesnt_have_any_name", strlen(UNNAMED_MAP"___unnamed_map_doesnt_have_any_name")) == 0)
810 return "";
811 return bv->bv_name;
812}
813
814/* Allocate a variable. */
815struct bt_var *
816bv_new(const char *vname)
817{
818 struct bt_var *bv;
819
820 bv = calloc(1, sizeof(*bv));
821 if (bv == NULL((void *)0))
822 err(1, "bt_var: calloc");
823 bv->bv_name = vname;
824
825 return bv;
826}
827
828/* Return the global variable corresponding to `vname'. */
829struct bt_var *
830bg_lookup(const char *vname)
831{
832 struct bt_var *bv;
833
834 SLIST_FOREACH(bv, &g_variables, bv_next)for((bv) = ((&g_variables)->slh_first); (bv) != ((void
*)0); (bv) = ((bv)->bv_next.sle_next))
{
835 if (strcmp(vname, bv->bv_name) == 0)
836 break;
837 }
838
839 return bv;
840}
841
842/* Find or allocate a global variable corresponding to `vname' */
843struct bt_var *
844bg_get(const char *vname)
845{
846 struct bt_var *bv;
847
848 bv = bg_lookup(vname);
849 if (bv == NULL((void *)0)) {
850 bv = bv_new(vname);
851 SLIST_INSERT_HEAD(&g_variables, bv, bv_next)do { (bv)->bv_next.sle_next = (&g_variables)->slh_first
; (&g_variables)->slh_first = (bv); } while (0)
;
852 }
853
854 return bv;
855}
856
857/* Create an "argument" that points to an existing untyped variable. */
858struct bt_arg *
859bg_find(const char *vname)
860{
861 return ba_new(bg_get(vname), B_AT_VAR)ba_new0((void *)(bg_get(vname)), (B_AT_VAR));
862}
863
864/* Create a 'store' statement to assign a value to a global variable. */
865struct bt_stmt *
866bg_store(const char *vname, struct bt_arg *vval)
867{
868 return bs_new(B_AC_STORE, vval, bg_get(vname));
869}
870
871/* Return the local variable corresponding to `vname'. */
872struct bt_var *
873bl_lookup(const char *vname)
874{
875 struct bt_var *bv;
876
877 SLIST_FOREACH(bv, &l_variables, bv_next)for((bv) = ((&l_variables)->slh_first); (bv) != ((void
*)0); (bv) = ((bv)->bv_next.sle_next))
{
878 if (strcmp(vname, bv->bv_name) == 0)
879 break;
880 }
881
882 return bv;
883}
884
885/* Find or create a local variable corresponding to `vname' */
886struct bt_arg *
887bl_find(const char *vname)
888{
889 struct bt_var *bv;
890
891 bv = bl_lookup(vname);
892 if (bv == NULL((void *)0)) {
893 bv = bv_new(vname);
894 SLIST_INSERT_HEAD(&l_variables, bv, bv_next)do { (bv)->bv_next.sle_next = (&l_variables)->slh_first
; (&l_variables)->slh_first = (bv); } while (0)
;
895 }
896
897 return ba_new(bv, B_AT_VAR)ba_new0((void *)(bv), (B_AT_VAR));
898}
899
900/* Create a 'store' statement to assign a value to a local variable. */
901struct bt_stmt *
902bl_store(const char *vname, struct bt_arg *vval)
903{
904 struct bt_var *bv;
905
906 bv = bl_lookup(vname);
907 if (bv == NULL((void *)0)) {
908 bv = bv_new(vname);
909 SLIST_INSERT_HEAD(&l_variables, bv, bv_next)do { (bv)->bv_next.sle_next = (&l_variables)->slh_first
; (&l_variables)->slh_first = (bv); } while (0)
;
910 }
911
912 return bs_new(B_AC_STORE, vval, bv);
913}
914
915struct bt_stmt *
916bm_op(enum bt_action mact, struct bt_arg *ba, struct bt_arg *mval)
917{
918 return bs_new(mact, ba, (struct bt_var *)mval);
919}
920
921/* Create a 'map store' statement to assign a value to a map entry. */
922struct bt_stmt *
923bm_insert(const char *mname, struct bt_arg *mkey, struct bt_arg *mval)
924{
925 struct bt_arg *ba;
926
927 ba = ba_new(bg_get(mname), B_AT_MAP)ba_new0((void *)(bg_get(mname)), (B_AT_MAP));
928 ba->ba_key = mkey;
929
930 return bs_new(B_AC_INSERT, ba, (struct bt_var *)mval);
931}
932
933/* Create an argument that points to a variable and attach a key to it. */
934struct bt_arg *
935bm_find(const char *vname, struct bt_arg *mkey)
936{
937 struct bt_arg *ba;
938
939 ba = ba_new(bg_get(vname), B_AT_MAP)ba_new0((void *)(bg_get(vname)), (B_AT_MAP));
940 ba->ba_key = mkey;
941 return ba;
942}
943
944/*
945 * Histograms implemented using associative arrays (maps). In the case
946 * of linear histograms `ba_key' points to a list of (min, max, step)
947 * necessary to "bucketize" any value.
948 */
949struct bt_stmt *
950bh_inc(const char *hname, struct bt_arg *hval, struct bt_arg *hrange)
951{
952 struct bt_arg *ba;
953
954 if (hrange == NULL((void *)0)) {
955 /* Power-of-2 histogram */
956 } else {
957 long min = 0, max;
958 int count = 0;
959
960 /* Linear histogram */
961 for (ba = hrange; ba != NULL((void *)0); ba = SLIST_NEXT(ba, ba_next)((ba)->ba_next.sle_next)) {
962 if (++count > 3)
963 yyerror("too many arguments");
964 if (ba->ba_type != B_AT_LONG)
965 yyerror("type invalid");
966
967 switch (count) {
968 case 1:
969 min = (long)ba->ba_value;
970 if (min >= 0)
971 break;
972 yyerror("negative minium");
973 case 2:
974 max = (long)ba->ba_value;
975 if (max > min)
976 break;
977 yyerror("maximum smaller than minium (%d < %d)",
978 max, min);
979 case 3:
980 break;
981 default:
982 assert(0)((0) ? (void)0 : __assert2("/usr/src/usr.sbin/btrace/bt_parse.y"
, 663, __func__, "0"))
;
983 }
984 }
985 if (count < 3)
986 yyerror("%d missing arguments", 3 - count);
987 }
988
989 ba = ba_new(bg_get(hname), B_AT_HIST)ba_new0((void *)(bg_get(hname)), (B_AT_HIST));
990 ba->ba_key = hrange;
991 return bs_new(B_AC_BUCKETIZE, ba, (struct bt_var *)hval);
992}
993
994struct keyword {
995 const char *word;
996 int token;
997 int type;
998};
999
1000int
1001kw_cmp(const void *str, const void *xkw)
1002{
1003 return (strcmp(str, ((const struct keyword *)xkw)->word));
1004}
1005
1006struct keyword *
1007lookup(char *s)
1008{
1009 static const struct keyword kws[] = {
1010 { "BEGIN", BEGIN268, B_PT_BEGIN },
1011 { "END", END269, B_PT_END },
1012 { "arg0", BUILTIN267, B_AT_BI_ARG0 },
1013 { "arg1", BUILTIN267, B_AT_BI_ARG1 },
1014 { "arg2", BUILTIN267, B_AT_BI_ARG2 },
1015 { "arg3", BUILTIN267, B_AT_BI_ARG3 },
1016 { "arg4", BUILTIN267, B_AT_BI_ARG4 },
1017 { "arg5", BUILTIN267, B_AT_BI_ARG5 },
1018 { "arg6", BUILTIN267, B_AT_BI_ARG6 },
1019 { "arg7", BUILTIN267, B_AT_BI_ARG7 },
1020 { "arg8", BUILTIN267, B_AT_BI_ARG8 },
1021 { "arg9", BUILTIN267, B_AT_BI_ARG9 },
1022 { "clear", MFUNC274, B_AC_CLEAR },
1023 { "comm", BUILTIN267, B_AT_BI_COMM },
1024 { "count", MOP0281, B_AT_MF_COUNT },
1025 { "cpu", BUILTIN267, B_AT_BI_CPU },
1026 { "delete", F_DELETE272, B_AC_DELETE },
1027 { "exit", FUNC0275, B_AC_EXIT },
1028 { "hist", OP1278, 0 },
1029 { "hz", HZ270, 0 },
1030 { "if", IF271, 0 },
1031 { "kstack", BUILTIN267, B_AT_BI_KSTACK },
1032 { "lhist", OP4280, 0 },
1033 { "max", MOP1282, B_AT_MF_MAX },
1034 { "min", MOP1282, B_AT_MF_MIN },
1035 { "nsecs", BUILTIN267, B_AT_BI_NSECS },
1036 { "pid", BUILTIN267, B_AT_BI_PID },
1037 { "print", F_PRINT273, B_AC_PRINT },
1038 { "printf", FUNCN277, B_AC_PRINTF },
1039 { "probe", BUILTIN267, B_AT_BI_PROBE },
1040 { "retval", BUILTIN267, B_AT_BI_RETVAL },
1041 { "str", STR286, B_AT_FN_STR },
1042 { "sum", MOP1282, B_AT_MF_SUM },
1043 { "tid", BUILTIN267, B_AT_BI_TID },
1044 { "time", FUNC1276, B_AC_TIME },
1045 { "ustack", BUILTIN267, B_AT_BI_USTACK },
1046 { "zero", MFUNC274, B_AC_ZERO },
1047 };
1048
1049 return bsearch(s, kws, nitems(kws)(sizeof((kws)) / sizeof((kws)[0])), sizeof(kws[0]), kw_cmp);
1050}
1051
1052int
1053peek(void)
1054{
1055 if (pbuf != NULL((void *)0)) {
1056 if (pindex < plen)
1057 return pbuf[pindex];
1058 }
1059 return EOF(-1);
1060}
1061
1062int
1063lgetc(void)
1064{
1065 if (pbuf != NULL((void *)0)) {
1066 if (pindex < plen) {
1067 yylval.colno++;
1068 return pbuf[pindex++];
1069 }
1070 }
1071 return EOF(-1);
1072}
1073
1074void
1075lungetc(void)
1076{
1077 if (pbuf != NULL((void *)0) && pindex > 0) {
1078 yylval.colno--;
1079 pindex--;
1080 }
1081}
1082
1083int
1084yylex(void)
1085{
1086 unsigned char buf[1024];
1087 unsigned char *ebuf, *p, *str;
1088 int c;
1089
1090 ebuf = buf + sizeof(buf);
1091 p = buf;
1092
1093again:
1094 /* skip whitespaces */
1095 for (c = lgetc(); isspace(c); c = lgetc()) {
1096 if (c == '\n') {
1097 yylval.lineno++;
1098 yylval.colno = 0;
1099 }
1100 }
1101
1102 /* skip single line comments and shell magic */
1103 if ((c == '/' && peek() == '/') ||
1104 (yylval.lineno == 1 && yylval.colno == 1 && c == '#' &&
1105 peek() == '!')) {
1106 for (c = lgetc(); c != EOF(-1); c = lgetc()) {
1107 if (c == '\n') {
1108 yylval.lineno++;
1109 yylval.colno = 0;
1110 goto again;
1111 }
1112 }
1113 }
1114
1115 /* skip multi line comments */
1116 if (c == '/' && peek() == '*') {
1117 int pc;
1118
1119 for (pc = 0, c = lgetc(); c != EOF(-1); c = lgetc()) {
1120 if (pc == '*' && c == '/')
1121 goto again;
1122 else if (c == '\n')
1123 yylval.lineno++;
1124 pc = c;
1125 }
1126 }
1127
1128 switch (c) {
1129 case '!':
1130 case '=':
1131 if (peek() == '=') {
1132 lgetc();
1133 return (c == '=') ? OP_EQ259 : OP_NE260;
1134 }
1135 return c;
1136 case '<':
1137 if (peek() == '=') {
1138 lgetc();
1139 return OP_LE261;
1140 }
1141 return OP_LT262;
1142 case '>':
1143 if (peek() == '=') {
1144 lgetc();
1145 return OP_GE263;
1146 }
1147 return OP_GT264;
1148 case '&':
1149 if (peek() == '&') {
1150 lgetc();
1151 return OP_LAND265;
1152 }
1153 return c;
1154 case '|':
1155 if (peek() == '|') {
1156 lgetc();
1157 return OP_LOR266;
1158 }
1159 return c;
1160 case '/':
1161 if (peek() == '{' || peek() == '/' || peek() == '\n') {
1162 return ENDFILT258;
1163 }
1164 /* FALLTHROUGH */
1165 case ',':
1166 case '(':
1167 case ')':
1168 case '{':
1169 case '}':
1170 case ':':
1171 case ';':
1172 return c;
1173 case EOF(-1):
1174 return 0;
1175 case '"':
1176 /* parse C-like string */
1177 while ((c = lgetc()) != EOF(-1) && c != '"') {
1178 if (c == '\\') {
1179 c = lgetc();
1180 switch (c) {
1181 case '\\': c = '\\'; break;
1182 case '\'': c = '\''; break;
1183 case '"': c = '"'; break;
1184 case 'a': c = '\a'; break;
1185 case 'b': c = '\b'; break;
1186 case 'e': c = 033; break;
1187 case 'f': c = '\f'; break;
1188 case 'n': c = '\n'; break;
1189 case 'r': c = '\r'; break;
1190 case 't': c = '\t'; break;
1191 case 'v': c = '\v'; break;
1192 default:
1193 yyerror("'%c' unsuported escape", c);
1194 return ERROR257;
1195 }
1196 }
1197 *p++ = c;
1198 if (p == ebuf) {
1199 yyerror("too long line");
1200 return ERROR257;
1201 }
1202 }
1203 if (c == EOF(-1)) {
1204 yyerror("\"%s\" invalid EOF", buf);
1205 return ERROR257;
1206 }
1207 *p++ = '\0';
1208 if ((str = strdup(buf)) == NULL((void *)0))
1209 err(1, "%s", __func__);
1210 yylval.v.string = str;
1211 return CSTRING284;
1212 default:
1213 break;
1214 }
1215
1216#define allowed_to_end_number(x)(isspace(x) || x == ')' || x == '/' || x == '{' || x == ';' ||
x == ']' || x == ',')
\
1217 (isspace(x) || x == ')' || x == '/' || x == '{' || x == ';' || x == ']' || x == ',')
1218
1219 /* parsing number */
1220 if (isdigit(c)) {
1221 do {
1222 *p++ = c;
1223 if (p == ebuf) {
1224 yyerror("too long line");
1225 return ERROR257;
1226 }
1227 } while ((c = lgetc()) != EOF(-1) && isdigit(c));
1228 lungetc();
1229 if (c == EOF(-1) || allowed_to_end_number(c)(isspace(c) || c == ')' || c == '/' || c == '{' || c == ';' ||
c == ']' || c == ',')
) {
1230 const char *errstr = NULL((void *)0);
1231
1232 *p = '\0';
1233 yylval.v.number = strtonum(buf, LONG_MIN(-9223372036854775807L -1L), LONG_MAX9223372036854775807L,
1234 &errstr);
1235 if (errstr) {
1236 yyerror("invalid number '%s' (%s)", buf,
1237 errstr);
1238 return ERROR257;
1239 }
1240 return NUMBER285;
1241 } else {
1242 while (p > buf + 1) {
1243 --p;
1244 lungetc();
1245 }
1246 c = *--p;
1247 }
1248 }
1249
1250#define allowed_in_string(x)(isalnum(c) || c == '_') (isalnum(c) || c == '_')
1251
1252 /* parsing next word */
1253 if (allowed_in_string(c)(isalnum(c) || c == '_')) {
1254 struct keyword *kwp;
1255 do {
1256 *p++ = c;
1257 if (p == ebuf) {
1258 yyerror("too long line");
1259 return ERROR257;
1260 }
1261 } while ((c = lgetc()) != EOF(-1) && (allowed_in_string(c)(isalnum(c) || c == '_')));
1262 lungetc();
1263 *p = '\0';
1264 kwp = lookup(buf);
1265 if (kwp == NULL((void *)0)) {
1266 if ((yylval.v.string = strdup(buf)) == NULL((void *)0))
1267 err(1, "%s", __func__);
1268 return STRING283;
1269 }
1270 if (pflag) {
1271 /*
1272 * Probe lexer backdoor, interpret the token as a string
1273 * rather than a keyword. Otherwise, reserved keywords
1274 * would conflict with syscall names. The exception to
1275 * this is 'hz', which hopefully will never be a
1276 * syscall.
1277 */
1278 if (kwp->token != HZ270) {
1279 yylval.v.string = kwp->word;
1280 return STRING283;
1281 }
1282 }
1283 yylval.v.i = kwp->type;
1284 return kwp->token;
1285 }
1286
1287 if (c == '\n') {
1288 yylval.lineno++;
1289 yylval.colno = 0;
1290 }
1291 if (c == EOF(-1))
1292 return 0;
1293 return c;
1294}
1295
1296void
1297pprint_syntax_error(void)
1298{
1299 char line[BUFSIZ1024];
1300 int c, indent = yylval.colno;
1301 size_t i;
1302
1303 strlcpy(line, &pbuf[pindex - yylval.colno], sizeof(line));
1304
1305 for (i = 0; line[i] != '\0' && (c = line[i]) != '\n'; i++) {
1306 if (c == '\t')
1307 indent += (8 - 1);
1308 fputc(c, stderr(&__sF[2]));
1309 }
1310
1311 fprintf(stderr(&__sF[2]), "\n%*c\n", indent, '^');
1312}
1313
1314void
1315yyerror(const char *fmt, ...)
1316{
1317 const char *prefix;
1318 va_list va;
1319
1320 prefix = (yylval.filename != NULL((void *)0)) ? yylval.filename : getprogname();
1321
1322 fprintf(stderr(&__sF[2]), "%s:%d:%d: ", prefix, yylval.lineno, yylval.colno);
1323 va_start(va, fmt)__builtin_va_start(va, fmt);
1324 vfprintf(stderr(&__sF[2]), fmt, va);
1325 va_end(va)__builtin_va_end(va);
1326 fprintf(stderr(&__sF[2]), ":\n");
1327
1328 pprint_syntax_error();
1329
1330 perrors++;
1331}
1332
1333int
1334btparse(const char *str, size_t len, const char *filename, int debug)
1335{
1336 if (debug > 0)
1337 yydebug = 1;
1338 pbuf = str;
1339 plen = len;
1340 pindex = 0;
1341 yylval.filename = filename;
1342 yylval.lineno = 1;
1343
1344 yyparse();
1345 if (perrors)
1346 return perrors;
1347
1348 assert(SLIST_EMPTY(&l_variables))(((((&l_variables)->slh_first) == ((void *)0))) ? (void
)0 : __assert2("/usr/src/usr.sbin/btrace/bt_parse.y", 1029, __func__
, "SLIST_EMPTY(&l_variables)"))
;
1349
1350 return 0;
1351}
1352#line 1345 "bt_parse.c"
1353/* allocate initial stack or double stack size, up to YYMAXDEPTH */
1354static int yygrowstack(void)
1355{
1356 unsigned int newsize;
1357 long sslen;
1358 short *newss;
1359 YYSTYPEyystype *newvs;
1360
1361 if ((newsize = yystacksize) == 0)
31
Assuming the condition is false
32
Taking false branch
1362 newsize = YYINITSTACKSIZE200;
1363 else if (newsize >= YYMAXDEPTH10000)
33
Assuming 'newsize' is < YYMAXDEPTH
34
Taking false branch
1364 return -1;
1365 else if ((newsize *= 2) > YYMAXDEPTH10000)
35
Assuming the condition is false
36
Taking false branch
1366 newsize = YYMAXDEPTH10000;
1367 sslen = yyssp - yyss;
1368#ifdef SIZE_MAX0xffffffffffffffffUL
1369#define YY_SIZE_MAX0xffffffffffffffffUL SIZE_MAX0xffffffffffffffffUL
1370#else
1371#define YY_SIZE_MAX0xffffffffffffffffUL 0xffffffffU
1372#endif
1373 if (newsize && YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newss)
37
Assuming 'newsize' is 0
1374 goto bail;
1375 newss = (short *)realloc(yyss, newsize * sizeof *newss);
1376 if (newss == NULL((void *)0))
38
Assuming 'newss' is not equal to NULL
39
Taking false branch
1377 goto bail;
1378 yyss = newss;
1379 yyssp = newss + sslen;
1380 if (newsize
39.1
'newsize' is 0
&& YY_SIZE_MAX0xffffffffffffffffUL / newsize < sizeof *newvs)
1381 goto bail;
1382 newvs = (YYSTYPEyystype *)realloc(yyvs, newsize * sizeof *newvs);
1383 if (newvs == NULL((void *)0))
40
Assuming 'newvs' is not equal to NULL
41
Taking false branch
1384 goto bail;
1385 yyvs = newvs;
1386 yyvsp = newvs + sslen;
1387 yystacksize = newsize;
1388 yysslim = yyss + newsize - 1;
1389 return 0;
1390bail:
1391 if (yyss)
1392 free(yyss);
1393 if (yyvs)
1394 free(yyvs);
1395 yyss = yyssp = NULL((void *)0);
1396 yyvs = yyvsp = NULL((void *)0);
1397 yystacksize = 0;
1398 return -1;
1399}
1400
1401#define YYABORTgoto yyabort goto yyabort
1402#define YYREJECTgoto yyabort goto yyabort
1403#define YYACCEPTgoto yyaccept goto yyaccept
1404#define YYERRORgoto yyerrlab goto yyerrlab
1405int
1406yyparse(void)
1407{
1408 int yym, yyn, yystate;
1409#if YYDEBUG0
1410 const char *yys;
1411
1412 if ((yys = getenv("YYDEBUG")))
1413 {
1414 yyn = *yys;
1415 if (yyn >= '0' && yyn <= '9')
1416 yydebug = yyn - '0';
1417 }
1418#endif /* YYDEBUG */
1419
1420 yynerrs = 0;
1421 yyerrflag = 0;
1422 yychar = (-1);
1423
1424 if (yyss == NULL((void *)0) && yygrowstack()) goto yyoverflow;
1
Assuming 'yyss' is not equal to NULL
1425 yyssp = yyss;
1426 yyvsp = yyvs;
1427 *yyssp = yystate = 0;
1428
1429yyloop:
1430 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
2
Taking true branch
3
Control jumps to line 1537
13
Taking false branch
1431 if (yychar
13.1
'yychar' is >= 0
< 0)
14
Taking false branch
1432 {
1433 if ((yychar = yylex()) < 0) yychar = 0;
1434#if YYDEBUG0
1435 if (yydebug)
1436 {
1437 yys = 0;
1438 if (yychar <= YYMAXTOKEN286) yys = yyname[yychar];
1439 if (!yys) yys = "illegal-symbol";
1440 printf("%sdebug: state %d, reading %d (%s)\n",
1441 YYPREFIX"yy", yystate, yychar, yys);
1442 }
1443#endif
1444 }
1445 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
15
Assuming 'yyn' is not equal to 0
16
Assuming the condition is false
1446 yyn <= YYTABLESIZE1148 && yycheck[yyn] == yychar)
1447 {
1448#if YYDEBUG0
1449 if (yydebug)
1450 printf("%sdebug: state %d, shifting to state %d\n",
1451 YYPREFIX"yy", yystate, yytable[yyn]);
1452#endif
1453 if (yyssp >= yysslim && yygrowstack())
1454 {
1455 goto yyoverflow;
1456 }
1457 *++yyssp = yystate = yytable[yyn];
1458 *++yyvsp = yylval;
1459 yychar = (-1);
1460 if (yyerrflag > 0) --yyerrflag;
1461 goto yyloop;
1462 }
1463 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
17
Assuming 'yyn' is not equal to 0
1464 yyn <= YYTABLESIZE1148 && yycheck[yyn] == yychar)
1465 {
1466 yyn = yytable[yyn];
1467 goto yyreduce;
1468 }
1469 if (yyerrflag) goto yyinrecovery;
18
Assuming 'yyerrflag' is not equal to 0
19
Taking true branch
20
Control jumps to line 1481
1470#if defined(__GNUC__4)
1471 goto yynewerror;
1472#endif
1473yynewerror:
1474 yyerror("syntax error");
1475#if defined(__GNUC__4)
1476 goto yyerrlab;
1477#endif
1478yyerrlab:
1479 ++yynerrs;
1480yyinrecovery:
1481 if (yyerrflag < 3)
21
Assuming 'yyerrflag' is < 3
22
Taking true branch
1482 {
1483 yyerrflag = 3;
1484 for (;;)
23
Loop condition is true. Entering loop body
1485 {
1486 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE256) >= 0 &&
24
Assuming 'yyn' is not equal to 0
25
Assuming the condition is true
28
Taking true branch
1487 yyn <= YYTABLESIZE1148 && yycheck[yyn] == YYERRCODE256)
26
Assuming 'yyn' is <= YYTABLESIZE
27
Assuming the condition is true
1488 {
1489#if YYDEBUG0
1490 if (yydebug)
1491 printf("%sdebug: state %d, error recovery shifting\
1492 to state %d\n", YYPREFIX"yy", *yyssp, yytable[yyn]);
1493#endif
1494 if (yyssp >= yysslim && yygrowstack())
29
Assuming 'yyssp' is >= 'yysslim'
30
Calling 'yygrowstack'
42
Returning from 'yygrowstack'
43
Taking false branch
1495 {
1496 goto yyoverflow;
1497 }
1498 *++yyssp = yystate = yytable[yyn];
44
Use of zero-allocated memory
1499 *++yyvsp = yylval;
1500 goto yyloop;
1501 }
1502 else
1503 {
1504#if YYDEBUG0
1505 if (yydebug)
1506 printf("%sdebug: error recovery discarding state %d\n",
1507 YYPREFIX"yy", *yyssp);
1508#endif
1509 if (yyssp <= yyss) goto yyabort;
1510 --yyssp;
1511 --yyvsp;
1512 }
1513 }
1514 }
1515 else
1516 {
1517 if (yychar == 0) goto yyabort;
1518#if YYDEBUG0
1519 if (yydebug)
1520 {
1521 yys = 0;
1522 if (yychar <= YYMAXTOKEN286) yys = yyname[yychar];
1523 if (!yys) yys = "illegal-symbol";
1524 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1525 YYPREFIX"yy", yystate, yychar, yys);
1526 }
1527#endif
1528 yychar = (-1);
1529 goto yyloop;
1530 }
1531yyreduce:
1532#if YYDEBUG0
1533 if (yydebug)
1534 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1535 YYPREFIX"yy", yystate, yyn, yyrule[yyn]);
1536#endif
1537 yym = yylen[yyn];
1538 if (yym
3.1
'yym' is 0
)
4
Taking false branch
1539 yyval = yyvsp[1-yym];
1540 else
1541 memset(&yyval, 0, sizeof yyval);
1542 switch (yyn)
5
'Default' branch taken. Execution continues on line 1782
1543 {
1544case 5:
1545#line 140 "/usr/src/usr.sbin/btrace/bt_parse.y"
1546{ br_new(yyvsp[-2].v.probe, yyvsp[-1].v.filter, yyvsp[0].v.stmt); }
1547break;
1548case 8:
1549#line 145 "/usr/src/usr.sbin/btrace/bt_parse.y"
1550{ yyval.v.probe = bp_append(yyvsp[-2].v.probe, yyvsp[0].v.probe); }
1551break;
1552case 10:
1553#line 149 "/usr/src/usr.sbin/btrace/bt_parse.y"
1554{ pflag = 1; }
1555break;
1556case 11:
1557#line 149 "/usr/src/usr.sbin/btrace/bt_parse.y"
1558{ yyval.v.probe = yyvsp[0].v.probe; pflag = 0; }
1559break;
1560case 12:
1561#line 150 "/usr/src/usr.sbin/btrace/bt_parse.y"
1562{ yyval.v.probe = bp_new(NULL((void *)0), NULL((void *)0), NULL((void *)0), yyvsp[0].v.i); }
1563break;
1564case 13:
1565#line 153 "/usr/src/usr.sbin/btrace/bt_parse.y"
1566{ yyval.v.probe = bp_new(yyvsp[-4].v.string, yyvsp[-2].v.string, yyvsp[0].v.string, 0); }
1567break;
1568case 14:
1569#line 154 "/usr/src/usr.sbin/btrace/bt_parse.y"
1570{ yyval.v.probe = bp_new(yyvsp[-4].v.string, "hz", NULL((void *)0), yyvsp[0].v.number); }
1571break;
1572case 15:
1573#line 157 "/usr/src/usr.sbin/btrace/bt_parse.y"
1574{ yyval.v.arg = get_varg(yyvsp[0].v.number); }
1575break;
1576case 16:
1577#line 158 "/usr/src/usr.sbin/btrace/bt_parse.y"
1578{ yyval.v.arg = get_nargs(); }
1579break;
1580case 17:
1581#line 161 "/usr/src/usr.sbin/btrace/bt_parse.y"
1582{ yyval.v.string = yyvsp[0].v.string; }
1583break;
1584case 18:
1585#line 162 "/usr/src/usr.sbin/btrace/bt_parse.y"
1586{ yyval.v.string = UNNAMED_MAP"___unnamed_map_doesnt_have_any_name"; }
1587break;
1588case 19:
1589#line 165 "/usr/src/usr.sbin/btrace/bt_parse.y"
1590{ yyval.v.string = yyvsp[0].v.string; }
1591break;
1592case 20:
1593#line 168 "/usr/src/usr.sbin/btrace/bt_parse.y"
1594{ yyval.v.arg = bm_find(yyvsp[-3].v.string, yyvsp[-1].v.arg); }
1595break;
1596case 21:
1597#line 171 "/usr/src/usr.sbin/btrace/bt_parse.y"
1598{ yyval.v.arg = ba_new(NULL, yyvsp[-2].v.i)ba_new0((void *)(((void *)0)), (yyvsp[-2].v.i)); }
1599break;
1600case 22:
1601#line 172 "/usr/src/usr.sbin/btrace/bt_parse.y"
1602{ yyval.v.arg = ba_new(yyvsp[-1].v.arg, yyvsp[-3].v.i)ba_new0((void *)(yyvsp[-1].v.arg), (yyvsp[-3].v.i)); }
1603break;
1604case 24:
1605#line 176 "/usr/src/usr.sbin/btrace/bt_parse.y"
1606{ yyval.v.arg = ba_new(yyvsp[0].v.string, B_AT_STR)ba_new0((void *)(yyvsp[0].v.string), (B_AT_STR)); }
1607break;
1608case 26:
1609#line 180 "/usr/src/usr.sbin/btrace/bt_parse.y"
1610{ yyval.v.filter = NULL((void *)0); }
1611break;
1612case 27:
1613#line 181 "/usr/src/usr.sbin/btrace/bt_parse.y"
1614{ yyval.v.filter = bc_new(NULL((void *)0), B_AT_OP_NE, yyvsp[-1].v.arg); }
1615break;
1616case 28:
1617#line 190 "/usr/src/usr.sbin/btrace/bt_parse.y"
1618{ yyval.v.arg = ba_op(B_AT_OP_LAND, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1619break;
1620case 29:
1621#line 191 "/usr/src/usr.sbin/btrace/bt_parse.y"
1622{ yyval.v.arg = ba_op(B_AT_OP_LOR, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1623break;
1624case 31:
1625#line 195 "/usr/src/usr.sbin/btrace/bt_parse.y"
1626{ yyval.v.arg = ba_op(B_AT_OP_EQ, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1627break;
1628case 32:
1629#line 196 "/usr/src/usr.sbin/btrace/bt_parse.y"
1630{ yyval.v.arg = ba_op(B_AT_OP_NE, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1631break;
1632case 33:
1633#line 197 "/usr/src/usr.sbin/btrace/bt_parse.y"
1634{ yyval.v.arg = ba_op(B_AT_OP_LE, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1635break;
1636case 34:
1637#line 198 "/usr/src/usr.sbin/btrace/bt_parse.y"
1638{ yyval.v.arg = ba_op(B_AT_OP_LT, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1639break;
1640case 35:
1641#line 199 "/usr/src/usr.sbin/btrace/bt_parse.y"
1642{ yyval.v.arg = ba_op(B_AT_OP_GE, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1643break;
1644case 36:
1645#line 200 "/usr/src/usr.sbin/btrace/bt_parse.y"
1646{ yyval.v.arg = ba_op(B_AT_OP_GT, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1647break;
1648case 37:
1649#line 201 "/usr/src/usr.sbin/btrace/bt_parse.y"
1650{ yyval.v.arg = ba_op(B_AT_OP_PLUS, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1651break;
1652case 38:
1653#line 202 "/usr/src/usr.sbin/btrace/bt_parse.y"
1654{ yyval.v.arg = ba_op(B_AT_OP_MINUS, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1655break;
1656case 39:
1657#line 203 "/usr/src/usr.sbin/btrace/bt_parse.y"
1658{ yyval.v.arg = ba_op(B_AT_OP_BAND, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1659break;
1660case 40:
1661#line 204 "/usr/src/usr.sbin/btrace/bt_parse.y"
1662{ yyval.v.arg = ba_op(B_AT_OP_XOR, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1663break;
1664case 41:
1665#line 205 "/usr/src/usr.sbin/btrace/bt_parse.y"
1666{ yyval.v.arg = ba_op(B_AT_OP_BOR, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1667break;
1668case 43:
1669#line 209 "/usr/src/usr.sbin/btrace/bt_parse.y"
1670{ yyval.v.arg = ba_op(B_AT_OP_MULT, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1671break;
1672case 44:
1673#line 210 "/usr/src/usr.sbin/btrace/bt_parse.y"
1674{ yyval.v.arg = ba_op(B_AT_OP_DIVIDE, yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1675break;
1676case 46:
1677#line 214 "/usr/src/usr.sbin/btrace/bt_parse.y"
1678{ yyval.v.arg = bl_find(yyvsp[0].v.string); }
1679break;
1680case 47:
1681#line 215 "/usr/src/usr.sbin/btrace/bt_parse.y"
1682{ yyval.v.arg = bg_find(yyvsp[0].v.string); }
1683break;
1684case 48:
1685#line 218 "/usr/src/usr.sbin/btrace/bt_parse.y"
1686{ yyval.v.arg = yyvsp[-1].v.arg; }
1687break;
1688case 49:
1689#line 219 "/usr/src/usr.sbin/btrace/bt_parse.y"
1690{ yyval.v.arg = ba_new(yyvsp[0].v.number, B_AT_LONG)ba_new0((void *)(yyvsp[0].v.number), (B_AT_LONG)); }
1691break;
1692case 50:
1693#line 220 "/usr/src/usr.sbin/btrace/bt_parse.y"
1694{ yyval.v.arg = ba_new(NULL, yyvsp[0].v.i)ba_new0((void *)(((void *)0)), (yyvsp[0].v.i)); }
1695break;
1696case 55:
1697#line 227 "/usr/src/usr.sbin/btrace/bt_parse.y"
1698{ yyval.v.arg = ba_new(yyvsp[-1].v.arg, B_AT_FN_STR)ba_new0((void *)(yyvsp[-1].v.arg), (B_AT_FN_STR)); }
1699break;
1700case 56:
1701#line 228 "/usr/src/usr.sbin/btrace/bt_parse.y"
1702{ yyval.v.arg = ba_op(B_AT_FN_STR, yyvsp[-3].v.arg, yyvsp[-1].v.arg); }
1703break;
1704case 58:
1705#line 232 "/usr/src/usr.sbin/btrace/bt_parse.y"
1706{ yyval.v.arg = ba_append(yyvsp[-2].v.arg, yyvsp[0].v.arg); }
1707break;
1708case 60:
1709#line 236 "/usr/src/usr.sbin/btrace/bt_parse.y"
1710{ yyval.v.arg = ba_append(bg_find(yyvsp[-2].v.string), yyvsp[0].v.arg); }
1711break;
1712case 63:
1713#line 243 "/usr/src/usr.sbin/btrace/bt_parse.y"
1714{ yyval.v.stmt = NULL((void *)0); }
1715break;
1716case 64:
1717#line 244 "/usr/src/usr.sbin/btrace/bt_parse.y"
1718{ yyval.v.stmt = bg_store(yyvsp[-2].v.string, yyvsp[0].v.arg); }
1719break;
1720case 65:
1721#line 245 "/usr/src/usr.sbin/btrace/bt_parse.y"
1722{ yyval.v.stmt = bl_store(yyvsp[-2].v.string, yyvsp[0].v.arg); }
1723break;
1724case 66:
1725#line 246 "/usr/src/usr.sbin/btrace/bt_parse.y"
1726{ yyval.v.stmt = bm_insert(yyvsp[-5].v.string, yyvsp[-3].v.arg, yyvsp[0].v.arg); }
1727break;
1728case 67:
1729#line 247 "/usr/src/usr.sbin/btrace/bt_parse.y"
1730{ yyval.v.stmt = bs_new(yyvsp[-3].v.i, yyvsp[-1].v.arg, NULL((void *)0)); }
1731break;
1732case 68:
1733#line 248 "/usr/src/usr.sbin/btrace/bt_parse.y"
1734{ yyval.v.stmt = bs_new(yyvsp[-3].v.i, yyvsp[-1].v.arg, NULL((void *)0)); }
1735break;
1736case 69:
1737#line 249 "/usr/src/usr.sbin/btrace/bt_parse.y"
1738{ yyval.v.stmt = bs_new(yyvsp[-3].v.i, yyvsp[-1].v.arg, NULL((void *)0)); }
1739break;
1740case 70:
1741#line 250 "/usr/src/usr.sbin/btrace/bt_parse.y"
1742{ yyval.v.stmt = bs_new(yyvsp[-2].v.i, NULL((void *)0), NULL((void *)0)); }
1743break;
1744case 71:
1745#line 251 "/usr/src/usr.sbin/btrace/bt_parse.y"
1746{ yyval.v.stmt = bm_op(yyvsp[-3].v.i, yyvsp[-1].v.arg, NULL((void *)0)); }
1747break;
1748case 72:
1749#line 252 "/usr/src/usr.sbin/btrace/bt_parse.y"
1750{ yyval.v.stmt = bs_new(yyvsp[-3].v.i, yyvsp[-1].v.arg, NULL((void *)0)); }
1751break;
1752case 73:
1753#line 253 "/usr/src/usr.sbin/btrace/bt_parse.y"
1754{ yyval.v.stmt = bh_inc(yyvsp[-5].v.string, yyvsp[-1].v.arg, NULL((void *)0)); }
1755break;
1756case 74:
1757#line 254 "/usr/src/usr.sbin/btrace/bt_parse.y"
1758{ yyval.v.stmt = bh_inc(yyvsp[-7].v.string, yyvsp[-3].v.arg, yyvsp[-1].v.arg); }
1759break;
1760case 75:
1761#line 257 "/usr/src/usr.sbin/btrace/bt_parse.y"
1762{ yyval.v.stmt = bt_new(yyvsp[-2].v.arg, yyvsp[0].v.stmt); }
1763break;
1764case 76:
1765#line 260 "/usr/src/usr.sbin/btrace/bt_parse.y"
1766{ yyval.v.stmt = bs_append(yyvsp[-1].v.stmt, yyvsp[0].v.stmt); }
1767break;
1768case 77:
1769#line 261 "/usr/src/usr.sbin/btrace/bt_parse.y"
1770{ yyval.v.stmt = bs_append(yyvsp[-1].v.stmt, yyvsp[0].v.stmt); }
1771break;
1772case 80:
1773#line 266 "/usr/src/usr.sbin/btrace/bt_parse.y"
1774{ yyval.v.stmt = yyvsp[-2].v.stmt; }
1775break;
1776case 82:
1777#line 270 "/usr/src/usr.sbin/btrace/bt_parse.y"
1778{ yyval.v.stmt = yyvsp[-1].v.stmt; }
1779break;
1780#line 1773 "bt_parse.c"
1781 }
1782 yyssp -= yym;
1783 yystate = *yyssp;
1784 yyvsp -= yym;
1785 yym = yylhs[yyn];
1786 if (yystate
5.1
'yystate' is equal to 0
== 0 && yym
5.2
'yym' is equal to 0
== 0)
6
Taking true branch
1787 {
1788#if YYDEBUG0
1789 if (yydebug)
1790 printf("%sdebug: after reduction, shifting from state 0 to\
1791 state %d\n", YYPREFIX"yy", YYFINAL1);
1792#endif
1793 yystate = YYFINAL1;
1794 *++yyssp = YYFINAL1;
1795 *++yyvsp = yyval;
1796 if (yychar
6.1
'yychar' is < 0
< 0)
7
Taking true branch
1797 {
1798 if ((yychar = yylex()) < 0) yychar = 0;
8
Assuming the condition is false
9
Taking false branch
1799#if YYDEBUG0
1800 if (yydebug)
1801 {
1802 yys = 0;
1803 if (yychar <= YYMAXTOKEN286) yys = yyname[yychar];
1804 if (!yys) yys = "illegal-symbol";
1805 printf("%sdebug: state %d, reading %d (%s)\n",
1806 YYPREFIX"yy", YYFINAL1, yychar, yys);
1807 }
1808#endif
1809 }
1810 if (yychar == 0) goto yyaccept;
10
Assuming 'yychar' is not equal to 0
11
Taking false branch
1811 goto yyloop;
12
Control jumps to line 1430
1812 }
1813 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1814 yyn <= YYTABLESIZE1148 && yycheck[yyn] == yystate)
1815 yystate = yytable[yyn];
1816 else
1817 yystate = yydgoto[yym];
1818#if YYDEBUG0
1819 if (yydebug)
1820 printf("%sdebug: after reduction, shifting from state %d \
1821to state %d\n", YYPREFIX"yy", *yyssp, yystate);
1822#endif
1823 if (yyssp >= yysslim && yygrowstack())
1824 {
1825 goto yyoverflow;
1826 }
1827 *++yyssp = yystate;
1828 *++yyvsp = yyval;
1829 goto yyloop;
1830yyoverflow:
1831 yyerror("yacc stack overflow");
1832yyabort:
1833 if (yyss)
1834 free(yyss);
1835 if (yyvs)
1836 free(yyvs);
1837 yyss = yyssp = NULL((void *)0);
1838 yyvs = yyvsp = NULL((void *)0);
1839 yystacksize = 0;
1840 return (1);
1841yyaccept:
1842 if (yyss)
1843 free(yyss);
1844 if (yyvs)
1845 free(yyvs);
1846 yyss = yyssp = NULL((void *)0);
1847 yyvs = yyvsp = NULL((void *)0);
1848 yystacksize = 0;
1849 return (0);
1850}