Debugging in-browser?

343 views
Skip to first unread message

Robert Goulet

unread,
Oct 21, 2015, 2:02:01 PM10/21/15
to emscripten-discuss
Hi all,

I'm trying to setup debugging in-browser, but it doesn't work for me, and I am wondering if it's just related to the size of my project? Does anyone successfully used breakpoints in code built with -g4 in Firefox Nightly? Everytime I add a breakpoint, it just freeze Firefox and I have to kill it. Please share your experience and tips. Thanks!

Alon Zakai

unread,
Oct 21, 2015, 3:58:55 PM10/21/15
to emscripten-discuss
In my experience very large projects are indeed hard to get running in browser debuggers. They just haven't been optimized for that size code yet, I think.

I do most of my debugging using dump(), which writes to stdout in the console firefox was started from. (You need to set browser.dom.window.dump.enabled in about:config for that to work.) Or alert() when I want things to be paused. Or just console.log() when the amount of output is small.

On Wed, Oct 21, 2015 at 11:02 AM, Robert Goulet <robert...@autodesk.com> wrote:
Hi all,

I'm trying to setup debugging in-browser, but it doesn't work for me, and I am wondering if it's just related to the size of my project? Does anyone successfully used breakpoints in code built with -g4 in Firefox Nightly? Everytime I add a breakpoint, it just freeze Firefox and I have to kill it. Please share your experience and tips. Thanks!

--
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.
For more options, visit https://groups.google.com/d/optout.

Robert Goulet

unread,
Oct 21, 2015, 4:48:14 PM10/21/15
to emscripten-discuss
Is there any easier way to trace down code, even without checked variables content, just to see the callstack?
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Brion Vibber

unread,
Oct 21, 2015, 4:52:32 PM10/21/15
to emscripten Mailing List
You should be able to get a call stack by throwing a JS exception; if using sufficient debug or profiling options in your build you should get useful function names out of that, which is a huge help even if the full debugger is not attached.

Should be pretty easy to attach a JS library function to do that.

-- brion

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

Alon Zakai

unread,
Oct 21, 2015, 4:58:29 PM10/21/15
to emscripten-discuss
Yeah, emscripten has jsStackTrace() which returns the JS stack, and stackTrace() which does the same with c++ names demangled.

Robert Goulet

unread,
Nov 3, 2015, 10:45:43 AM11/3/15
to emscripten-discuss
I tried calling stackTrace and it didn't work. Is there special build flags we need to pass to enable it?

Here is what I tried:

EM_ASM(
    console.log('Callstack:' + stackTrace());
);

When I call C++ printf I see stuff in the console. But using JS console.log never prints anything. Why?


On Wednesday, October 21, 2015 at 4:58:29 PM UTC-4, Alon Zakai wrote:
Yeah, emscripten has jsStackTrace() which returns the JS stack, and stackTrace() which does the same with c++ names demangled.
On Wed, Oct 21, 2015 at 1:52 PM, Brion Vibber <br...@pobox.com> wrote:
You should be able to get a call stack by throwing a JS exception; if using sufficient debug or profiling options in your build you should get useful function names out of that, which is a huge help even if the full debugger is not attached.

Should be pretty easy to attach a JS library function to do that.

-- brion
On Wed, Oct 21, 2015 at 1:48 PM, Robert Goulet <robert...@autodesk.com> wrote:
Is there any easier way to trace down code, even without checked variables content, just to see the callstack?

On Wednesday, October 21, 2015 at 3:58:55 PM UTC-4, Alon Zakai wrote:
In my experience very large projects are indeed hard to get running in browser debuggers. They just haven't been optimized for that size code yet, I think.

I do most of my debugging using dump(), which writes to stdout in the console firefox was started from. (You need to set browser.dom.window.dump.enabled in about:config for that to work.) Or alert() when I want things to be paused. Or just console.log() when the amount of output is small.
On Wed, Oct 21, 2015 at 11:02 AM, Robert Goulet <robert...@autodesk.com> wrote:
Hi all,

I'm trying to setup debugging in-browser, but it doesn't work for me, and I am wondering if it's just related to the size of my project? Does anyone successfully used breakpoints in code built with -g4 in Firefox Nightly? Everytime I add a breakpoint, it just freeze Firefox and I have to kill it. Please share your experience and tips. Thanks!

--
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-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

Robert Goulet

unread,
Nov 3, 2015, 11:24:41 AM11/3/15
to emscripten-discuss
Actually, I tried with Module.stackTrace() and that didn't work either.

Robert Goulet

