diff options
author | anton <anton@cvs.openbsd.org> | 2020-12-07 20:14:36 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2020-12-07 20:14:36 +0000 |
commit | b78e0555772d888b6fc57acec4de6fc627d91068 (patch) | |
tree | 5097cf39c2f83f3a02b1c8deb40de8f1e1b01ad8 | |
parent | f74f2a2c2b5d8f3e12d65b74e3125ee1befc100f (diff) |
In revision 1.18 of bt_parse.y, I missed the fact that the print()
function accepts an optional argument representing the number of map
entries to print.
ok bluhm@ mpi@
-rw-r--r-- | usr.sbin/btrace/bt.5 | 9 | ||||
-rw-r--r-- | usr.sbin/btrace/bt_parse.y | 16 |
2 files changed, 18 insertions, 7 deletions
diff --git a/usr.sbin/btrace/bt.5 b/usr.sbin/btrace/bt.5 index 5014856e2d0..fab7954abf1 100644 --- a/usr.sbin/btrace/bt.5 +++ b/usr.sbin/btrace/bt.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bt.5,v 1.9 2020/09/18 18:05:20 jmc Exp $ +.\" $OpenBSD: bt.5,v 1.10 2020/12/07 20:14:35 anton Exp $ .\" .\" Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 18 2020 $ +.Dd $Mdocdate: December 7 2020 $ .Dt BT 5 .Os .Sh NAME @@ -142,6 +142,11 @@ Returns the minimum recorded value. .It Fn print "@map" Print all pairs from .Va @map . +.It Fn print "@map" n +Print only the first +.Va n +entries in +.Va @map . .It Fn printf "fmt" ... Print formatted string .Va fmt . diff --git a/usr.sbin/btrace/bt_parse.y b/usr.sbin/btrace/bt_parse.y index bfad8f779db..ee4ac9b259d 100644 --- a/usr.sbin/btrace/bt_parse.y +++ b/usr.sbin/btrace/bt_parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: bt_parse.y,v 1.18 2020/12/01 18:47:25 anton Exp $ */ +/* $OpenBSD: bt_parse.y,v 1.19 2020/12/07 20:14:35 anton Exp $ */ /* * Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org> @@ -104,17 +104,18 @@ static int yylex(void); /* Builtins */ %token BUILTIN PID TID /* Functions and Map operators */ -%token F_DELETE FUNC0 FUNC1 FUNCN OP1 OP4 MOP0 MOP1 +%token F_DELETE F_PRINT FUNC0 FUNC1 FUNCN OP1 OP4 MOP0 MOP1 %token <v.string> STRING CSTRING %token <v.number> NUMBER %type <v.string> gvar %type <v.i> filterval oper builtin -%type <v.i> BUILTIN F_DELETE FUNC0 FUNC1 FUNCN OP1 OP4 MOP0 MOP1 +%type <v.i> BUILTIN F_DELETE F_PRINT FUNC0 FUNC1 FUNCN OP1 OP4 +%type <v.i> MOP0 MOP1 %type <v.probe> probe %type <v.filter> predicate %type <v.stmt> action stmt stmtlist -%type <v.arg> expr vargs map mexpr term +%type <v.arg> expr vargs map mexpr printargs term %type <v.rtype> beginend %left '|' @@ -192,6 +193,10 @@ vargs : expr | vargs ',' expr { $$ = ba_append($1, $3); } ; +printargs : gvar { $$ = bv_get($1); } + | gvar ',' expr { $$ = ba_append(bv_get($1), $3); } + ; + NL : /* empty */ | '\n' ; @@ -202,6 +207,7 @@ stmt : ';' NL { $$ = NULL; } | FUNC1 '(' expr ')' { $$ = bs_new($1, $3, NULL); } | FUNC0 '(' ')' { $$ = bs_new($1, NULL, NULL); } | F_DELETE '(' map ')' { $$ = bm_op($1, $3, NULL); } + | F_PRINT '(' printargs ')' { $$ = bs_new($1, $3, NULL); } | gvar '=' OP1 '(' expr ')' { $$ = bh_inc($1, $5, NULL); } | gvar '=' OP4 '(' expr ',' vargs ')' {$$ = bh_inc($1, $5, $7);} ; @@ -579,7 +585,7 @@ lookup(char *s) { "min", MOP1, B_AT_MF_MIN }, { "nsecs", BUILTIN, B_AT_BI_NSECS }, { "pid", PID, 0 /*B_AT_BI_PID*/ }, - { "print", FUNC1, B_AC_PRINT }, + { "print", F_PRINT, B_AC_PRINT }, { "printf", FUNCN, B_AC_PRINTF }, { "retval", BUILTIN, B_AT_BI_RETVAL }, { "sum", MOP1, B_AT_MF_SUM }, |