包详细信息

v8-debug

v8 debugger extending API

v8, debugger

自述文件

Build Status Build status npm version

v8-debug

Provides extending API for node internal debugger protocol (based on v8 debugger protocol)

This is a part of node-inspector.

Installation

npm install v8-debug

API

registerCommand(name, callback)

Registers new debug processor command, like lookup.

callback accepts two arguments - request and response.

You need to modify response.body if you want to return something to caller.

debug.registerCommand('_lookup', function(request, response) {
  var test = request.attributes;
  //do someting here
  //and modify response
  response.body = {
    test: test
  };
});

registerEvent(eventName)

This is a shortcut for:

debug.registerCommand('someEvent', debug.commandToEvent);

execCommand(commandName, attributes)

Calls debug processor command like 'lookup'.

attributes will be passed to registerCommand.callback as request.attributes.

attributes needs to be valid JSON object.

debug.registerCommand('_lookup', function(request, response) {
  var test = request.attributes;
  //do someting here
  //and modify response
  response.body = {
    test: test
  };
});

debug.execCommand('_lookup', { attr: 'test' });

emitEvent(eventName, attributes)

This is a semantic alias for execCommand

debug.emitEvent('myEvent', { attr: 'test' });

commandToEvent(request, response)

response object has a different structure for commands and events.

By default registerCommand.callback receives command's response.

This is a small converter.

debug.registerCommand('someEvent1', function(request, response) {
  debug.commandToEvent(request, response);
});

debug.registerCommand('someEvent2', debug.commandToEvent);

Use debug.registerEvent instead of this.

runInDebugContext(script)

(alias get)

Evaluates string or function (will be stringifyed) in debug context.

var MakeMirror = debug.get('MakeMirror');
var mirror = MakeMirror({ test: 1 });

getFromFrame(index, value)

Tries to receive a value from targeted frame scopes

function a(options) {
  //...
  b();
}

function b() {
  // There is no info about `options` object
  var options = debug.getFromFrame(1, 'options');
}

enableWebkitProtocol()

Enables experimental usage of WebKit protocol

registerAgentCommand(command, parameters, callback)

Experimental method for registering WebKit protocol handlers

Usage

Simple console.log checking

var debug = require('v8-debug');

debug.registerEvent('console.log');

console.log = (function(fn) {
  return function() {
    debug.emitEvent('console.log', {message: arguments[0]} /*, userdata*/);
    return fn.apply(console, arguments);
  }
} (console.log));

For more experience see protocol documentation

更新日志