unread,
Nov 3, 2015, 11:26:11 AM11/3/15
to emscripten-discuss
This worked :

printf("Callstack:\n%s", emscripten_run_script_string("Module.stackTrace();"));

Why do I have to print in console using a C++ printf? I was never able to get something to print in the console using EM_ASM or emscripten_run_script.

Alon Zakai

unread,
Nov 3, 2015, 12:37:49 PM11/3/15
to emscripten-discuss
Do you get an error? That  works for me. For example, this prints out a stack trace:

#include <emscripten.h>
int main() {

  EM_ASM(
    console.log('Callstack:' + stackTrace());
  );
}

Are you looking in the stdout area on the page, or the browser's web console? Also, the web console has options to disable logging showing up, you might have those disabled?

On Tue, Nov 3, 2015 at 7:45 AM, Robert Goulet <robert...@autodesk.com> wrote:
I tried calling stackTrace and it didn't work. Is there special build flags we need to pass to enable it?

Here is what I tried:

EM_ASM(
    console.log('Callstack:' + stackTrace());
);

When I call C++ printf I see stuff in the console. But using JS console.log never prints anything. Why?


On Wednesday, October 21, 2015 at 4:58:29 PM UTC-4, Alon Zakai wrote:
Yeah, emscripten has jsStackTrace() which returns the JS stack, and stackTrace() which does the same with c++ names demangled.
On Wed, Oct 21, 2015 at 1:52 PM, Brion Vibber <br...@pobox.com> wrote:
You should be able to get a call stack by throwing a JS exception; if using sufficient debug or profiling options in your build you should get useful function names out of that, which is a huge help even if the full debugger is not attached.

Should be pretty easy to attach a JS library function to do that.

-- brion
On Wed, Oct 21, 2015 at 1:48 PM, Robert Goulet <robert...@autodesk.com> wrote:
Is there any easier way to trace down code, even without checked variables content, just to see the callstack?

On Wednesday, October 21, 2015 at 3:58:55 PM UTC-4, Alon Zakai wrote:
In my experience very large projects are indeed hard to get running in browser debuggers. They just haven't been optimized for that size code yet, I think.

I do most of my debugging using dump(), which writes to stdout in the console firefox was started from. (You need to set browser.dom.window.dump.enabled in about:config for that to work.) Or alert() when I want things to be paused. Or just console.log() when the amount of output is small.
On Wed, Oct 21, 2015 at 11:02 AM, Robert Goulet <robert...@autodesk.com> wrote:
Hi all,

I'm trying to setup debugging in-browser, but it doesn't work for me, and I am wondering if it's just related to the size of my project? Does anyone successfully used breakpoints in code built with -g4 in Firefox Nightly? Everytime I add a breakpoint, it just freeze Firefox and I have to kill it. Please share your experience and tips. Thanks!

--
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.

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 emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

Robert Goulet

unread,
Nov 3, 2015, 12:41:29 PM11/3/15
to emscripten-discuss
No error reported. I am looking at the browser's web console, not the stdout text area on the page. I did not disable any web console logging, and also I'm guessing it wouldn't print anything if it was disabled? it does appear when I use C++ printf.

This is a build done with -O3, no debugging information, if that matters.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Nov 3, 2015, 12:51:24 PM11/3/15
to emscripten-discuss
Does just doing console.log('hello world') work when you directly write that in the web console?

If that works, you can debug this by finding your console.log in the emscripten output. Perhaps put an alert() right before it. Maybe somehow control flow isn't getting there?

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

Robert Goulet

unread,
Nov 3, 2015, 2:14:54 PM11/3/15
to emscripten-discuss
Indeed it works elsewhere in the code. But it still doesn't work at the other location, and basically the only difference is that it is closer to exit(1) call. Perhaps the code to print to the console can't be executed when its too close to the exit function? I really don't know why, but whatever.

Is there a cleaner way to retrieve the callstack as char* from emscripten other than using emscripten_run_script_string("Module.stackTrace();") ? When I do that, the call to emscripten_run_script_string and stackTrace is added to the callstack, and preferably I would want only the callstack from the location where I ask for it. If its not possible then its not a huge problem.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Nov 3, 2015, 2:38:30 PM11/3/15
to emscripten-discuss

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

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 emscripten-disc...@googlegroups.com.

Robert Goulet

unread,
Nov 3, 2015, 3:37:32 PM11/3/15
to emscripten-discuss
Awesome! This is exactly what I needed: emscripten_get_callstack

It works perfectly.

Thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.

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 emscripten-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages