I'm going through the Erlang module. How is the trace functionality of Erlang's virtual machine implemented?
Does it 'recompile' the bytecodes on the fly to add the trace calls? Or does it 'interpret' all bytecodes per scheduler and do the trace logic in real time each time? Or something else altogether?
It modifies the code at runtime very similarly to how GDB inserts breakpoints into native code.
That is, the first instruction in the function is overwritten by a special trace instruction which does the tracing and then calls the original code before jumping back to the function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With