sync code with last improvements from OpenBSD
This commit is contained in:
parent
12cd8aa4a2
commit
18b0c95b14
@ -1,11 +1,11 @@
|
|||||||
# $OpenBSD: Makefile,v 1.27 2023/08/13 09:49:47 mpi Exp $
|
# $OpenBSD: Makefile,v 1.28 2023/08/28 21:23:46 dv Exp $
|
||||||
|
|
||||||
BTRACE?= /usr/sbin/btrace
|
BTRACE?= /usr/sbin/btrace
|
||||||
ALLOWDT!= sysctl -n kern.allowdt 2>/dev/null
|
ALLOWDT!= sysctl -n kern.allowdt 2>/dev/null
|
||||||
|
|
||||||
# scripts that don't need /dev/dt
|
# scripts that don't need /dev/dt
|
||||||
BT_LANG_SCRIPTS= arithm beginend boolean comments delete exit \
|
BT_LANG_SCRIPTS= arithm beginend beginend-argn boolean comments delete \
|
||||||
histempty if \
|
exit histempty if \
|
||||||
map mapclear mapempty mapsyntax mapzero map-unnamed \
|
map mapclear mapempty mapsyntax mapzero map-unnamed \
|
||||||
maxoperand min+max+sum multismts nsecs+var \
|
maxoperand min+max+sum multismts nsecs+var \
|
||||||
precedence print read-map-after-clear staticv-empty \
|
precedence print read-map-after-clear staticv-empty \
|
||||||
|
8
regress/usr.sbin/btrace/beginend-argn.bt
Normal file
8
regress/usr.sbin/btrace/beginend-argn.bt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Test catching invalid use of argN in BEGIN and END contexts.
|
||||||
|
BEGIN {
|
||||||
|
print(arg0);
|
||||||
|
}
|
||||||
|
|
||||||
|
END {
|
||||||
|
print(arg0);
|
||||||
|
}
|
6
regress/usr.sbin/btrace/beginend-argn.ok
Normal file
6
regress/usr.sbin/btrace/beginend-argn.ok
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
beginend-argn.bt:3:11: the arg0 builtin cannot be used with BEGIN or END probes:
|
||||||
|
print(arg0);
|
||||||
|
^
|
||||||
|
beginend-argn.bt:7:11: the arg0 builtin cannot be used with BEGIN or END probes:
|
||||||
|
print(arg0);
|
||||||
|
^
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: bt_parse.y,v 1.50 2023/08/13 13:19:23 dv Exp $ */
|
/* $OpenBSD: bt_parse.y,v 1.51 2023/08/28 21:23:46 dv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2021 Martin Pieuchot <mpi@openbsd.org>
|
* Copyright (c) 2019-2021 Martin Pieuchot <mpi@openbsd.org>
|
||||||
@ -109,7 +109,8 @@ typedef struct {
|
|||||||
static void yyerror(const char *, ...);
|
static void yyerror(const char *, ...);
|
||||||
static int yylex(void);
|
static int yylex(void);
|
||||||
|
|
||||||
static int pflag;
|
static int pflag = 0; /* probe parsing context flag */
|
||||||
|
static int beflag = 0; /* BEGIN/END parsing context flag */
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%token <v.i> ERROR ENDFILT
|
%token <v.i> ERROR ENDFILT
|
||||||
@ -137,7 +138,7 @@ grammar : /* empty */
|
|||||||
| grammar error
|
| grammar error
|
||||||
;
|
;
|
||||||
|
|
||||||
rule : plist filter action { br_new($1, $2, $3); }
|
rule : plist filter action { br_new($1, $2, $3); beflag = 0; }
|
||||||
;
|
;
|
||||||
|
|
||||||
beginend: BEGIN | END ;
|
beginend: BEGIN | END ;
|
||||||
@ -147,7 +148,7 @@ plist : plist ',' probe { $$ = bp_append($1, $3); }
|
|||||||
;
|
;
|
||||||
|
|
||||||
probe : { pflag = 1; } pname { $$ = $2; pflag = 0; }
|
probe : { pflag = 1; } pname { $$ = $2; pflag = 0; }
|
||||||
| beginend { $$ = bp_new(NULL, NULL, NULL, $1); }
|
| { beflag = 1; } beginend { $$ = bp_new(NULL, NULL, NULL, $2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
pname : STRING ':' STRING ':' STRING { $$ = bp_new($1, $3, $5, 0); }
|
pname : STRING ':' STRING ':' STRING { $$ = bp_new($1, $3, $5, 0); }
|
||||||
@ -962,6 +963,12 @@ again:
|
|||||||
yylval.v.string = kwp->word;
|
yylval.v.string = kwp->word;
|
||||||
return STRING;
|
return STRING;
|
||||||
}
|
}
|
||||||
|
} else if (beflag) {
|
||||||
|
/* Interpret tokens in a BEGIN/END context. */
|
||||||
|
if (kwp->type >= B_AT_BI_ARG0 &&
|
||||||
|
kwp->type <= B_AT_BI_ARG9)
|
||||||
|
yyerror("the %s builtin cannot be used with "
|
||||||
|
"BEGIN or END probes", kwp->word);
|
||||||
}
|
}
|
||||||
yylval.v.i = kwp->type;
|
yylval.v.i = kwp->type;
|
||||||
return kwp->token;
|
return kwp->token;
|
||||||
|
Loading…
Reference in New Issue
Block a user