2017-03-28, Version 1.0.1

  • fix: fix the deprecated warnings (#40) (淘小杰)

2017-03-23, Version 1.0.0

  • feat: config node7 on appveyor (#39) (淘小杰)

  • fix: make it work on node7.x (#38) (淘小杰)

  • Update release script (Yury Puzynya)

2016-05-10, Version 0.7.7

  • Return node 4 x86 build (Yury Puzynya)

2016-05-08, Version 0.7.6

2016-05-08, Version 0.7.5

2016-04-28, Version 0.7.4

  • fix publishing (Yury Puzynya)

2016-04-28, Version 0.7.3

  • Update nan (Yury Puzynya)

  • Exclude 4.0.0-win32-ia32 from prebuilts (Yury Puzynya)

2016-03-12, Version 0.7.2

  • New release script (Yury Puzynya)

2016-01-26, Version 0.7.1

  • Fix prepublish script (Yury Puzynya)

  • Fix #21: this.extendedProcessDebugJSONRequest_ is not a function (Shawn Van Ittersum)

  • Update build script (Yury Puzynya)

  • Update prepublish (Yury Puzynya)

2015-12-06, Version 0.7.0

  • Add prepublish script (Yury Puzynya)

  • Add .npmignore (Yury Puzynya)

  • Update .gitignore (Yury Puzynya)

2015-12-06, Version 0.6.2

  • Update build scripts (Yury Puzynya)

2015-11-29, Version 0.6.1

  • Build configuration updated (Yury Puzynya)

2015-10-22, Version 0.6.0

  • Code prepared for NODE_NEXT logic (Yury Puzynya)

  • InjectedScriptSource updated (Yury Puzynya)

  • Added InjectedScriptHost.cc (Yury Puzynya)

  • Fixed preinstall script (Yury Puzynya)

2015-09-17, Version 0.5.4

2015-09-13, Version 0.5.3

  • Update travis build (Yury Puzynya)

  • Fix src for node v4 (Yury Puzynya)

  • Updated cloud build (Yury Puzynya)

2015-08-09, Version 0.5.2

  • Version changed to 0.5.2 (3y3)

  • Fix error rethrowing (3y3)

2015-08-09, Version 0.5.1

  • Version changed to 0.5.1 (3y3)

  • Update cloud build (3y3)

  • Fix build for iojs-3 (3y3)

  • Readme.md updated (3y3)

2015-07-23, Version 0.5.0

  • Version changed to 0.5.0 (3y3)

  • Readme.md updated (3y3)

  • Added getFromFrame func (3y3)

2015-05-19, Version 0.4.6

  • Version changed to 0.4.6 (3y3)

  • Enable win_delay_load_hook for 1.* (3y3)

2015-05-19, Version 0.4.5

  • Version changed to 0.4.5 (3y3)

  • Cleanup CI configs (3y3)

2015-05-09, Version 0.4.4

  • Version changed to 0.4.4 (3y3)

  • Update CI settings (3y3)

  • Unbundle node-pre-gyp (3y3)

  • Update TravisCI badge (3y3)

2015-05-01, Version 0.4.3

  • Version changed to 0.4.3 (3y3)

  • Update dependencies (3y3)

  • Added npm version badge (3y3)

2015-02-22, Version 0.4.2

  • Version changed to 0.4.2 (3y3)

  • Webkit API refactoring (3y3)

  • Allocate Debug Context for 0.12+ (3y3)

2015-02-19, Version 0.4.1

  • Version changed to 0.4.1 (3y3)

  • Fixes for 0.10.36 (3y3)

  • Bump node-pre-gyp to ^0.6.4 for iojs (Jim Cummins)

2015-02-15, Version 0.4.0

  • Version changed to 0.4.0 (3y3)

  • Temporary fix for io.js testing (3y3)

  • Fix for 0.12 and io.js (3y3)

  • Update build matrix (3y3)

2015-02-08, Version 0.3.5

  • Version changed to 0.3.5 (3y3)

  • Skip failing test for build (3y3)

  • Add v0.12 to build matrix (3y3)

  • Rename Signal to SendCommand (3y3)

  • Upgrade npm dependencies, notably nan to 1.6.2 (James Ide)

  • Suppress compile warnings (3y3)

  • Added AppVeyor badge (3y3)

  • Update build matrix (3y3)

  • Fix errors and warning when compiling with iojs (Leo Koppelkamm)

2015-01-25, Version 0.3.4

  • Version changed to 0.3.4 (3y3)

  • Use seq = 0 by default instead of 1 (3y3)

  • Fix Linux compatibility (3y3)

  • Update nan to 1.5.0 (3y3)

  • Fix tests race condition (3y3)

  • Fix paths for injected usage (3y3)

  • Added test for registerAgentCommand (3y3)

  • Added Webkit protocol support (3y3)

  • Node-pre-gyp updated to ^0.6.0 (3y3)

  • allow_natives_syntax flag moved to allowNatives method (3y3)

  • Depreceted undocumented method mirror (3y3)

2015-01-10, Version 0.3.3

  • Version changed to 0.3.3 (3y3)

2015-01-09, Version 0.3.2

  • Version changed to 0.3.2 (3y3)

  • Finish prebuild binaries (3y3)

  • Linux/OSX prebuild binaries (3y3)

  • Added registerAsync command (3y3)

  • Convert line endings to LF (3y3)

2014-12-07, Version 0.3.1

  • Windows prebuild binaries (3y3)

2014-11-27, Version 0.3.0

  • Version changed to 0.3.0 (3y3)

  • Update readme.md (Moshe Kolodny)

  • Readme updated (3y3)

  • API updated (3y3)

2014-10-02, Version 0.2.0

  • Version changed to 0.2.0 (3y3)

  • Allow natives syntax flag enabled (3y3)

  • Ignore v8 protocol serializer for custom commands (3y3)

  • v8-debug.js refactored (3y3)

  • Added runInDebugContext function (3y3)

  • Fixed newline in readme.md (3y3)

2014-09-28, Version 0.1.5

  • Version changed to 0.1.5 (3y3)

  • Fix compatibility with 0.10.x (3y3)

2014-09-28, Version 0.1.4

  • Version changed to 0.1.4 (3y3)

  • Fast fix for Node v0.11.14 (3y3)

  • Move DebugCommandProcessor to closure (3y3)

  • Added mirror API (3y3)

2014-06-29, Version 0.1.3

  • Version changed to 0.1.3 (3y3)

  • Remove 'v8-debug' from cache after disconnect (3y3)

  • Safely handling errors (3y3)

2014-06-26, Version 0.1.2

  • First release!