The Classroom Continuous Build Butler - Didit

Debugging with mdb

Even when running on Linux, it is possible to debug node memory issues using mdb, the illumos debugger: MDB and Linux.

  1. Generate a core dump of the node process using gcore.

  2. Install the Manta utilities. Even if they conflict with existing binaries, the commands can be run directly from /usr/lib/node_modules/manta/bin/.

  3. Copy the node binary and the core file into a debug directory.

  4. Per the installation instructions, export Manta environment vars.

    Upload node and core using mput:

    tar cz debug | mput ~~/stor/debug.tar.gz

  5. Follow the instructions to create and run mmdb.sh:

    ./mmdb.sh ~~/stor/debug.tar.gz

In mdb, use ::findjsobjects and ::jsprint to navigate and print objects:

  • Use ::findjsobjects to find one representative of every kind of object

  • Use abcd1234::findjsobjects | ::findjsobjects to find all objects like abcd1234

  • Use abcd1234::findjsobjects -r to find all objects with a reference to abcd1234

Inspect stack frames and functions using ::jsframe, ::v8print and other commands:

  • ::jsprint doesn’t say much about function objects; use ::v8print first on the function and then on the associated SharedFunctionInfo