The short answer is that there is no good guide. And the code is not very well documented. I recommend finding someone in your neighbourhood that knows the code reasonably well, and buy them dinner in exchange for a little chat. If you don't have the possibility to do that, then I recommend starting with the loader.
./erts/emulator/beam/beam_load.c
Some useful information can also be found by pretty printing the beam representation. I don't know whether there is any way to do so supplied by OTP, but the HiPE project has some cheats.
hipe:c(MODULE, [pp_beam]).
Should get you started. (And I also recommend Joe's book.)
5条答案
按热度按时间798qvoo81#
首先,您可能想看一下Joe Armstrong's thesis,它在较高的层次上介绍了Erlang。了解该语言背后的思想是很有用的。然后,您可以关注Erlang运行时系统(erts)。erlang.erl模块可以是一个很好的开始。然后,我将集中讨论构成所谓的 * 最小发布 * 的应用程序,* * kernel和stdlib**。在stdlib中,看看 * behaviors * 是如何实现的。我可以建议从gen_server. erl模块开始吗?
csbfibhn2#
A Guide To The Erlang Source
http://www.trapexit.org/A_Guide_To_The_Erlang_Source
polkgigr3#
The short answer is that there is no good guide. And the code is not very well documented.
I recommend finding someone in your neighbourhood that knows the code reasonably well, and buy them dinner in exchange for a little chat.
If you don't have the possibility to do that, then I recommend starting with the loader.
Some useful information can also be found by pretty printing the beam representation. I don't know whether there is any way to do so supplied by OTP, but the HiPE project has some cheats.
Should get you started.
(And I also recommend Joe's book.)
ebdffaop4#
beam的漂亮打印机可以通过“erlc -S”来完成,这与丹尼尔提到的hipe:c(M,[pp_beam])是等价的。
我还使用
erts_debug:df(Module).
来反汇编加载的beam代码,这些代码实际上是由VM解释的指令。有时我会使用调试器。OTP提供了很好的支持gdb的工具。参见http://www.erlang.org/pipermail/erlang-questions/2008-September/037793.html的示例用法
hmae6n7t5#
如果你只是从GitHub下载源代码的话,内部文档确实很好,你必须用
make
生成一些。构建文档,大部分相关源代码位于
/erts
(Erlang运行时系统)下编辑:BEAM Wisdoms也是一个很好的指南,但它可能是也可能不是你所追求的。