cpptrace icon indicating copy to clipboard operation
cpptrace copied to clipboard

Feature Request: Emscripten support

Open vittorioromeo opened this issue 1 year ago • 2 comments

Would be nice to get even (partial) support for Emscripten -- I currently only need cpptrace::generate_trace().print() in my project, and I have to #ifdef for Emscripten like this:

#ifdef SFML_SYSTEM_EMSCRIPTEN
    char callstack[4096];
    emscripten_get_callstack(EM_LOG_C_STACK, callstack, sizeof(callstack));
    std::puts(callstack);
#else
    cpptrace::generate_trace().print();
#endif

Would be nice if cpptrace handled this automatically :)

vittorioromeo avatar Sep 15 '24 22:09 vittorioromeo

I've started looking into adding support for this. The main issue would be parsing the result from emscripten_get_callstack and I don't have as much confidence in doing this as I'd like. It seems the format can differ depending on where the js/wasm is being ran. Do you have any advice?

jeremy-rifkin avatar Nov 10 '24 16:11 jeremy-rifkin

Unfortunately I do not have any experience with that, the only pointer I can provide is the function that generates the callstack in Emscripten: https://github.com/emscripten-core/emscripten/blob/e6ed9d3fc2821a72cc8ded4a02cac72b9f306f88/src/library_stack_trace.js#L12-L97

It seems it already does some normalization between browsers

vittorioromeo avatar Nov 11 '24 12:11 vittorioromeo