Re: bt.5 document count()

2021-11-16 Thread Dave Voutila


Claudio Jeker  writes:

> This documents count(). This function only works when used like this
>   @map[key] = count();
> But it is implemented and works. If used differently you get a syntax
> error which is not helpful. This is why I chose to document it like this.
> Another option would be to document the language (so it is clear where it
> is possible to use what).
>
> max(), min() and sum() are other functions that behave like this. Their
> documentation should also be adjusted IMO.

Since these are all "map functions" per bpftrace [1] and we're aiming to
keep parity with that language, should we separate them from the vague
list of "functions" into their own section? They can't be used elsewhere.

-dv

[1] 
https://github.com/iovisor/bpftrace/blob/master/docs/reference_guide.md#map-functions



Re: bt.5 document count()

2021-11-16 Thread Martin Pieuchot
On 16/11/21(Tue) 11:07, Claudio Jeker wrote:
> This documents count(). This function only works when used like this
>   @map[key] = count();
> But it is implemented and works. If used differently you get a syntax
> error which is not helpful. This is why I chose to document it like this.
> Another option would be to document the language (so it is clear where it
> is possible to use what). 

ok mpi@

> max(), min() and sum() are other functions that behave like this. Their
> documentation should also be adjusted IMO.
> 
> -- 
> :wq Claudio
> 
> Index: bt.5
> ===
> RCS file: /cvs/src/usr.sbin/btrace/bt.5,v
> retrieving revision 1.13
> diff -u -p -r1.13 bt.5
> --- bt.5  12 Nov 2021 16:57:24 -  1.13
> +++ bt.5  16 Nov 2021 09:50:52 -
> @@ -120,6 +120,11 @@ Functions:
>  .It Fn clear "@map"
>  Delete all (key, value) pairs from
>  .Va @map .
> +.It "@map[key]" = Fn count
> +Increment the value of
> +.Va key
> +from
> +.Va @map .
>  .It Fn delete "@map[key]"
>  Delete the pair indexed by
>  .Va key
>