[erlang-questions] erl_tracer, trace_status and pids

Lukas Larsson lukas@REDACTED
Tue May 30 15:05:36 CEST 2017


On Tue, May 30, 2017 at 11:40 AM, Loïc Hoguin <essen@REDACTED> wrote:

> On 05/30/2017 10:14 AM, Loïc Hoguin wrote:
>
>>     * trace_status is always called before any other enabled_*/3 so I
>>>     should be fine just doing nothing in enabled_*/3, right? I'm only
>>>     checking that the tracer processes are still alive anyway.
>>>
>>>
>>> no, trace_status is not always called before enabled_*. The only event
>>> that I know of where it is called is enabled_call/3, there may be a couple
>>> of more but not all of them.
>>>
>>
>> Alright. I'm a bit confused still. Would it make sense to only perform
>> some checks for trace_status, for example checking that the tracer process
>> exists? Then for other enabled_*/3 calls I would just reject events I don't
>> need.
>>
>>     Basically if you could shed light on the circumstances around
>>>     trace_status that would help a lot for optimizing this. :-)
>>>
>>>
>>> the check for trace_status call is made in various places in the vm code
>>> where the VM finds it convenient to do a check and see if the tracer is
>>> still alive. There are no specific rules about when it is called.
>>>
>>
>> It sounds like the answer to my question is a yes. :-)
>>
>
> Answering myself.
>
> I think what I was looking for can be found in this sentence of the
> documentation:
>
> "It is called in multiple scenarios, but most significantly it is used
> when tracing is started using this tracer."
>
> If correct, then this means trace_status is always called at least once
> before anything happens; and that's good enough for me. That would allow me
> to remove traces for the tracer processes immediately when receiving the
> trace_status, and not have to worry about that in enabled_*/3 calls.
>

It is not overly clear/correct in the docs. One purpose of trace_status was
that it and only it should be able to remove tracers from the tracee. There
are assertions in the code that prohibit trace nifs from returning 'remove'
from any event other then trace_status. However, those are only triggered
in debug builds. The current non-debug code and to some extent docs seems
to allow enabled_*/3 calls to also remove tracers from tracees.

Writing clear and concise documentation is hard.

Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170530/3aa88fd4/attachment.htm>


More information about the erlang-questions mailing list