-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse debug information such as files and locations from .s files. #347
Conversation
Example of .s file (generated with clang -g1 option) (llvm needs https://gist.github.com/yurydelendik/a37b786dae40736ed7a1b04770f9c9ed):
s2wasm output:
P.S. source float test(int i) {
float n = i;
float c = 2.0f;
return c / n;
} |
e458bbd
to
4ec135f
Compare
@sunfishcode: is the debug output from the backend stable? is now a good time to start parsing it as in this PR? |
Also curious to hear @jfbastien and @dschuff's thoughts as well. |
It would be good to get @rossberg-chromium / @binji input on the representation of the debug info. I think the spec repo may be the best place to suggest a syntax first, instead of here. |
Related conversation at WebAssembly/spec#258 Just to clarify. I want to limit this PR only to parsing of .s files (that we are producing with clang's '-g' flag). Embedding the debug info into wast or wasm format needs to be out of this PR scope (I placed this info as comments in wasm atm). So far we cannot only pull DWARF information about binding of virtual registers to the variable names, rest of it (files, line numbers, scopes) looks okay. |
Yes, the debug output format follows DWARF, so while the details may change, the overall format is pretty stable. That said, I expect any approach focused on translating a subset of DWARF into some other format will be a temporary solution. |
Can you please elaborate as to why it would be temporary? |
Because it will eventually be surpassed by browsers offering a debugging API, and content providing its own debuggers. |
Just to make sure, the .s file produced by llvm webassembly backend will contain non-translated subset of DWARF stored in llvm assembly text format. The goal will be parse and repackage it into something browsers can consume (e.g. subsections in wasm, separate files, etc.). Is it correct? |
Changed title to better reflect the intent of the PR. |
I don't really like that we're generating this debug information as comments in the wast format. I think it would be better to develop a design first so we can have it exist as a real node. |
89afc3e
to
03e879e
Compare
Added '--debug-info' argument to the s2wasm to enable printing of the "debug" comments. More advanced example can be found at https://gist.github.com/yurydelendik/352dc3250d92191fc7f38dd0daf6a022 . Please notice that we might have "guide" bookmarks/labels in the text format to setup scope and ranges needed for debug sections:
The example above shows that from '.Ltmp1' bookmark to '.Lfunc_end0' one, some variable ('c') can be evaluated using constant 2.0 (an expression can be more complex). The point is that we will need to mark AST node somehow to properly set ranges in the code, and single range in .s file might map into multiple "AST" ranges (? checking this atm). |
69f2dc1
to
bb512f2
Compare
LLVM backend can provide debug information about source code locations for compiled bytecode in form of .file and .loc directives. We can store and use them in s-expression format (via comments?), asm.js via source maps and later in binary in additional sections.
Is this still relevant, or can we close it? |
Closing due to inactivity. |
LLVM backend can provide debug information about source code locations
for compiled bytecode in form of .file and .loc directives. We can store
and use them in s-expression format (via comments?), asm.js via source maps
and later in binary in additional sections.