<div dir="ltr"><div>Many tools in the Erlang ecosystem expect the Erlang Abstract Code chunk to exist or, if it doesn't exist, it automatically generates one from the source code, if it can find the respective Erlang source.</div><div><br></div><div>This restricts the use of the existing tooling to only some languages and leads to code duplication in different tools (such as dialyzer, debuger, cover, etc) as each tool includes their own implemention of loading abstract code from beams, fetching it from source as well as converting the abstract code to other formats.</div><div><br></div><div>To partially solve this issue for languages that compile directly to Core, such as LFE, I have earlier proposed a chunk that stores Core AST. However, even if we add such chunk, I can foresee the following problems:</div><div><br></div><div> * Storing the Core AST chunk still does not include the ability of retrieving the AST on the fly in case the chunk is not available for whatever reason</div><div><br></div><div> * Adding a new chunk could potentially make the situation worse because tools in the future may work directly on those new chunks, forcing compilers to add both Erlang Abstract Format and Code AST chunks to the .beam file. Futhermore, it is expected that languages may want to store their own AST as well, which will lead to further increase on the .beam file size</div><div><br></div><div>Therefore we need a mechanism to store abstract code on .beam such that:</div><div><br></div><div> * The abstract code is stored once but can be retrieved in different formats, as supported by the initial language (where the initial language is erlang, core, lfe, elixir, alpaca, etc)</div><div><br></div><div> * If the abstract code is omitted, we should still provide the ability to retrieve it from source if desired, regardless of the initial language</div><div><br></div><div>I have written a proposal which aims to unify how abstract code, or generally speaking, debug information is stored on `.beam` by introducing a new chunk, called "Dbgi" which aims to replace the current "Absc" chunk. The proposal is backwards compatible and solves the problems outlined above.</div><div><br></div><div>The full proposal alongside a prototype can be found on GitHub: <a href="https://github.com/erlang/otp/pull/1367">https://github.com/erlang/otp/pull/1367</a></div><div><br></div><div>Feedback is welcome!</div><div><div class="gmail_signature"><div dir="ltr"><div><div><br></div><div><br></div><div><span style="font-size:13px"><div><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse"><b>José Valim</b></span></div><div><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse"><div><span style="font-family:verdana,sans-serif;font-size:x-small"><a href="http://www.plataformatec.com.br/" style="color:rgb(42,93,176)" target="_blank">www.plataformatec.com.br</a></span></div><div><span style="font-family:verdana,sans-serif;font-size:x-small">Skype: jv.ptec</span></div><div><span style="font-family:verdana,sans-serif;font-size:x-small">Founder and Director of R&D</span></div></span></div></span></div></div></div></div></div>
</div>