Description
Is your feature request related to a problem? Please describe.
Today, match specs for tracing have to specify exactly all the arguments the function will expect. This is somewhat disappointing when combined with ability to set tracing on functions with specific name and any arity. For example, to match on lists:seq/2
, and lists:seq/3
where first argument is > 5
:
> Session = trace:session_create(greenbug, self(), []).
> trace:process(Session, self(), true, [call]).
> trace:function(Session, {lists, seq, '_'}, [{['$1' | '_'], [{'>', '$1', 5}], [true]}], [local]).
** exception error: bad argument
Describe the solution you'd like
I'd like match specs to support matching on a prefix of arguments, if combined with the '_'
arity matcher. The syntax for this seems fairly clear - since we match on a list of arguments, we can easily prefix-match the list.
Describe alternatives you've considered
An alternative that works today, but is somewhat cumbersome, is to load the module, get a list of functions from M:module_info(functions)
and find all the matching arities we could set traces for, and generate multiple clauses for the match specs. However, this is quite cumbersome and likely less efficient to execute than necessary.