Instrumenting Erlang code
Stavros Aronis
aronisstav@REDACTED
Tue Jan 28 09:59:58 CET 2020
>
> @Kostis: does Concuerror (https://github.com/parapluu/Concuerror) use
> this technique?
>
Concuerror's instrumenter does not really work in the way you need. It is
instead doing the following things:
* wraps every function call / apply into a call to an inspector function
concuerror_inspect:inspect (this function does a simple runtime check using
the process dictionary to decide whether a process is under Concuerror or
not)
* adds a similar inspector function to every receive statement
The process dictionary trick used to decide which modules should have the
instrumentation on and which not might be useful to you, if you want to
instrument all modules but not affect all processes: if the process has a
specific atom in its dictionary then instrumentation is on, otherwise not.
Without thinking too much about it, if I wanted to implement your variant
I'd write a parse transform or custom instrumenter that would just
introduce a helper function for every function like this:
Original:
f1() ->
Body1.
Becomes:
f1() ->
instrument:start(),
R = f1_orig(),
instrument:stop(),
R
fi_orig() ->
Body1.
Hope this helps!
Stavros
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200128/93d8d30c/attachment.htm>
More information about the erlang-questions
mailing list