Match Specifications

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Match Specifications

Siri Hansen-2
I don't think the parameter to enable_trace should be a list, it should rather be {enable_trace,procs} (but I didn't try).

Also, you should be aware that by specifying the MatchHead as [] you implicitly say that the match spec is true only for functions with zero arguments. If you mean to hit all functions i your module ping your MatchHead should be '_'.

Good luck!

/siri

-----Original Message-----
From: Francesco Cesarini [mailto:francesco]
Sent: Wednesday, October 24, 2001 12:37 PM
To: erlang-questions
Subject: Match Specifications


Hi!
I got stuck with match specifications and wonder if anyone can find the
error or confirm if it is a bug.. When the match specification is
successful, I want to enable the tracing of all process related
activities, but the flags do not seem to get activated. Other actions
(Even if I have not tried all) seem to work ok. Here is the problem
stripped to a bare minimum:

3> P = ping:start().
<0.37.0>
4> erlang:trace(P, true, [call]).
1
5> erlang:trace_pattern({ping,'_','_'}, [{[],[],[{enable_trace,
[procs]}]}],[local]).
5
6> ping:send(P).
pong
7> flush().
Shell got {trace,<0.37.0>,call,{ping,loop,[]}}
ok
8> erlang:trace_info(P, flags).
{flags,[call]}
9> ping:send(P).
pong
10> flush().
Shell got {trace,<0.37.0>,call,{ping,loop,[]}}
ok

-module(ping).
-export([start/0, send/1, loop/0]).

start() ->
    spawn(ping, loop, []).

send(Pid) ->
    Pid ! {self(), ping},
    receive
        pong -> pong
    end.

loop() ->
    receive
        {Pid, ping} ->
             spawn(crash, do_not_exist, []),
             Pid ! pong,
             loop()
      end.

Thanks!
Francesco
--
http://www.erlang-consulting.com



Reply | Threaded
Open this post in threaded view
|

Match Specifications

Francesco Mazzoli-2
Siri is right.. The match specifications can only handle a flag at the time (Unlike the arguments in the bifs and dbg). The correct specification is

5> erlang:trace_pattern({ping,'_','_'}, [{[],[],[{enable_trace, procs}]}],[local]).
5
6> ping:send(P).
pong
7> flush().
Shell got {trace,<0.37.0>,call,{ping,loop,[]}}
ok
8> erlang:trace_info(P, flags).
{flags,[procs, call]}
9> ping:send(P).
pong
10> flush().
Shell got {trace,<0.37.0>,spawn, <0.40.0>,{crash,do_not_exist,[]}}
Shell got {trace,<0.37.0>,call,{ping,loop,[]}}
ok

//Francesco

"Siri Hansen (ETO)" wrote:

> I don't think the parameter to enable_trace should be a list, it should rather be {enable_trace,procs} (but I didn't try).
>
> Also, you should be aware that by specifying the MatchHead as [] you implicitly say that the match spec is true only for functions with zero arguments. If you mean to hit all functions i your module ping your MatchHead should be '_'.
>
> Good luck!
>
> /siri
>
> -----Original Message-----
> From: Francesco Cesarini [mailto:francesco]
> Sent: Wednesday, October 24, 2001 12:37 PM
> To: erlang-questions
> Subject: Match Specifications
>
> Hi!
> I got stuck with match specifications and wonder if anyone can find the
> error or confirm if it is a bug.. When the match specification is
> successful, I want to enable the tracing of all process related
> activities, but the flags do not seem to get activated. Other actions
> (Even if I have not tried all) seem to work ok. Here is the problem
> stripped to a bare minimum:
>
> 3> P = ping:start().
> <0.37.0>
> 4> erlang:trace(P, true, [call]).
> 1
> 5> erlang:trace_pattern({ping,'_','_'}, [{[],[],[{enable_trace,
> [procs]}]}],[local]).
> 5
> 6> ping:send(P).
> pong
> 7> flush().
> Shell got {trace,<0.37.0>,call,{ping,loop,[]}}
> ok
> 8> erlang:trace_info(P, flags).
> {flags,[call]}
> 9> ping:send(P).
> pong
> 10> flush().
> Shell got {trace,<0.37.0>,call,{ping,loop,[]}}
> ok
>
> -module(ping).
> -export([start/0, send/1, loop/0]).
>
> start() ->
>     spawn(ping, loop, []).
>
> send(Pid) ->
>     Pid ! {self(), ping},
>     receive
>         pong -> pong
>     end.
>
> loop() ->
>     receive
>         {Pid, ping} ->
>              spawn(crash, do_not_exist, []),
>              Pid ! pong,
>              loop()
>       end.
>
> Thanks!
> Francesco
> --
> http://www.erlang-consulting.com

--
http://www.erlang-consulting.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: francesco.vcf
Type: text/x-vcard
Size: 352 bytes
Desc: Card for Francesco Cesarini
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20011024/94cfaa3a/attachment.vcf>