-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[question] Matching on maps not supported? #2
Comments
sorry for the late reply. AFAICT, the BEAM tracing does not support matching on maps. Possibly that has changed in erlang 20? |
I couldn't find any information on it, so today I tried to repro it to see if it's supported. It seems like it's possible, at least on Erlang 20.
-module(wat).
-export([start/1]).
start(X) -> X. Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V9.0 (abort with ^G)
1> c(wat).
{ok,wat}
2> l(wat).
{module,wat}
3> erlang:trace(all, true, [call]).
29
4> erlang:trace_pattern({wat, start, '_'}, [{[#{foo => bar}], [], []}], [local]).
1
5> spawn(fun() -> wat:start(#{baz => ban}) end).
<0.70.0>
6> spawn(fun() -> wat:start(#{foo => bar}) end).
<0.72.0>
7> spawn(fun() -> wat:start(foo) end).
<0.74.0>
8> flush().
Shell got {trace,<0.72.0>,call,{wat,start,[#{foo => bar}]}}
ok I'll try earlier versions of Erlang to see where it's possible. I'd be happy to write a PR to make matching on maps possible in |
The example I posted works in in 19.3 and 18.3, I had problems compiling 17.x so I couldn't check further than that. |
I'll do it. I've been waiting for them to support maps (or maybe they did all along and I just missed it). |
Brilliant, thank you! |
(Possibly) fixed in 0bc3ffa |
I tried 935ae87 and it works like a charm, with var binding, good errors for invalid trace patterns and everything. From CI it looks like it doesn't work with Erlang 16 anymore, but it should be ok with semver if you release it under 1.2.x. Thank you for doing this! |
I'll tag it with 1.2.0 |
fixed in 1.2.0 |
When playing around with
redbug
(which I loved right out of the gate) I realized it doesn't support matching maps in the trace pattern arguments:After looking at the source code, I think it's intentional.
While I'm not questioning the decision, I'm curious to the motivation. Is there any reason in particular why matching maps isn't supported in the trace pattern?
Thanks in advance and sorry to bother you with this GitHub issue.
The text was updated successfully, but these errors were encountered: