<br><br><div class="gmail_quote">Den 12 april 2012 19:39 skrev Emilio De Camargo Francesquini <span dir="ltr"><<a href="mailto:francesquini@gmail.com">francesquini@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello again,<br>
<br>
I was playing around with dbg:p/2 and I realized that it does not<br>
accept the flag 'exiting'. I browsed the code a little bit and found<br>
out that it accepts only the flags declared in dbg:all/0. Here's the<br>
code:<br>
<br>
all() -><br>
[send,'receive',call,procs,garbage_collection,running,<br>
set_on_spawn,set_on_first_spawn,set_on_link,set_on_first_link,<br>
timestamp,arity,return_to].<br>
<br>
I took a brief look at the documentation, and found that "The list can<br>
also include any of the flags allowed in erlang:trace/3".<br>
<br>
Is this a bug or a deliberate decision?<br></blockquote><div><br></div><div>I am not so sure that this is a deliberate decision .. in fact a believe the opposite.</div><div><br></div><div>If I recall correctly, the 'exiting' option is newer tracing option (though it apparently older than R13B03). I think it was added when some process termination internals got rewritten. dbg were probably overlooked when implementing it. </div>
<div><br></div><div>Does it work as intended for you if you add 'exiting' to all/0 in this case?</div><div><br></div><div>// Björn-Egil</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks!<br>
<br>
<br>
Le 10 avril 2012 14:46, Björn-Egil Dahlberg <<a href="mailto:egil@erlang.org">egil@erlang.org</a>> a écrit :<br>
<div class="HOEnZb"><div class="h5">> On 2012-04-09 19:49, Emilio De Camargo Francesquini wrote:<br>
>><br>
>> Hello,<br>
>><br>
>> I'm having some trouble understanding the exact meaning of two of the<br>
>> flags for the erlang:trace/3 function.<br>
>><br>
>> Flag:<br>
>><br>
>> - running<br>
>> Trace scheduling of processes.<br>
>> Message tags: in, and out.<br>
>><br>
>> I imagine that a message tagged "in" means that the process was chosen<br>
>> by a scheduler and will begin/resume execution and a tag "out" means<br>
>> that the processes has been preempted. Is that correct?<br>
><br>
> Correct but, to be clear, not only preempted. The tag "out" will be sent if<br>
> the process is scheduled out for any reason.<br>
><br>
>> - exiting<br>
>> Trace scheduling of an exiting processes.<br>
>> Message tags: in_exiting, out_exiting, and out_exited.<br>
>><br>
>> I guess that these messages are sent when the proccess is about to<br>
>> exit or has already exited. Am I right? What is the exact difference<br>
>> between each one of them?<br>
><br>
> With "in_exiting" and "out_exiting" the process is scheduled as normal but<br>
> it is in limbo. This means the process is dead but has to be scheduled in<br>
> order to terminate and cleanup internally in the runtime. In other words, it<br>
> will not execute beam-code any more just terminate. Why? It simplifies<br>
> things internally.<br>
><br>
>> Moreover, what is the difference between "exiting" flag with the tag<br>
>> "out_exited" and "procs" flag with the tag "exit"?<br>
><br>
> The tag "exit" from procs is sent when the process is deemed dead, i.e. it<br>
> is exiting. The last chunk of beam code the process executed was some form<br>
> of exit. At this moment in time process has the state EXITING but will<br>
> potentially be scheduled again.<br>
><br>
> The trace will after this be out_exited or, if more has to be done to<br>
> terminate it, out_exiting and in_exiting. Ex:<br>
><br>
><br>
> Eshell V5.9 (abort with ^G)<br>
> 1> P = spawn(fun() -> receive Ok -> ok end end).<br>
> <0.34.0><br>
> 2> erlang:trace(P, true, [running, procs, exiting]).<br>
> 1<br>
> 3> P ! ok.<br>
> ok<br>
> 4> flush().<br>
> Shell got {trace,<0.34.0>,in,{erl_eval,receive_clauses,6}}<br>
> Shell got {trace,<0.34.0>,exit,normal}<br>
> Shell got {trace,<0.34.0>,out_exited,0}<br>
> ok<br>
><br>
> I hope this clarifies things.<br>
><br>
> Regards,<br>
> Björn-Egil<br>
> Erlang/OTP<br>
> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br>