Ok, I got it working (somewhat) with a cmake project.

First problem I had was an oversight, I didn't pass -g4 to the linker stage 
too.

After that one can look into the .wasm.map files that have been created, 
and confirm that the source file paths are in there.

Then run the program in Chrome, open the devtool, go to the source panel 
*and hit refresh*. After that a tree-item is listed next to the .html and 
.js file, opening this shows all the sources.

But clicking on those source files only results in an empty tab, no source 
files are actually loaded. Looking at the webserver log reveals that the 
browsers tries to load those source files via HTTP, which doesn't work, 
because the source files are somewhere else in the filesystem.

That's where the Filesystem tab in the devtools come in, adding the 'lowest 
common parent directory' under which all sources are located seems to work, 
Chrome seems to properly map the absolute source paths from the .wasm.map 
files.

Now loading the source and breakpoints work, but the actual debugging 
experience isn't much better then what I remember from a few years ago. 
Even for minimal programs like my sokol-samples stepping through the code 
is very 'laggy', the laptop is running hot and goes into jet-mode for some 
reason, sometimes I need to 'step' ten times on a single line of code until 
progressing to the next line, sometimes I'm ending up in a completely wrong 
location when stepping into a new source file, and local variable names are 
not mapped to their C/C++ names (they only show up as "arg#0, local#1, 
local#2...".

Compared to a "native" debugging experience this isn't much to write home 
about unfortunately ;)

On Thursday, 4 April 2019 00:43:12 UTC+2, Floh wrote:
>
> Hmm, indeed. It works immediately when the source files are in the same 
> directory as the build result. It even automatically lists the .c file...
>
> I can't get it to work with "out-of-source builds" yet. I figured out that 
> I need to tell Chrome the source code directory via "Filesystem -> Add to 
> workspace...",
> and then I can open the source files with Ctrl-P, but it doesn't recognize 
> the breakpoints (I can set them, but they're not hit).
>
> I'll do some more experiments. Maybe the source file isn't properly 
> matched with the 'reference' from the WASM file.
>
> Cheers!
>
> On Wednesday, 3 April 2019 22:51:35 UTC+2, Alon Zakai wrote:
>>
>> The Ctrl+P stuff is new, but it should work. For example,
>>
>> ./emcc tests/hello_world.c -g4 -o a.html
>> python -m SimpleHTTPServer
>> browse to localhost:8000/a.html in chrome
>> go to sources, ctrl-p, pick hello_world.c
>>
>> Then it shows up, breakpoints work, etc.
>>
>>
>> On Sat, Mar 30, 2019 at 10:38 PM <[email protected]> wrote:
>>
>>> Also, sorry, I should clarify, I have set the compiler options as 
>>> instructed on that page, in Chrome I get errors, but no C++ source code.  
>>> In the sources tree, no C++ files appear.  There's a message: "Source map 
>>> detected.  Associated files should be added to the file tree.  You can 
>>> debug these resolved source files as regular JavaScript files.  Associated 
>>> files are available via file tree or Ctrl + P"
>>>
>>> Ctrl + P doesn't bring up any C++ files, I'm not sure what to do.
>>>
>>> Thanks so much
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to