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

Dwarf doesnt load source files #13486

Closed
amarav opened this issue Feb 12, 2021 · 12 comments
Closed

Dwarf doesnt load source files #13486

amarav opened this issue Feb 12, 2021 · 12 comments

Comments

@amarav
Copy link

amarav commented Feb 12, 2021

I'm trying to debug my c++ application usind Dwarf on Chrome Version 89.0.4389.47 (Official Build) beta (64-bit)
But, Unable to see the source files in the Inspect window
Need help to resolve it

This is the option i use
emcc --preload-file rdf_cpp/resources/Resources.tar -I include -s USE_LIBPNG=1 -s ALLOW_MEMORY_GROWTH=1 -s WASM=1 librendercore.a main.cpp rdf_cpp/.cpp rdf_cpp/scripts/.cpp -o rendercoreweb.js -o rendercoreweb.html -g -fdebug-compilation-dir=".."

In the console/sources window, i can see only the .html,.js and .wasm file.

Expected: Source files to debug

@kripken
Copy link
Member

kripken commented Feb 12, 2021

cc @RReverser @pfaffe

@RReverser
Copy link
Collaborator

@amarav Sorry to hear it doesn't work. Did you install the extension and enable the flag as per instructions at https://goo.gle/wasm-debugging-with-dwarf?

@RReverser
Copy link
Collaborator

I'm trying to debug my c++ application usind Dwarf on Chrome Version 89.0.4389.47 (Official Build) beta (64-bit)

Actually, this is probably the reason - as the instructions say, you need Chrome Canary at the moment. I don't think we're in Beta yet.

@pfaffe
Copy link
Collaborator

pfaffe commented Feb 12, 2021

Beta channel should be fine! Did you make sure to enable the DWARF Debugging experiment in DevTools? (Gear icon > Experiments)

@amarav
Copy link
Author

amarav commented Feb 15, 2021

@pfaffe You're right! Missed to enable Dwarf support in DevTools.
Although the source files i built as library are listed, I cant see the cpp files i compiled using emcc like main.cpp. It gives the error

Could not load content for wasm://wasm/main.cpp (HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME)

I'm unable to see the contents of the source files now.
And Im using Chrome Canary as suggested, Facing the same issue in beta as well

Any inputs to resolve this?

@amarav
Copy link
Author

amarav commented Feb 15, 2021

err

I need to debug into main.cpp, rc_platform_fio.cpp etc but couldnt see the contents and got the error

@pfaffe
Copy link
Collaborator

pfaffe commented Feb 15, 2021

You're hitting a corner case that we assumed would be quite rare in the wild. We have special treatment for when source files have relative paths in the debug symbols. In that case, we treat the paths as relative to the base URL.

In your case, that base URL is a wasm:// origin, which are fake URLs assigned by the engine when modules are created from a buffer instead of through the streaming APIs. We generally discourage using the ArrayBuffer APIs for performance reasons.

Besides switching to streaming APIs, here's how you get out of that situation. The web.dev blog post briefly talks about remapping source file paths. Path substitutions match prefixes of your source file paths and replace it. For example, you could replace . with file:///c:/foo/bar to define a new base for relative paths.

@amarav
Copy link
Author

amarav commented Feb 15, 2021

May I know Where i could do this Path substitution? Is it in devTools? In my case i need to substitute wasm://wasm/ with file:///C: is it?

@pfaffe
Copy link
Collaborator

pfaffe commented Feb 15, 2021

The setting is in the extension's options page. You navigate to chrome://extensions, click the extension's Details button, and then the Extension options link near the bottom of the page.

@amarav
Copy link
Author

amarav commented Feb 15, 2021

Thanks @pfaffe but doesnt work yet
err

@pfaffe
Copy link
Collaborator

pfaffe commented Feb 15, 2021

The left-hand side should just read .

The substitutions are applied to the (relative) paths that are in the debug symbols, not to the complete URLs that are shown in DevTools. So what you want to do is to replace the . in ./main.cpp.

@amarav
Copy link
Author

amarav commented Feb 15, 2021

@pfaffe Thanks a ton! File contents load now.

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

4 participants