python-wasm
python-wasm copied to clipboard
Debugging Emscripten builds
It's tricky to debug emscripten builds. By default emcc strips all debug symbols and even function names from WASM files. I got some promising results with debug builds, source map, and Chromium DevTools.
- Configure with
--with-pydebug - Extend
PY_LDFLAGS_NODISTvar with-gsource-map --source-map-base http://localhost:8000/builddir/host/ emmake make -j8 python.html- Run
python3 -m http.serverfrom thecpythonbase directory (not the directory wherepython.htmllives). - open http://localhost:8000/builddir/host/python.html
- Use Chromium with C/C++ DevTools Support (DWARF) support and WebAssembly Debugging: Enable DWARF support.

Source map does not require a debug build. A standard build of Python includes sufficient DWARF symbols to generate a source map:
$ emmake make python.html BUILDPYTHON= LDFLAGS="-gsource-map --source-map-base=http://localhost:8000/builddir/host/"