Skip to content

Support vararg match specs for tracing #9999

Open
@michalmuskala

Description

@michalmuskala

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.

Metadata

Metadata

Assignees

Labels

enhancementhelp wantedIssue not worked on by OTP; help wanted from the communityteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions