8354 sync regcomp(3C) with upstream (fix make catalog)
[unleashed/tickless.git] / usr / src / cmd / tnf / prex / prexgram.y
blob3dbe9495fb54a7fd06e269bd12a8380ebb1ba435
1 %{
2 /*
3 * CDDL HEADER START
5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License, Version 1.0 only
7 * (the "License"). You may not use this file except in compliance
8 * with the License.
10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 * or http://www.opensolaris.org/os/licensing.
12 * See the License for the specific language governing permissions
13 * and limitations under the License.
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
21 * CDDL HEADER END
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 %token ADD
30 %token ALLOC
31 %token BUFFER
32 %token CLEAR
33 %token COMMA
34 %token CONNECT
35 %token DEALLOC
36 %token DELETE
37 %token FILTER
38 %token CONTINUE
39 %token CREATE
40 %token DISABLE
41 %token ENABLE
42 %token EQ
43 %token FCNNAME
44 %token FCNS
45 %token ON
46 %token OFF
47 %token HELP
48 %token KTRACE
49 %token HISTORY
50 %token IDENT
51 %token INVAL
52 %token KILL
53 %token LIST
54 %token NL
55 %token PFILTER
56 %token PROBES
57 %token QUIT
58 %token REGEXP
59 %token RESUME
60 %token SCALED_INT
61 %token SETNAME
62 %token SETS
63 %token SOURCE
64 %token SUSPEND
65 %token TRACE
66 %token TRACEFILE
67 %token UNTRACE
68 %token VALSTR
69 %token VALUES
72 #include <stdio.h>
73 #include <string.h>
74 #include <sys/types.h>
76 #include "set.h"
77 #include "cmd.h"
78 #include "fcn.h"
79 #include "list.h"
80 #include "expr.h"
81 #include "spec.h"
82 #include "source.h"
83 #include "prbk.h"
85 extern int yylex();
87 extern void help_on_topic(char *topic);
88 extern void help_on_command(int cmd);
89 extern boolean_t g_kernelmode;
90 extern tnfctl_handle_t *g_hndl;
92 void quit(boolean_t killtarget, boolean_t runtarget);
93 extern void help(void);
94 extern void process_cmd(tnfctl_handle_t *hndl, cmd_t *cmd);
95 extern void cmd_listtracefile();
98 %union
100 char * strval;
101 expr_t * exprval;
102 spec_t * specval;
103 void * pidlistval;
104 int intval;
107 %type <strval> SETNAME FCNNAME IDENT VALSTR REGEXP
108 %type <intval> CONTINUE DISABLE ENABLE HELP LIST QUIT SOURCE TRACE UNTRACE BUFFER KTRACE PFILTER CLEAR CONNECT command
109 %type <exprval> expr exprlist
110 %type <specval> spec speclist
111 %type <pidlistval> pidlist
112 %type <intval> SCALED_INT singlepid
116 file : statement_list
119 statement_list : /* empty */ { prompt(); }
120 | statement_list statement
122 if (g_kernelmode)
123 prbk_warn_pfilter_empty();
124 prompt();
128 statement : empty_statement
129 | help_statement
130 | continue_statement
131 | quit_statement
132 | enable_statement
133 | disable_statement
134 | trace_statement
135 | untrace_statement
136 | connect_statement
137 | clear_statement
138 | pfilter_statement
139 | ktrace_statement
140 | buffer_statement
141 | create_statement
142 | source_statement
143 | listsets_statement
144 | listhistory_statement
145 | listtracefile_statement
146 | listfcns_statement
147 | listprobes_statement
148 | listvalues_statement
149 | error NL { yyerrok; }
152 empty_statement : NL
155 command : CONTINUE { $$ = $1; } /* user&kernel */
156 | DISABLE { $$ = $1; }
157 | ENABLE { $$ = $1; }
158 | HELP { $$ = $1; }
159 | LIST { $$ = $1; }
160 | QUIT { $$ = $1; }
161 | SOURCE { $$ = $1; }
162 | TRACE { $$ = $1; }
163 | UNTRACE { $$ = $1; }
164 | BUFFER { $$ = $1; } /* kernel only */
165 | KTRACE { $$ = $1; }
166 | PFILTER { $$ = $1; }
167 | CLEAR { $$ = $1; } /* user only */
168 | CONNECT { $$ = $1; }
171 help_statement : HELP NL { help(); }
172 | HELP command NL { help_on_command($2); }
173 | HELP IDENT NL { help_on_topic($2); }
176 continue_statement : CONTINUE NL
178 if (!g_kernelmode) YYACCEPT;
182 quit_statement : QUIT NL { quit(B_TRUE, B_TRUE); }
183 | QUIT KILL NL { quit(B_TRUE, B_FALSE); }
184 | QUIT RESUME NL { quit(B_FALSE, B_TRUE); }
185 | QUIT SUSPEND NL { quit(B_FALSE, B_FALSE); }
188 enable_statement : ENABLE SETNAME NL
190 cmd_t *cmd_p;
191 cmd_p = cmd_set($2, CMD_ENABLE, NULL);
192 if (cmd_p)
193 process_cmd(g_hndl, cmd_p);
195 | ENABLE exprlist NL
197 cmd_t *cmd_p;
198 cmd_p = cmd_expr($2, CMD_ENABLE, NULL);
199 if (cmd_p)
200 process_cmd(g_hndl, cmd_p);
204 disable_statement : DISABLE SETNAME NL
206 cmd_t *cmd_p;
207 cmd_p = cmd_set($2, CMD_DISABLE, NULL);
208 if (cmd_p)
209 process_cmd(g_hndl, cmd_p);
211 | DISABLE exprlist NL
213 cmd_t *cmd_p;
214 cmd_p = cmd_expr($2, CMD_DISABLE, NULL);
215 if (cmd_p)
216 process_cmd(g_hndl, cmd_p);
220 trace_statement : TRACE SETNAME NL
222 cmd_t *cmd_p;
223 cmd_p = cmd_set($2, CMD_TRACE, NULL);
224 if (cmd_p)
225 process_cmd(g_hndl, cmd_p);
227 | TRACE exprlist NL
229 cmd_t *cmd_p;
230 cmd_p = cmd_expr($2, CMD_TRACE, NULL);
231 if (cmd_p)
232 process_cmd(g_hndl, cmd_p);
236 untrace_statement : UNTRACE SETNAME NL
238 cmd_t *cmd_p;
239 cmd_p = cmd_set($2, CMD_UNTRACE, NULL);
240 if (cmd_p)
241 process_cmd(g_hndl, cmd_p);
243 | UNTRACE exprlist NL
245 cmd_t *cmd_p;
246 cmd_p = cmd_expr($2, CMD_UNTRACE, NULL);
247 if (cmd_p)
248 process_cmd(g_hndl, cmd_p);
252 connect_statement : CONNECT FCNNAME SETNAME NL
254 cmd_t *cmd_p;
255 cmd_p = cmd_set($3, CMD_CONNECT, $2);
256 if (cmd_p)
257 process_cmd(g_hndl, cmd_p);
259 | CONNECT FCNNAME exprlist NL
261 cmd_t *cmd_p;
262 cmd_p = cmd_expr($3, CMD_CONNECT, $2);
263 if (cmd_p)
264 process_cmd(g_hndl, cmd_p);
268 clear_statement : CLEAR SETNAME NL
270 cmd_t *cmd_p;
271 cmd_p = cmd_set($2, CMD_CLEAR, NULL);
272 if (cmd_p)
273 process_cmd(g_hndl, cmd_p);
275 | CLEAR exprlist NL
277 cmd_t *cmd_p;
278 cmd_p = cmd_expr($2, CMD_CLEAR, NULL);
279 if (cmd_p)
280 process_cmd(g_hndl, cmd_p);
284 create_statement : CREATE SETNAME exprlist NL { (void) set($2, $3); }
285 | CREATE FCNNAME IDENT NL { fcn($2, $3); }
288 source_statement : SOURCE VALSTR NL { source_file($2); }
289 | SOURCE IDENT NL { source_file($2); }
292 listsets_statement : LIST SETS NL { set_list(); }
295 listhistory_statement : LIST HISTORY NL { cmd_list(); }
298 listtracefile_statement : LIST TRACEFILE NL { cmd_listtracefile(); }
301 listfcns_statement : LIST FCNS NL { fcn_list(); }
306 pfilter_statement : PFILTER ON NL
307 { prbk_set_pfilter_mode(B_TRUE); }
308 | PFILTER OFF NL
309 { prbk_set_pfilter_mode(B_FALSE); }
310 | PFILTER ADD pidlist NL
311 { prbk_pfilter_add($3); }
312 | PFILTER DELETE pidlist NL
313 { prbk_pfilter_drop($3); }
314 | PFILTER NL
315 { prbk_show_pfilter_mode(); }
318 ktrace_statement : KTRACE ON NL
319 { prbk_set_tracing(B_TRUE); }
320 | KTRACE OFF NL
321 { prbk_set_tracing(B_FALSE); }
322 | KTRACE NL
323 { prbk_show_tracing(); }
326 listprobes_statement : LIST speclist PROBES SETNAME NL
327 { list_set($2, $4); }
328 | LIST speclist PROBES exprlist NL
329 { list_expr($2, $4); }
332 listvalues_statement : LIST VALUES speclist NL { list_values($3); }
335 exprlist : /* empty */ { $$ = NULL; }
336 | exprlist expr { $$ = expr_list($1, $2); }
339 speclist : /* empty */ { $$ = NULL; }
340 | speclist spec { $$ = spec_list($1, $2); }
343 expr : spec EQ spec { $$ = expr($1, $3); }
344 | spec { $$ = expr(spec(strdup("keys"),
345 SPEC_EXACT), $1); }
348 spec : IDENT { $$ = spec($1, SPEC_EXACT); }
349 | VALSTR { $$ = spec($1, SPEC_EXACT); }
350 | REGEXP { $$ = spec($1, SPEC_REGEXP); }
353 pidlist : pidlist COMMA singlepid
354 { $$ = prbk_pidlist_add($1, $3); }
355 | singlepid
356 { $$ = prbk_pidlist_add(NULL, $1); }
359 singlepid : SCALED_INT
362 buffer_statement : BUFFER NL
364 prbk_buffer_list();
366 | BUFFER ALLOC NL
368 extern int g_outsize;
369 prbk_buffer_alloc(g_outsize);
371 | BUFFER ALLOC SCALED_INT NL
373 prbk_buffer_alloc($3);
375 | BUFFER DEALLOC NL
377 prbk_buffer_dealloc();