btrace: add boolean AND and OR operators

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

btrace: add boolean AND and OR operators

Jasper Lievisse Adriaanse-2
Hi,

This diff adds support for the '&' and '|' operators, along with
a new testcase.

OK?

Index: usr.sbin/btrace/bt_parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/btrace/bt_parse.y,v
retrieving revision 1.16
diff -u -p -r1.16 bt_parse.y
--- usr.sbin/btrace/bt_parse.y 11 Jul 2020 14:52:14 -0000 1.16
+++ usr.sbin/btrace/bt_parse.y 14 Sep 2020 15:14:10 -0000
@@ -119,6 +119,7 @@ static int yylex(void);
 
 %left '+' '-'
 %left '/' '*'
+%left '&' '|'
 %%
 
 grammar : /* empty */
@@ -172,6 +173,8 @@ term : '(' term ')' { $$ = $2; }
  | term '-' term { $$ = ba_op('-', $1, $3); }
  | term '/' term { $$ = ba_op('/', $1, $3); }
  | term '*' term { $$ = ba_op('*', $1, $3); }
+ | term '&' term { $$ = ba_op('&', $1, $3); }
+ | term '|' term { $$ = ba_op('|', $1, $3); }
  | NUMBER { $$ = ba_new($1, B_AT_LONG); }
  | builtin { $$ = ba_new(NULL, $1); }
  | gvar { $$ = bv_get($1); }
@@ -331,6 +334,12 @@ ba_op(const char op, struct bt_arg *da0,
  break;
  case '/':
  type = B_AT_OP_DIVIDE;
+ break;
+ case '&':
+ type = B_AT_OP_AND;
+ break;
+ case '|':
+ type = B_AT_OP_OR;
  break;
  default:
  assert(0);
Index: usr.sbin/btrace/bt_parser.h
===================================================================
RCS file: /cvs/src/usr.sbin/btrace/bt_parser.h,v
retrieving revision 1.9
diff -u -p -r1.9 bt_parser.h
--- usr.sbin/btrace/bt_parser.h 13 Aug 2020 11:29:39 -0000 1.9
+++ usr.sbin/btrace/bt_parser.h 14 Sep 2020 15:14:10 -0000
@@ -143,6 +143,8 @@ struct bt_arg {
  B_AT_OP_MINUS,
  B_AT_OP_MULT,
  B_AT_OP_DIVIDE,
+ B_AT_OP_AND,
+ B_AT_OP_OR,
  } ba_type;
 };
 
