python-wasm icon indicating copy to clipboard operation
python-wasm copied to clipboard

Debugging Emscripten builds

Open tiran opened this issue 3 years ago • 1 comments

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_NODIST var with -gsource-map --source-map-base http://localhost:8000/builddir/host/
  • emmake make -j8 python.html
  • Run python3 -m http.server from the cpython base directory (not the directory where python.html lives).
  • open http://localhost:8000/builddir/host/python.html
  • Use Chromium with C/C++ DevTools Support (DWARF) support and WebAssembly Debugging: Enable DWARF support.

Screenshot_20220105_171125

tiran avatar Jan 05 '22 16:01 tiran

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

tiran avatar Jan 05 '22 22:01 tiran