Skip to content
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

Source maps for wasm2c? #2215

Open
SoniEx2 opened this issue Apr 25, 2023 · 5 comments
Open

Source maps for wasm2c? #2215

SoniEx2 opened this issue Apr 25, 2023 · 5 comments

Comments

@SoniEx2
Copy link
Contributor

SoniEx2 commented Apr 25, 2023

Does it... make any sense to have source maps for wasm2c?

@keithw
Copy link
Member

keithw commented Apr 25, 2023

It would be nice to have something like this, because it's pretty challenging to debug a program that's been compiled from, e.g., C++ (via g++) to Wasm (and then, via wasm2c) to C (and then, via gcc) to ELF. See #1210 & #432.

An MVP might be to make wasm2c include little comments next to each line of a function body, giving a Wat version of the Wasm instruction, so that if you then compile wasm2c's output with -g, a debugger that speaks DWARF can show the Wat for each line. That seems like a one-day project.

But it would be really nice to plumb it all the way through somehow so that a debugger of the final object file can show the original high-level source code.

@sbc100
Copy link
Member

sbc100 commented Apr 25, 2023

I think we could use C pre-processor directives: https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html

@shravanrn
Copy link
Collaborator

yup, the C-preprocessor debug directives was something I was hoping to do for several months now, but I don't think I have time on my roadmap. I would love to see support for something like this too!

@turbolent
Copy link

turbolent commented May 27, 2023

In w2c2 we parse the DWARF debug info (if provided) from the module, and generate C #line directives. It works fairly well

@shravanrn
Copy link
Collaborator

(Sorry for the delay in responding was traveling)
Ah this is good to know. I will add it to my todo list to see if we can get something like this as well.
Assuming the licenses are compatible, and there are no objections, I am hoping we can borrow some of the implementation from w2c2 for this effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants