CyberDWARF Debugging


To add CyberDWARF support to a build, pass -s CYBERDWARF=1 to emcc. This generates a .cd file containing type information for debugging and adds a debugging toolkit to the output JavaScript.


The CyberDWARF debugger is designed to be used from the JavaScript devtool console available in most modern browsers.

Heap Pretty Printer

This small example will show how to use CyberDWARF to visualize a simple struct.

#include <emscripten.h>
#include <stdio.h>
#include <string.h>

struct TinyStruct {
  short len;
  char * chars;

extern "C" {

int example() {
  TinyStruct example;
  example.chars = "Hello World";
  example.len = strlen(example.chars);

  printf("%p\n", &example);
  EM_ASM({ debugger });

  return 0;


int main(int argc, char *argv[]) {
  return 0;

Compile the code

em++ -O1 -s CYBERDWARF=1 example.cpp -o example.html -s EXPORTED_FUNCTIONS="['_example']"


After the page loads, open a JavaScript console.

> Module['cyberdwarf'].initialize_debugger()
Debugger ready
> Module['_example']()
> Module['cyberdwarf'].set_current_function("_example")
> JSON.stringify(Module['cyberdwarf'].decode_var_by_var_name(0x1078, "example", 10), null, "\t")
  "struct TinyStruct": {
    "short : len": 5,
    "char * : chars": 87



Called to load the CyberDWARF file for the script.


Sets the function to lookup variable type by name. Supports either C/mangled name or minified name from symbol file.

Module['cyberdwarf'].decode_var_by_var_name(address, name, depth)

Looks up the type given by variable name in the current function, then dumps a JSON formatted representation of that type at address up to depth (defaults to 1)

Module['cyberdwarf'].decode_var_by_type_name(address, type, depth)

Using the type given in type, then dumps a JSON formatted representation of that type at address up to depth (defaults to 1)