Skip to content

erts: Support prefix argument matching in trace match specs#10754

Merged
sverker merged 2 commits intoerlang:masterfrom
michalmuskala:match-spec-prefix
Mar 5, 2026
Merged

erts: Support prefix argument matching in trace match specs#10754
sverker merged 2 commits intoerlang:masterfrom
michalmuskala:match-spec-prefix

Conversation

@michalmuskala
Copy link
Copy Markdown
Contributor

@michalmuskala michalmuskala commented Feb 24, 2026

Allow trace match spec heads to use [Arg1, Arg2 | '_'] syntax to match functions with at least N arguments, regardless of actual arity. This is useful when combined with the '_' arity wildcard in trace:function/4, e.g. to trace lists:seq/2 and lists:seq/3 with a single match spec that only constrains the first argument.

The prefix flag is encoded as a tag bit on the arity operand of the existing matchArray instruction (bit 8, since max arity is 255), avoiding the need for a separate VM instruction.

Fixes #9999

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 24, 2026

CT Test Results

    3 files    136 suites   50m 8s ⏱️
1 665 tests 1 608 ✅ 57 💤 0 ❌
2 305 runs  2 230 ✅ 75 💤 0 ❌

Results for commit 3910919.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Mar 2, 2026
Copy link
Copy Markdown
Contributor

@sverker sverker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add something in the match spec docs also:

Extend the grammar
https://www.erlang.org/doc/apps/erts/match_spec#grammar

Add an example or modify one of the existing
https://www.erlang.org/doc/apps/erts/match_spec#tracing-examples

Comment thread erts/emulator/beam/erl_db_util.c Outdated
Comment thread erts/emulator/beam/erl_db_util.c Outdated
@michalmuskala
Copy link
Copy Markdown
Contributor Author

I pushed a commit that addresses the feedback:

  • adds docs
  • switches to a separate matchArrayPrefix op

@sverker
Copy link
Copy Markdown
Contributor

sverker commented Mar 3, 2026

@michalmuskala Thanks. Sorry for the nitpickery.

@sverker sverker added testing currently being tested, tag is used by OTP internal CI feature labels Mar 3, 2026
michalmuskala and others added 2 commits March 5, 2026 12:49
Allow trace match spec heads to use [Arg1, Arg2 | '_'] syntax to match
functions with at least N arguments, regardless of actual arity. This is
useful when combined with the '_' arity wildcard in trace:function/4, e.g.
to trace lists:seq/2 and lists:seq/3 with a single match spec that only
constrains the first argument.

The prefix flag is encoded as a tag bit on the arity operand of the
existing matchArray instruction (bit 8, since max arity is 255), avoiding
the need for a separate VM instruction.
@sverker sverker force-pushed the match-spec-prefix branch from fb5425f to 3910919 Compare March 5, 2026 11:51
@sverker sverker merged commit db20095 into erlang:master Mar 5, 2026
30 of 31 checks passed
@michalmuskala michalmuskala deleted the match-spec-prefix branch March 5, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support vararg match specs for tracing

3 participants