Index: usr.sbin/btrace/btrace.c
===================================================================
RCS file: /cvs/src/usr.sbin/btrace/btrace.c,v
retrieving revision 1.24
diff -u -p -r1.24 btrace.c
--- usr.sbin/btrace/btrace.c 11 Sep 2020 08:16:15 -0000 1.24
+++ usr.sbin/btrace/btrace.c 14 Sep 2020 15:14:10 -0000
@@ -812,7 +812,7 @@ stmt_store(struct bt_stmt *bs, struct dt
  case B_AT_BI_NSECS:
  bv->bv_value = ba_new(builtin_nsecs(dtev), B_AT_LONG);
  break;
- case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+ case B_AT_OP_ADD ... B_AT_OP_OR:
  bv->bv_value = ba_new(ba2long(ba, dtev), B_AT_LONG);
  break;
  default:
@@ -992,6 +992,12 @@ baexpr2long(struct bt_arg *ba, struct dt
  case B_AT_OP_DIVIDE:
  result = first / second;
  break;
+ case B_AT_OP_AND:
+ result = first & second;
+ break;
+ case B_AT_OP_OR:
+ result = first | second;
+ break;
  default:
  xabort("unsuported operation %d", ba->ba_type);
  }
@@ -1025,7 +1031,7 @@ ba2long(struct bt_arg *ba, struct dt_evt
  case B_AT_BI_RETVAL:
  val = dtev->dtev_sysretval[0];
  break;
- case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+ case B_AT_OP_ADD ... B_AT_OP_OR:
  val = baexpr2long(ba, dtev);
  break;
  default:
@@ -1093,7 +1099,7 @@ ba2str(struct bt_arg *ba, struct dt_evt
  case B_AT_VAR:
  str = ba2str(ba_read(ba), dtev);
  break;
- case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+ case B_AT_OP_ADD ... B_AT_OP_OR:
  snprintf(buf, sizeof(buf) - 1, "%ld", ba2long(ba, dtev));
  str = buf;
  break;
@@ -1152,7 +1158,7 @@ ba2dtflags(struct bt_arg *ba)
  case B_AT_MF_MAX:
  case B_AT_MF_MIN:
  case B_AT_MF_SUM:
- case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+ case B_AT_OP_ADD ... B_AT_OP_OR:
  break;
  default:
  xabort("invalid argument type %d", ba->ba_type);
Index: regress/usr.sbin/btrace/Makefile
===================================================================
RCS file: /cvs/src/regress/usr.sbin/btrace/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- regress/usr.sbin/btrace/Makefile 19 Mar 2020 15:53:09 -0000 1.4
+++ regress/usr.sbin/btrace/Makefile 14 Sep 2020 15:14:10 -0000
@@ -3,8 +3,8 @@
 BTRACE?= /usr/sbin/btrace
 
 # scripts that don't need /dev/dt
-BT_LANG_SCRIPTS= arithm beginend comments delete exit map map-unnamed \
- maxoperand min+max+sum multismts nsecs+var
+BT_LANG_SCRIPTS= arithm beginend boolean comments delete exit map \
+ map-unnamed maxoperand min+max+sum multismts nsecs+var
 
 BT_KERN_SCRIPTS=
 
Index: regress/usr.sbin/btrace/boolean.bt
===================================================================
RCS file: regress/usr.sbin/btrace/boolean.bt
diff -N regress/usr.sbin/btrace/boolean.bt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regress/usr.sbin/btrace/boolean.bt 14 Sep 2020 15:14:10 -0000
@@ -0,0 +1,8 @@
+BEGIN
+{
+ @a = 9;
+ @b = 1;
+
+ printf("a & b = %d\n", @a & @b);
+ printf("a | b = %d\n", @a | @b);
+}
Index: regress/usr.sbin/btrace/boolean.ok
===================================================================
RCS file: regress/usr.sbin/btrace/boolean.ok
diff -N regress/usr.sbin/btrace/boolean.ok
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regress/usr.sbin/btrace/boolean.ok 14 Sep 2020 15:14:10 -0000
@@ -0,0 +1,2 @@
+a & b = 1
+a | b = 9
--
jasper

Reply | Threaded
Open this post in threaded view
|

Re: btrace: add boolean AND and OR operators

Otto Moerbeek
On Mon, Sep 14, 2020 at 03:28:17PM +0200, Jasper Lievisse Adriaanse wrote:

> Hi,
>
> This diff adds support for the '&' and '|' operators, along with
> a new testcase.
>
> OK?

The precedence looks funny

I'd guess you want

%left '|'
%left '&'
%left '+' '-'
%left '/' '*'

To avoid suprises.

        -Otto

>
> Index: usr.sbin/btrace/bt_parse.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/btrace/bt_parse.y,v
> retrieving revision 1.16
> diff -u -p -r1.16 bt_parse.y
> --- usr.sbin/btrace/bt_parse.y 11 Jul 2020 14:52:14 -0000 1.16
> +++ usr.sbin/btrace/bt_parse.y 14 Sep 2020 15:14:10 -0000
> @@ -119,6 +119,7 @@ static int yylex(void);
>  
>  %left '+' '-'
>  %left '/' '*'
> +%left '&' '|'
>  %%
>  
>  grammar : /* empty */
> @@ -172,6 +173,8 @@ term : '(' term ')' { $$ = $2; }
>   | term '-' term { $$ = ba_op('-', $1, $3); }
>   | term '/' term { $$ = ba_op('/', $1, $3); }
>   | term '*' term { $$ = ba_op('*', $1, $3); }
> + | term '&' term { $$ = ba_op('&', $1, $3); }
> + | term '|' term { $$ = ba_op('|', $1, $3); }
>   | NUMBER { $$ = ba_new($1, B_AT_LONG); }
>   | builtin { $$ = ba_new(NULL, $1); }
>   | gvar { $$ = bv_get($1); }
> @@ -331,6 +334,12 @@ ba_op(const char op, struct bt_arg *da0,
>   break;
>   case '/':
>   type = B_AT_OP_DIVIDE;
> + break;
> + case '&':
> + type = B_AT_OP_AND;
> + break;
> + case '|':
> + type = B_AT_OP_OR;
>   break;
>   default:
>   assert(0);
> Index: usr.sbin/btrace/bt_parser.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/btrace/bt_parser.h,v
> retrieving revision 1.9
> diff -u -p -r1.9 bt_parser.h
> --- usr.sbin/btrace/bt_parser.h 13 Aug 2020 11:29:39 -0000 1.9
> +++ usr.sbin/btrace/bt_parser.h 14 Sep 2020 15:14:10 -0000
> @@ -143,6 +143,8 @@ struct bt_arg {
>   B_AT_OP_MINUS,
>   B_AT_OP_MULT,
>   B_AT_OP_DIVIDE,
> + B_AT_OP_AND,
> + B_AT_OP_OR,
>   } ba_type;
>  };
>  
> Index: usr.sbin/btrace/btrace.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/btrace/btrace.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 btrace.c
> --- usr.sbin/btrace/btrace.c 11 Sep 2020 08:16:15 -0000 1.24
> +++ usr.sbin/btrace/btrace.c 14 Sep 2020 15:14:10 -0000
> @@ -812,7 +812,7 @@ stmt_store(struct bt_stmt *bs, struct dt
>   case B_AT_BI_NSECS:
>   bv->bv_value = ba_new(builtin_nsecs(dtev), B_AT_LONG);
>   break;
> - case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
> + case B_AT_OP_ADD ... B_AT_OP_OR:
>   bv->bv_value = ba_new(ba2long(ba, dtev), B_AT_LONG);
>   break;
>   default:
> @@ -992,6 +992,12 @@ baexpr2long(struct bt_arg *ba, struct dt
>   case B_AT_OP_DIVIDE:
>   result = first / second;
>   break;
> + case B_AT_OP_AND:
> + result = first & second;
> + break;
> + case B_AT_OP_OR:
> + result = first | second;
> + break;
>   default:
>   xabort("unsuported operation %d", ba->ba_type);
>   }
> @@ -1025,7 +1031,7 @@ ba2long(struct bt_arg *ba, struct dt_evt
>   case B_AT_BI_RETVAL:
>   val = dtev->dtev_sysretval[0];
>   break;
> - case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
> + case B_AT_OP_ADD ... B_AT_OP_OR:
>   val = baexpr2long(ba, dtev);
>   break;
>   default:
> @@ -1093,7 +1099,7 @@ ba2str(struct bt_arg *ba, struct dt_evt
>   case B_AT_VAR:
>   str = ba2str(ba_read(ba), dtev);
>   break;
> - case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
> + case B_AT_OP_ADD ... B_AT_OP_OR:
>   snprintf(buf, sizeof(buf) - 1, "%ld", ba2long(ba, dtev));
>   str = buf;
>   break;
> @@ -1152,7 +1158,7 @@ ba2dtflags(struct bt_arg *ba)
>   case B_AT_MF_MAX:
>   case B_AT_MF_MIN:
>   case B_AT_MF_SUM:
> - case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
> + case B_AT_OP_ADD ... B_AT_OP_OR:
>   break;
>   default:
>   xabort("invalid argument type %d", ba->ba_type);
> Index: regress/usr.sbin/btrace/Makefile
> ===================================================================
> RCS file: /cvs/src/regress/usr.sbin/btrace/Makefile,v
> retrieving revision 1.4
> diff -u -p -r1.4 Makefile
> --- regress/usr.sbin/btrace/Makefile 19 Mar 2020 15:53:09 -0000 1.4
> +++ regress/usr.sbin/btrace/Makefile 14 Sep 2020 15:14:10 -0000
> @@ -3,8 +3,8 @@
>  BTRACE?= /usr/sbin/btrace
>  
>  # scripts that don't need /dev/dt
> -BT_LANG_SCRIPTS= arithm beginend comments delete exit map map-unnamed \
> - maxoperand min+max+sum multismts nsecs+var
> +BT_LANG_SCRIPTS= arithm beginend boolean comments delete exit map \
> + map-unnamed maxoperand min+max+sum multismts nsecs+var
>  
>  BT_KERN_SCRIPTS=
>  
> Index: regress/usr.sbin/btrace/boolean.bt
> ===================================================================
> RCS file: regress/usr.sbin/btrace/boolean.bt
> diff -N regress/usr.sbin/btrace/boolean.bt
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ regress/usr.sbin/btrace/boolean.bt 14 Sep 2020 15:14:10 -0000
> @@ -0,0 +1,8 @@
> +BEGIN
> +{
> + @a = 9;
> + @b = 1;
> +
> + printf("a & b = %d\n", @a & @b);
> + printf("a | b = %d\n", @a | @b);
> +}
> Index: regress/usr.sbin/btrace/boolean.ok
> ===================================================================
> RCS file: regress/usr.sbin/btrace/boolean.ok
> diff -N regress/usr.sbin/btrace/boolean.ok
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ regress/usr.sbin/btrace/boolean.ok 14 Sep 2020 15:14:10 -0000
> @@ -0,0 +1,2 @@
> +a & b = 1
> +a | b = 9
> --
> jasper
>

Reply | Threaded
Open this post in threaded view
|

Re: btrace: add boolean AND and OR operators

Jasper Lievisse Adriaanse-2
On Mon, Sep 14, 2020 at 03:39:04PM +0200, Otto Moerbeek wrote:

> On Mon, Sep 14, 2020 at 03:28:17PM +0200, Jasper Lievisse Adriaanse wrote:
>
> > Hi,
> >
> > This diff adds support for the '&' and '|' operators, along with
> > a new testcase.
> >
> > OK?
>
> The precedence looks funny
>
> I'd guess you want
>
> %left '|'
> %left '&'
> %left '+' '-'
> %left '/' '*'
>
> To avoid suprises.
>
> -Otto
Good point.

Index: usr.sbin/btrace/bt_parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/btrace/bt_parse.y,v
retrieving revision 1.16
diff -u -p -r1.16 bt_parse.y
--- usr.sbin/btrace/bt_parse.y 11 Jul 2020 14:52:14 -0000 1.16
+++ usr.sbin/btrace/bt_parse.y 14 Sep 2020 15:41:40 -0000
@@ -117,6 +117,8 @@ static int yylex(void);
 %type <v.arg> expr vargs map mexpr term
 %type <v.rtype> beginend
 
+%left '|'
+%left '&'
 %left '+' '-'
 %left '/' '*'
 %%
@@ -172,6 +174,8 @@ term : '(' term ')' { $$ = $2; }
  | term '-' term { $$ = ba_op('-', $1, $3); }
  | term '/' term { $$ = ba_op('/', $1, $3); }
  | term '*' term { $$ = ba_op('*', $1, $3); }
+ | term '&' term { $$ = ba_op('&', $1, $3); }
+ | term '|' term { $$ = ba_op('|', $1, $3); }
  | NUMBER { $$ = ba_new($1, B_AT_LONG); }
  | builtin { $$ = ba_new(NULL, $1); }
  | gvar { $$ = bv_get($1); }
@@ -331,6 +335,12 @@ ba_op(const char op, struct bt_arg *da0,
  break;
  case '/':
  type = B_AT_OP_DIVIDE;
+ break;
+ case '&':
+ type = B_AT_OP_AND;
+ break;
+ case '|':
+ type = B_AT_OP_OR;
  break;
  default:
  assert(0);
Index: usr.sbin/btrace/bt_parser.h
===================================================================
RCS file: /cvs/src/usr.sbin/btrace/bt_parser.h,v
retrieving revision 1.9
diff -u -p -r1.9 bt_parser.h
--- usr.sbin/btrace/bt_parser.h 13 Aug 2020 11:29:39 -0000 1.9
+++ usr.sbin/btrace/bt_parser.h 14 Sep 2020 15:41:40 -0000
@@ -143,6 +143,8 @@ struct bt_arg {
  B_AT_OP_MINUS,
  B_AT_OP_MULT,
  B_AT_OP_DIVIDE,
+ B_AT_OP_AND,
+ B_AT_OP_OR,
  } ba_type;
 };
 
Index: usr.sbin/btrace/btrace.c
===================================================================
RCS file: /cvs/src/usr.sbin/btrace/btrace.c,v
retrieving revision 1.24
diff -u -p -r1.24 btrace.c
--- usr.sbin/btrace/btrace.c 11 Sep 2020 08:16:15 -0000 1.24
+++ usr.sbin/btrace/btrace.c 14 Sep 2020 15:41:40 -0000
@@ -812,7 +812,7 @@ stmt_store(struct bt_stmt *bs, struct dt
  case B_AT_BI_NSECS:
  bv->bv_value = ba_new(builtin_nsecs(dtev), B_AT_LONG);
  break;
- case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+ case B_AT_OP_ADD ... B_AT_OP_OR:
  bv->bv_value = ba_new(ba2long(ba, dtev), B_AT_LONG);
  break;
  default:
@@ -992,6 +992,12 @@ baexpr2long(struct bt_arg *ba, struct dt
  case B_AT_OP_DIVIDE:
  result = first / second;
  break;
+ case B_AT_OP_AND:
+ result = first & second;
+ break;
+ case B_AT_OP_OR:
+ result = first | second;
+ break;
  default:
  xabort("unsuported operation %d", ba->ba_type);
  }
@@ -1025,7 +1031,7 @@ ba2long(struct bt_arg *ba, struct dt_evt
  case B_AT_BI_RETVAL:
  val = dtev->dtev_sysretval[0];
  break;
- case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+ case B_AT_OP_ADD ... B_AT_OP_OR:
  val = baexpr2long(ba, dtev);
  break;
  default:
@@ -1093,7 +1099,7 @@ ba2str(struct bt_arg *ba, struct dt_evt
  case B_AT_VAR:
  str = ba2str(ba_read(ba), dtev);
  break;
- case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+ case B_AT_OP_ADD ... B_AT_OP_OR:
  snprintf(buf, sizeof(buf) - 1, "%ld", ba2long(ba, dtev));
  str = buf;
  break;
@@ -1152,7 +1158,7 @@ ba2dtflags(struct bt_arg *ba)
  case B_AT_MF_MAX:
  case B_AT_MF_MIN:
  case B_AT_MF_SUM:
- case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
+ case B_AT_OP_ADD ... B_AT_OP_OR:
  break;
  default:
  xabort("invalid argument type %d", ba->ba_type);
Index: regress/usr.sbin/btrace/Makefile
===================================================================
RCS file: /cvs/src/regress/usr.sbin/btrace/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- regress/usr.sbin/btrace/Makefile 19 Mar 2020 15:53:09 -0000 1.4
+++ regress/usr.sbin/btrace/Makefile 14 Sep 2020 15:41:40 -0000
@@ -3,8 +3,8 @@
 BTRACE?= /usr/sbin/btrace
 
 # scripts that don't need /dev/dt
-BT_LANG_SCRIPTS= arithm beginend comments delete exit map map-unnamed \
- maxoperand min+max+sum multismts nsecs+var
+BT_LANG_SCRIPTS= arithm beginend boolean comments delete exit map \
+ map-unnamed maxoperand min+max+sum multismts nsecs+var
 
 BT_KERN_SCRIPTS=
 
Index: regress/usr.sbin/btrace/boolean.bt
===================================================================
RCS file: regress/usr.sbin/btrace/boolean.bt
diff -N regress/usr.sbin/btrace/boolean.bt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regress/usr.sbin/btrace/boolean.bt 14 Sep 2020 15:41:40 -0000
@@ -0,0 +1,8 @@
+BEGIN
+{
+ @a = 9;
+ @b = 1;
+
+ printf("a & b = %d\n", @a & @b);
+ printf("a | b = %d\n", @a | @b);
+}
Index: regress/usr.sbin/btrace/boolean.ok
===================================================================
RCS file: regress/usr.sbin/btrace/boolean.ok
diff -N regress/usr.sbin/btrace/boolean.ok
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regress/usr.sbin/btrace/boolean.ok 14 Sep 2020 15:41:40 -0000
@@ -0,0 +1,2 @@
+a & b = 1
+a | b = 9

Reply | Threaded
Open this post in threaded view
|

Re: btrace: add boolean AND and OR operators

Sebastien Marie-3
In reply to this post by Jasper Lievisse Adriaanse-2
On Mon, Sep 14, 2020 at 03:28:17PM +0200, Jasper Lievisse Adriaanse wrote:
> Hi,
>
> This diff adds support for the '&' and '|' operators, along with
> a new testcase.
>
> OK?

make sens to me. ok semarie@
 

> Index: usr.sbin/btrace/bt_parse.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/btrace/bt_parse.y,v
> retrieving revision 1.16
> diff -u -p -r1.16 bt_parse.y
> --- usr.sbin/btrace/bt_parse.y 11 Jul 2020 14:52:14 -0000 1.16
> +++ usr.sbin/btrace/bt_parse.y 14 Sep 2020 15:14:10 -0000
> @@ -119,6 +119,7 @@ static int yylex(void);
>  
>  %left '+' '-'
>  %left '/' '*'
> +%left '&' '|'
>  %%
>  
>  grammar : /* empty */
> @@ -172,6 +173,8 @@ term : '(' term ')' { $$ = $2; }
>   | term '-' term { $$ = ba_op('-', $1, $3); }
>   | term '/' term { $$ = ba_op('/', $1, $3); }
>   | term '*' term { $$ = ba_op('*', $1, $3); }
> + | term '&' term { $$ = ba_op('&', $1, $3); }
> + | term '|' term { $$ = ba_op('|', $1, $3); }
>   | NUMBER { $$ = ba_new($1, B_AT_LONG); }
>   | builtin { $$ = ba_new(NULL, $1); }
>   | gvar { $$ = bv_get($1); }
> @@ -331,6 +334,12 @@ ba_op(const char op, struct bt_arg *da0,
>   break;
>   case '/':
>   type = B_AT_OP_DIVIDE;
> + break;
> + case '&':
> + type = B_AT_OP_AND;
> + break;
> + case '|':
> + type = B_AT_OP_OR;
>   break;
>   default:
>   assert(0);
> Index: usr.sbin/btrace/bt_parser.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/btrace/bt_parser.h,v
> retrieving revision 1.9
> diff -u -p -r1.9 bt_parser.h
> --- usr.sbin/btrace/bt_parser.h 13 Aug 2020 11:29:39 -0000 1.9
> +++ usr.sbin/btrace/bt_parser.h 14 Sep 2020 15:14:10 -0000
> @@ -143,6 +143,8 @@ struct bt_arg {
>   B_AT_OP_MINUS,
>   B_AT_OP_MULT,
>   B_AT_OP_DIVIDE,
> + B_AT_OP_AND,
> + B_AT_OP_OR,
>   } ba_type;
>  };
>  
> Index: usr.sbin/btrace/btrace.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/btrace/btrace.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 btrace.c
> --- usr.sbin/btrace/btrace.c 11 Sep 2020 08:16:15 -0000 1.24
> +++ usr.sbin/btrace/btrace.c 14 Sep 2020 15:14:10 -0000
> @@ -812,7 +812,7 @@ stmt_store(struct bt_stmt *bs, struct dt
>   case B_AT_BI_NSECS:
>   bv->bv_value = ba_new(builtin_nsecs(dtev), B_AT_LONG);
>   break;
> - case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
> + case B_AT_OP_ADD ... B_AT_OP_OR:
>   bv->bv_value = ba_new(ba2long(ba, dtev), B_AT_LONG);
>   break;
>   default:
> @@ -992,6 +992,12 @@ baexpr2long(struct bt_arg *ba, struct dt
>   case B_AT_OP_DIVIDE:
>   result = first / second;
>   break;
> + case B_AT_OP_AND:
> + result = first & second;
> + break;
> + case B_AT_OP_OR:
> + result = first | second;
> + break;
>   default:
>   xabort("unsuported operation %d", ba->ba_type);
>   }
> @@ -1025,7 +1031,7 @@ ba2long(struct bt_arg *ba, struct dt_evt
>   case B_AT_BI_RETVAL:
>   val = dtev->dtev_sysretval[0];
>   break;
> - case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
> + case B_AT_OP_ADD ... B_AT_OP_OR:
>   val = baexpr2long(ba, dtev);
>   break;
>   default:
> @@ -1093,7 +1099,7 @@ ba2str(struct bt_arg *ba, struct dt_evt
>   case B_AT_VAR:
>   str = ba2str(ba_read(ba), dtev);
>   break;
> - case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
> + case B_AT_OP_ADD ... B_AT_OP_OR:
>   snprintf(buf, sizeof(buf) - 1, "%ld", ba2long(ba, dtev));
>   str = buf;
>   break;
> @@ -1152,7 +1158,7 @@ ba2dtflags(struct bt_arg *ba)
>   case B_AT_MF_MAX:
>   case B_AT_MF_MIN:
>   case B_AT_MF_SUM:
> - case B_AT_OP_ADD ... B_AT_OP_DIVIDE:
> + case B_AT_OP_ADD ... B_AT_OP_OR:
>   break;
>   default:
>   xabort("invalid argument type %d", ba->ba_type);
> Index: regress/usr.sbin/btrace/Makefile
> ===================================================================
> RCS file: /cvs/src/regress/usr.sbin/btrace/Makefile,v
> retrieving revision 1.4
> diff -u -p -r1.4 Makefile
> --- regress/usr.sbin/btrace/Makefile 19 Mar 2020 15:53:09 -0000 1.4
> +++ regress/usr.sbin/btrace/Makefile 14 Sep 2020 15:14:10 -0000
> @@ -3,8 +3,8 @@
>  BTRACE?= /usr/sbin/btrace
>  
>  # scripts that don't need /dev/dt
> -BT_LANG_SCRIPTS= arithm beginend comments delete exit map map-unnamed \
> - maxoperand min+max+sum multismts nsecs+var
> +BT_LANG_SCRIPTS= arithm beginend boolean comments delete exit map \
> + map-unnamed maxoperand min+max+sum multismts nsecs+var
>  
>  BT_KERN_SCRIPTS=
>  
> Index: regress/usr.sbin/btrace/boolean.bt
> ===================================================================
> RCS file: regress/usr.sbin/btrace/boolean.bt
> diff -N regress/usr.sbin/btrace/boolean.bt
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ regress/usr.sbin/btrace/boolean.bt 14 Sep 2020 15:14:10 -0000
> @@ -0,0 +1,8 @@
> +BEGIN
> +{
> + @a = 9;
> + @b = 1;
> +
> + printf("a & b = %d\n", @a & @b);
> + printf("a | b = %d\n", @a | @b);
> +}
> Index: regress/usr.sbin/btrace/boolean.ok
> ===================================================================
> RCS file: regress/usr.sbin/btrace/boolean.ok
> diff -N regress/usr.sbin/btrace/boolean.ok
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ regress/usr.sbin/btrace/boolean.ok 14 Sep 2020 15:14:10 -0000
> @@ -0,0 +1,2 @@
> +a & b = 1
> +a | b = 9
> --
> jasper
>

--
Sebastien Marie