Skip to main content
In this hands-on tutorial, we’ll explore WebAssembly (WASM) debugging workflows using Emscripten and Chrome DevTools. You’ll learn how to compile a simple C function to WASM, step through raw instructions in the browser, and then enable source-level debugging with DWARF symbols for C/C++ projects.
The image shows a Chrome Web Store page for the "C/C++ DevTools Support (DWARF)" extension, with a 3.7-star rating and 8,000 users. There's a screenshot of a code editor interface below.

Basic Debugging Experience

We start with a minimal C library that calculates the factorial of a non-negative integer:
Add an HTML page with JS glue to invoke the WASM module:
Compile using Emscripten:
When you open the HTML in Chrome and inspect DevTools > Sources, you’ll find both the generated JavaScript and the raw WebAssembly (.wasm):
You can set breakpoints in JS, step into the WASM module, and inspect raw locals like var0. However, mapping these low-level variables back to your C source can be tedious.
Low-level WASM debugging displays raw opcodes (local.get, i32.mul, etc.) and generic local names. To see your original C/C++ code directly, you need DWARF debug symbols.

Source-Level Debugging with DWARF

For larger C++ projects—such as rendering a Julia set fractal with SDL2—inspecting raw assembly is cumbersome. A Julia set is generated by iterating a simple complex-numbers formula for each pixel. Here’s a concise renderer:

Compiling with Debug Info

  1. Install the C/C++ DevTools Support (DWARF) extension from the Chrome Web Store.
  2. Compile with SDL2 support and DWARF symbols:
Open the resulting HTML in Chrome (with the DWARF extension enabled). In DevTools > Sources, you’ll find a C/C++ tab where you can:
  • Set breakpoints in your original .cpp files
  • Step through high-level C++ code, not raw WASM opcodes
  • Inspect variables by name and type
This workflow turns WebAssembly debugging into a familiar, source-level experience.

Watch Video