There are some logging and callstack methods in the C API,
http://kripken.github.io/emscripten-site/docs/api_reference/emscripten.h.html?#c.emscripten_log

On Tue, Nov 3, 2015 at 11:14 AM, Robert Goulet <[email protected]>
wrote:

> 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.
>
> On Tuesday, November 3, 2015 at 12:51:24 PM UTC-5, Alon Zakai wrote:
>>
>> 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?
>>
>> On Tue, Nov 3, 2015 at 9:41 AM, Robert Goulet <[email protected]>
>> wrote:
>>
>>> 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.
>>>
>>> On Tuesday, November 3, 2015 at 12:37:49 PM UTC-5, Alon Zakai wrote:
>>>>
>>>> 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 <[email protected]>
>>>> 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 <[email protected]>
>>>>>> 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 <
>>>>>>> [email protected]> 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 <
>>>>>>>>> [email protected]> 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 [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.
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> 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.
>>>>>
>>>>
>>>> --
>>> 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.
>

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