Sequential trace in match specification problems..

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sequential trace in match specification problems..

Francesco Mazzoli-2
Hello everyone,
I am having problems with sequential tokens. (For those of
you who have never used them, take a look at them as it is
an excellent addition to the trace capabilities which came
out with R7). I have been getting problems/strange
behaviours when I try to set tokens in the shell. The major
problem, however, seems to set trace tokens with match
specifications. The match specification is triggered, (I
have printed stuff out, valid trace tokens included), but
the trace tokens are not associated with the tokens.

sequence:start() spawns three processes, and registers
them. When process a receieves a start message, it sends a
message to b and c, which in turn send a message to a.
sequence:start_tracer() receives messages and prints them
out. I have played around with the syntax, but to no avail.
Nor have I found any documentatins on restrictions. Help
anyone?

Thanks!
Francesco

--
2> sequential:start_tracer().
false
3> dbg:p(new, [c,m]).
{ok,[{matched,0}]}
4> (<0.37.0>) <0.20.0> ! {io_request,<0.37.0>,
                                  <0.20.0>,
                                  {get_until,
                                      {format,"~w> ",[4]},
                                      erl_scan,
                                      tokens,
                                      [1]}}
4> sequential:start().
(<0.37.0>) << {io_reply,<0.20.0>,
                        {ok,[{atom,1,sequential},
                             {':',1},
                             {atom,1,start},
                             {'(',1},
                             {')',1},
                             {dot,1}],
                            2}}
(<0.37.0>) << timeout
true
5> (<0.42.0>) <0.20.0> ! {io_request,<0.42.0>,
                                  <0.20.0>,
                                  {get_until,
                                      {format,"~w> ",[5]},
                                      erl_scan,
                                      tokens,
                                      [1]}}
5> a ! start.
(<0.42.0>) << {io_reply,<0.20.0>,
                        {ok,[{atom,1,a},{'!',1},
{atom,1,start},{dot,1}],2}}
(<0.42.0>) << timeout
start
(<0.41.0>) << start
6> (<0.41.0>) b ! start
6> (<0.40.0>) << start
6> (<0.40.0>) c ! init
6> (<0.39.0>) << init
6> (<0.40.0>) d ! init
6> (<0.38.0>) << init
6> (<0.39.0>) a ! ok
6> (<0.41.0>) << ok
6> (<0.38.0>) a ! ok
6> (<0.41.0>) << ok
6> (<0.43.0>) <0.20.0> ! {io_request,<0.43.0>,
                                  <0.20.0>,
                                  {get_until,
                                      {format,"~w> ",[6]},
                                      erl_scan,
                                      tokens,
                                      [1]}}
6>




Reply | Threaded
Open this post in threaded view
|

Sequential trace in match specification problems..

Francesco Mazzoli-2
For those interested, the strange behaviour of the seq_trace in the
shell (and in my example) was because of all the internal io messages
between the shell and its group leader which were resetting the trace
tokens. Using dbg:p(new, [c]) does not reset the token. Another (and
obvious solution) is to set the token internally in process a once the
initial message has been received.  (It might be worth putting a note of
the io disturbances in the shell in the documentation.)

Thanks everyone.

Francesco

Francesco Cesarini wrote:

> Hello everyone,
> I am having problems with sequential tokens. (For those of
> you who have never used them, take a look at them as it is
> an excellent addition to the trace capabilities which came
> out with R7). I have been getting problems/strange
> behaviours when I try to set tokens in the shell. The major
> problem, however, seems to set trace tokens with match
> specifications. The match specification is triggered, (I
> have printed stuff out, valid trace tokens included), but
> the trace tokens are not associated with the tokens.
>
> sequence:start() spawns three processes, and registers
> them. When process a receieves a start message, it sends a
> message to b and c, which in turn send a message to a.
> sequence:start_tracer() receives messages and prints them
> out. I have played around with the syntax, but to no avail.
> Nor have I found any documentatins on restrictions. Help
> anyone?
>
> Thanks!
> Francesco
>
> --
> 2> sequential:start_tracer().
> false
> 3> dbg:p(new, [c,m]).
> {ok,[{matched,0}]}
> 4> (<0.37.0>) <0.20.0> ! {io_request,<0.37.0>,
>                                   <0.20.0>,
>                                   {get_until,
>                                       {format,"~w> ",[4]},
>                                       erl_scan,
>                                       tokens,
>                                       [1]}}
> 4> sequential:start().
> (<0.37.0>) << {io_reply,<0.20.0>,
>                         {ok,[{atom,1,sequential},
>                              {':',1},
>                              {atom,1,start},
>                              {'(',1},
>                              {')',1},
>                              {dot,1}],
>                             2}}
> (<0.37.0>) << timeout
> true
> 5> (<0.42.0>) <0.20.0> ! {io_request,<0.42.0>,
>                                   <0.20.0>,
>                                   {get_until,
>                                       {format,"~w> ",[5]},
>                                       erl_scan,
>                                       tokens,
>                                       [1]}}
> 5> a ! start.
> (<0.42.0>) << {io_reply,<0.20.0>,
>                         {ok,[{atom,1,a},{'!',1},
> {atom,1,start},{dot,1}],2}}
> (<0.42.0>) << timeout
> start
> (<0.41.0>) << start
> 6> (<0.41.0>) b ! start
> 6> (<0.40.0>) << start
> 6> (<0.40.0>) c ! init
> 6> (<0.39.0>) << init
> 6> (<0.40.0>) d ! init
> 6> (<0.38.0>) << init
> 6> (<0.39.0>) a ! ok
> 6> (<0.41.0>) << ok
> 6> (<0.38.0>) a ! ok
> 6> (<0.41.0>) << ok
> 6> (<0.43.0>) <0.20.0> ! {io_request,<0.43.0>,
>                                   <0.20.0>,
>                                   {get_until,
>                                       {format,"~w> ",[6]},
>                                       erl_scan,
>                                       tokens,
>                                       [1]}}
> 6>

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




Reply | Threaded
Open this post in threaded view
|

Sequential trace in match specification problems..

Raimo Niskanen-3
For those interested, this strange behaviour of seq_trace extends to all
code where a message is received from a port, e.g when the shell
receives from the ttsl driver, or if you do a file operation, or even
worse when some code is not loaded and the code server does a file
operation for you.

It is in most cases possible to do workarounds.

We are nevertheless planning a patch that makes messages received from
ports not resetting the trace token, in contrast to all other received
messages (that resets the trace token). No promises yet, the
consequenses of such a patch might be undesired.

/ Raimo Niskanen, Erlang/OTP, Ericsson UAB



Francesco Cesarini wrote:

>
> For those interested, the strange behaviour of the seq_trace in the
> shell (and in my example) was because of all the internal io messages
> between the shell and its group leader which were resetting the trace
> tokens. Using dbg:p(new, [c]) does not reset the token. Another (and
> obvious solution) is to set the token internally in process a once the
> initial message has been received.  (It might be worth putting a note of
> the io disturbances in the shell in the documentation.)
>
> Thanks everyone.
>
> Francesco
>
> Francesco Cesarini wrote:
>
> > Hello everyone,
> > I am having problems with sequential tokens. (For those of
> > you who have never used them, take a look at them as it is
> > an excellent addition to the trace capabilities which came
> > out with R7). I have been getting problems/strange
> > behaviours when I try to set tokens in the shell. The major
> > problem, however, seems to set trace tokens with match
> > specifications. The match specification is triggered, (I
> > have printed stuff out, valid trace tokens included), but
> > the trace tokens are not associated with the tokens.
> >
> > sequence:start() spawns three processes, and registers
> > them. When process a receieves a start message, it sends a
> > message to b and c, which in turn send a message to a.
> > sequence:start_tracer() receives messages and prints them
> > out. I have played around with the syntax, but to no avail.
> > Nor have I found any documentatins on restrictions. Help
> > anyone?
> >
> > Thanks!
> > Francesco
> >
> > --
> > 2> sequential:start_tracer().
> > false
> > 3> dbg:p(new, [c,m]).
> > {ok,[{matched,0}]}
> > 4> (<0.37.0>) <0.20.0> ! {io_request,<0.37.0>,
> >                                   <0.20.0>,
> >                                   {get_until,
> >                                       {format,"~w> ",[4]},
> >                                       erl_scan,
> >                                       tokens,
> >                                       [1]}}
> > 4> sequential:start().
> > (<0.37.0>) << {io_reply,<0.20.0>,
> >                         {ok,[{atom,1,sequential},
> >                              {':',1},
> >                              {atom,1,start},
> >                              {'(',1},
> >                              {')',1},
> >                              {dot,1}],
> >                             2}}
> > (<0.37.0>) << timeout
> > true
> > 5> (<0.42.0>) <0.20.0> ! {io_request,<0.42.0>,
> >                                   <0.20.0>,
> >                                   {get_until,
> >                                       {format,"~w> ",[5]},
> >                                       erl_scan,
> >                                       tokens,
> >                                       [1]}}
> > 5> a ! start.
> > (<0.42.0>) << {io_reply,<0.20.0>,
> >                         {ok,[{atom,1,a},{'!',1},
> > {atom,1,start},{dot,1}],2}}
> > (<0.42.0>) << timeout
> > start
> > (<0.41.0>) << start
> > 6> (<0.41.0>) b ! start
> > 6> (<0.40.0>) << start
> > 6> (<0.40.0>) c ! init
> > 6> (<0.39.0>) << init
> > 6> (<0.40.0>) d ! init
> > 6> (<0.38.0>) << init
> > 6> (<0.39.0>) a ! ok
> > 6> (<0.41.0>) << ok
> > 6> (<0.38.0>) a ! ok
> > 6> (<0.41.0>) << ok
> > 6> (<0.43.0>) <0.20.0> ! {io_request,<0.43.0>,
> >                                   <0.20.0>,
> >                                   {get_until,
> >                                       {format,"~w> ",[6]},
> >                                       erl_scan,
> >                                       tokens,
> >                                       [1]}}
> > 6>
>
> --
> http://www.erlang-consulting.com