Setting breakpoints using debug version(DWARF)

289 views
Skip to first unread message

Brian Gavin

unread,
Jan 8, 2021, 10:22:05 AM1/8/21
to emscripten-discuss
Hello,
I am excited to see the new ability to set breakpoints and view variables in Chrome.   

When I do a simple project with about 5 source files it works fairly well, but when I try to debug my large project with 100s of files.   I am unable to set breakpoints in the callback functions such as mouse events and our callback function that draws to the screen at 60 fps( emscripten_set_main_loop_arg ).   Is there a linker/compiler setting that helps this.   I am using -g -O0 -fno-inline as flags for debugging.   I am using emscripten SDK 2.0.11 with Chrome Canary.

Thanks,
Brian Gavin

Philip Pfaffe

unread,
Jan 11, 2021, 9:57:38 AM1/11/21
to emscripten-discuss
Hi Brian!

By unable do you mean that all the line numbers in the sources panel are grayed out? But you can see all source files? Are you using those flags both for compiling and linking?

Cheers,
Philip

Brian Gavin

unread,
Jan 12, 2021, 2:03:37 PM1/12/21
to emscripten-discuss
yes, all of the line numbers are grayed out, but I can see all of my source files.   I am using -g for linking and compiling -O0 only when linking.   I can set breakpoints in my main() function and any code in other files called by the main() function.

My code has a file main.cpp that holds int main()  if I hack my code and a callback function for an event or my main loop callback I can set breakpoints for code in main.cpp but as soon as my code calls code outside of main.cpp.   I can not set breakpoints in the code.

pseudo code

void MainLoopCB(void* data)
{
     // If this function is not in main.cpp breakpoints will not work
     ClassInOtherFile();
}

int main()
{
     // Breakpoints work here and variables can be inspected
     int i=0;
     int sum=0;
     for(i=0;i<20;i++)
     {
           sum++;
     }
       emscripten_set_main_loop_arg(MainLoopCB,0,nullptr,true);

      return 0;

Philip Pfaffe

unread,
Jan 14, 2021, 8:20:32 AM1/14/21
to emscripten-discuss
Thanks for the infos! I tried to reproduce it with your pseudo code but had no luck. I can see breakable lines in the MainLoopCB file. Would you mind filing a bug at crbug.com against the Platform>DevTools>WebAssembly component?

If possible, please include a minimal self-contained reproducer, such as the two required sources and something like a makefile to build.  You might also attach a binary if that's not too big!

chunyi song

unread,
Mar 1, 2021, 10:11:06 PM3/1/21
to emscripten-discuss
I also encountered the same problem when I debug a qt5 app with dwarf in chrome devtools. I can see all the c++ source files in devtool, but some source code line can not set breakpoints and some line can set bp in the same file, which are all grayed out.

Brian Gavin

unread,
Mar 30, 2021, 9:25:06 AM3/30/21
to emscripten-discuss
Breakpoints are working much better with recent changes.   Still unable to see variable values in many cases and crashing, but nice improvements.  :)

Philip Pfaffe

unread,
Mar 30, 2021, 9:32:32 AM3/30/21
to emscripten-discuss
Hi Brian,

great to hear that things improved!
I'd still like to get to the bottom of your remaining issues. What kind of crashes are you getting? Page/Renderer crashes or DevTools crashes? It would be great if you could share a reproducer, then I can debug what's going on!

Cheers,
Philip

Brian Gavin

unread,
Mar 30, 2021, 1:55:35 PM3/30/21
to emscripten-discuss
DevTool crashes.   Unfortunately I do not have a simple example with repro steps.   

Sorry,
Brian Gavin

Brian Gavin

unread,
Mar 30, 2021, 2:48:23 PM3/30/21
to emscripten-discuss
I also noticed adding -fno-inline to compiler options made things worse for setting breakpoints.

Philip Pfaffe

unread,
Mar 31, 2021, 10:06:12 AM3/31/21
to emscripte...@googlegroups.com
How does the DevTools crash look like? Do you get a "DevTools disconnected from the page" error or anything on the terminal? What Chrome version are you on currently?

It would be great if you could share steps to reproduce, as so far I've not managed to myself.

Cheers,
Philip

--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/070198b1-d464-4dac-a323-af54964d67aan%40googlegroups.com.


--

Philip Pfaffe

Software Engineer

pfa...@google.com


Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls Sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. 

     

This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.


Brian Gavin

unread,
Apr 2, 2021, 9:00:59 AM4/2/21
to emscripten-discuss
I am running the latest version of chrome canary  91.0.4464.5  64bit MS Windows .   The crashing is pretty random.    You can set a breakpoint on a line and it might work and then you run some more and it crashes.   Yes I get a DevTools disconneted error and the web page crashes..

Brian Gavin

unread,
May 13, 2021, 4:31:14 PM5/13/21
to emscripten-discuss
The crashing of DevTools when using Chrome Canary has gone away for me.   It used crash all the time which made it unusable.   Nice work to everyone creating this tool.  

The only issue I still see is inspecting local scope variables does not always work and will sometimes report undefined.

Brian Gavin

Reply all
Reply to author
Forward
0 new messages