Getting C++ mangled names in stack trace to add to EXPORTED_FUNCTIONS

34 views
Skip to first unread message

Rohit Saini

unread,
Jan 31, 2020, 11:24:01 AM1/31/20
to emscripten-discuss
Hi All,

Previously we were using emscripten 1.38.28 version, and when we were making debug build with --profiling --profiling-func, the stack trace we were getting on exception was with mangled c++ names.
But now as we are updating to emscripten 1.39.6 , the stack trace we are getting has c++ function names in demangled forms. I need mangled C++ names to add to EXPORTED_FUNCTIONS and EXCEPTION_CATCHING_WHITELIST Is there any way to get mangled C++ names in stack trace or better if I can get a list of mangled names of all the functions.

I tried DEMANGLE_SUPPORT=0 but still not getting mangled c++ names.
I also tried --emit-symbol-map but map I am getting has only some functions with mangled C++ names, all other are in the unmangled form.

Regards,






Alon Zakai

unread,
Jan 31, 2020, 6:58:45 PM1/31/20
to emscripte...@googlegroups.com
I think this is because 1.39.0 changed the backend to upstream, and the upstream backend uses human-readable names in the wasm names section, so they show up in stack traces.

I'm not aware of a good way to work around this, I'm afraid. I've complained about it but there seems no consensus on changing it, as overall human-readable names in stack traces are generally what users want.

Sorry about this, I know it's annoying. Some things you can do:

* Inspect the relevant .o file, as the names are demangled during the link stage, so if you know the object file, the name will be in there. Use wasm-objdump -d for this as other disassemblers may not work.


We should perhaps look into creating a tool like the reverse of c++filt to mangle names easily. However, after 10 minutes of searching I can't find a good codebase for that (e.g. LLVM's is internal and would be hard to extract, and I can't find any standalone ones).


--
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/d340ff0d-2770-4f01-b3bf-b0525af7a9d7%40googlegroups.com.

Rohit Saini

unread,
Feb 3, 2020, 7:05:58 AM2/3/20
to emscripten-discuss
Thanks Alon,

Disassembling .o files worked for me. Fortunately mangled names haven't been changed with transition from 1.38.28 to 1.39.6.

Regards,
Reply all
Reply to author
Forward
0 new messages