const kNoFrame = -1;
Debug.State = {
currentFrame: kNoFrame,
- displaySourceStartLine: -1,
- displaySourceEndLine: -1,
currentSourceLine: -1
}
var trace_compile = false; // Tracing all compile events?
-var trace_debug_json = false; // Tracing all debug json packets?
-var last_cmd_line = '';
-var repeat_cmd_line = '';
-var is_running = true;
-
-// Copied from debug-delay.js. This is needed below:
-function ScriptTypeFlag(type) {
- return (1 << type);
-}
// Process a debugger JSON message into a display text and a running status.
// This function returns an object with properties "text" and "running" holding
// this information.
function DebugMessageDetails(message) {
- if (trace_debug_json) {
- print("received: '" + message + "'");
- }
// Convert the JSON string to an object.
var response = new ProtocolPackage(message);
- is_running = response.running();
if (response.type() == 'event') {
return DebugEventDetails(response);
result += '\n';
result += SourceUnderline(body.sourceLineText, body.sourceColumn);
Debug.State.currentSourceLine = body.sourceLine;
- Debug.State.displaySourceStartLine = -1;
- Debug.State.displaySourceEndLine = -1;
Debug.State.currentFrame = 0;
details.text = result;
break;
result += '\n';
result += SourceUnderline(body.sourceLineText, body.sourceColumn);
Debug.State.currentSourceLine = body.sourceLine;
- Debug.State.displaySourceStartLine = -1;
- Debug.State.displaySourceEndLine = -1;
Debug.State.currentFrame = 0;
} else {
result += ' (empty stack)';
Debug.State.currentSourceLine = -1;
- Debug.State.displaySourceStartLine = -1;
- Debug.State.displaySourceEndLine = -1;
Debug.State.currentFrame = kNoFrame;
}
details.text = result;
details.text = result;
break;
- case 'scriptCollected':
- details.text = result;
- break;
-
default:
details.text = 'Unknown debug event ' + response.event();
}
// Converts a text command to a JSON request.
function DebugCommandToJSONRequest(cmd_line) {
- var result = new DebugRequest(cmd_line).JSONRequest();
- if (trace_debug_json && result) {
- print("sending: '" + result + "'");
- }
- return result;
+ return new DebugRequest(cmd_line).JSONRequest();
};
return;
}
- // Check for a simple carriage return to repeat the last command:
- var is_repeating = false;
- if (cmd_line == '\n') {
- if (is_running) {
- cmd_line = 'break'; // Not in debugger mode, break with a frame request.
- } else {
- cmd_line = repeat_cmd_line; // use command to repeat.
- is_repeating = true;
- }
- }
- if (!is_running) { // Only save the command if in debugger mode.
- repeat_cmd_line = cmd_line; // save last command.
- }
-
// Trim string for leading and trailing whitespace.
cmd_line = cmd_line.replace(/^\s+|\s+$/g, '');
args = cmd_line.slice(pos).replace(/^\s+|\s+$/g, '');
}
- if ((cmd === undefined) || !cmd) {
- this.request_ = void 0;
- return;
- }
-
- last_cmd = cmd;
-
// Switch on command.
switch (cmd) {
case 'continue':
case 'step':
case 's':
- this.request_ = this.stepCommandToJSONRequest_(args, 'in');
- break;
-
- case 'stepi':
- case 'si':
- this.request_ = this.stepCommandToJSONRequest_(args, 'min');
- break;
-
- case 'next':
- case 'n':
- this.request_ = this.stepCommandToJSONRequest_(args, 'next');
- break;
-
- case 'finish':
- case 'fin':
- this.request_ = this.stepCommandToJSONRequest_(args, 'out');
+ this.request_ = this.stepCommandToJSONRequest_(args);
break;
case 'backtrace':
this.request_ = this.scopeCommandToJSONRequest_(args);
break;
- case 'disconnect':
- case 'exit':
- case 'quit':
- this.request_ = this.disconnectCommandToJSONRequest_(args);
- break;
-
- case 'up':
- this.request_ =
- this.frameCommandToJSONRequest_('' +
- (Debug.State.currentFrame + 1));
- break;
-
- case 'down':
- case 'do':
- this.request_ =
- this.frameCommandToJSONRequest_('' +
- (Debug.State.currentFrame - 1));
- break;
-
- case 'set':
case 'print':
case 'p':
this.request_ = this.printCommandToJSONRequest_(args);
this.request_ = this.instancesCommandToJSONRequest_(args);
break;
- case 'list':
- case 'l':
- this.request_ = this.listCommandToJSONRequest_(args);
- break;
case 'source':
this.request_ = this.sourceCommandToJSONRequest_(args);
break;
case 'scripts':
- case 'script':
- case 'scr':
this.request_ = this.scriptsCommandToJSONRequest_(args);
break;
break;
case 'clear':
- case 'delete':
- case 'd':
this.request_ = this.clearCommandToJSONRequest_(args);
break;
this.request_ = this.threadsCommandToJSONRequest_(args);
break;
- case 'cond':
- this.request_ = this.changeBreakpointCommandToJSONRequest_(args, 'cond');
- break;
-
- case 'enable':
- case 'en':
- this.request_ =
- this.changeBreakpointCommandToJSONRequest_(args, 'enable');
- break;
-
- case 'disable':
- case 'dis':
- this.request_ =
- this.changeBreakpointCommandToJSONRequest_(args, 'disable');
- break;
-
- case 'ignore':
- this.request_ =
- this.changeBreakpointCommandToJSONRequest_(args, 'ignore');
- break;
-
- case 'info':
- case 'inf':
- this.request_ = this.infoCommandToJSONRequest_(args);
- break;
-
- case 'flags':
- this.request_ = this.v8FlagsToJSONRequest_(args);
- break;
-
- case 'gc':
- this.request_ = this.gcToJSONRequest_(args);
- break;
-
case 'trace':
- case 'tr':
// Return undefined to indicate command handled internally (no JSON).
this.request_ = void 0;
this.traceCommand_(args);
default:
throw new Error('Unknown command "' + cmd + '"');
}
+
+ last_cmd = cmd;
}
DebugRequest.prototype.JSONRequest = function() {
// Create a JSON request for the step command.
-DebugRequest.prototype.stepCommandToJSONRequest_ = function(args, type) {
+DebugRequest.prototype.stepCommandToJSONRequest_ = function(args) {
// Requesting a step is through the continue command with additional
// arguments.
var request = this.createRequest('continue');
request.arguments = {};
// Process arguments if any.
-
- // Only process args if the command is 'step' which is indicated by type being
- // set to 'in'. For all other commands, ignore the args.
if (args && args.length > 0) {
- args = args.split(/\s+/g);
+ args = args.split(/\s*[ ]+\s*/g);
if (args.length > 2) {
throw new Error('Invalid step arguments.');
}
if (args.length > 0) {
- // Check if we have a gdb stype step command. If so, the 1st arg would
- // be the step count. If it's not a number, then assume that we're
- // parsing for the legacy v8 step command.
- var stepcount = Number(args[0]);
- if (stepcount == Number.NaN) {
- // No step count at arg 1. Process as legacy d8 step command:
- if (args.length == 2) {
- var stepcount = parseInt(args[1]);
- if (isNaN(stepcount) || stepcount <= 0) {
- throw new Error('Invalid step count argument "' + args[0] + '".');
- }
- request.arguments.stepcount = stepcount;
+ // Get step count argument if any.
+ if (args.length == 2) {
+ var stepcount = parseInt(args[1]);
+ if (isNaN(stepcount) || stepcount <= 0) {
+ throw new Error('Invalid step count argument "' + args[0] + '".');
}
+ request.arguments.stepcount = stepcount;
+ }
- // Get the step action.
- switch (args[0]) {
- case 'in':
- case 'i':
- request.arguments.stepaction = 'in';
- break;
-
- case 'min':
- case 'm':
- request.arguments.stepaction = 'min';
- break;
+ // Get the step action.
+ switch (args[0]) {
+ case 'in':
+ case 'i':
+ request.arguments.stepaction = 'in';
+ break;
- case 'next':
- case 'n':
- request.arguments.stepaction = 'next';
- break;
+ case 'min':
+ case 'm':
+ request.arguments.stepaction = 'min';
+ break;
- case 'out':
- case 'o':
- request.arguments.stepaction = 'out';
- break;
+ case 'next':
+ case 'n':
+ request.arguments.stepaction = 'next';
+ break;
- default:
- throw new Error('Invalid step argument "' + args[0] + '".');
- }
+ case 'out':
+ case 'o':
+ request.arguments.stepaction = 'out';
+ break;
- } else {
- // gdb style step commands:
- request.arguments.stepaction = type;
- request.arguments.stepcount = stepcount;
+ default:
+ throw new Error('Invalid step argument "' + args[0] + '".');
}
}
} else {
- // Default is step of the specified type.
- request.arguments.stepaction = type;
+ // Default is step next.
+ request.arguments.stepaction = 'next';
}
return request.toJSONProtocol();
};
-// Create a JSON request for the list command.
-DebugRequest.prototype.listCommandToJSONRequest_ = function(args) {
-
- // Default is ten lines starting five lines before the current location.
- if (Debug.State.displaySourceEndLine == -1) {
- // If we list forwards, we will start listing after the last source end
- // line. Set it to start from 5 lines before the current location.
- Debug.State.displaySourceEndLine = Debug.State.currentSourceLine - 5;
- // If we list backwards, we will start listing backwards from the last
- // source start line. Set it to start from 1 lines before the current
- // location.
- Debug.State.displaySourceStartLine = Debug.State.currentSourceLine + 1;
- }
-
- var from = Debug.State.displaySourceEndLine + 1;
- var lines = 10;
-
- // Parse the arguments.
- args = args.split(/\s*,\s*/g);
- if (args == '') {
- } else if ((args.length == 1) && (args[0] == '-')) {
- from = Debug.State.displaySourceStartLine - lines;
- } else if (args.length == 2) {
- from = parseInt(args[0]);
- lines = parseInt(args[1]) - from + 1; // inclusive of the ending line.
- } else {
- throw new Error('Invalid list arguments.');
- }
- Debug.State.displaySourceStartLine = from;
- Debug.State.displaySourceEndLine = from + lines - 1;
- var sourceArgs = '' + from + ' ' + lines;
- return this.sourceCommandToJSONRequest_(sourceArgs);
-};
-
-
// Create a JSON request for the source command.
DebugRequest.prototype.sourceCommandToJSONRequest_ = function(args) {
// Build a evaluate request from the text command.
break;
default:
- // If the arg is not one of the know one aboves, then it must be a
- // filter used for filtering the results:
- request.arguments.filter = args[0];
- break;
+ throw new Error('Invalid argument "' + args[0] + '".');
}
}
var request = this.createRequest('setbreakpoint');
- // Break the args into target spec and condition if appropriate.
-
// Check for breakpoint condition.
pos = args.indexOf(' ');
if (pos > 0) {
};
-// Create a JSON request for the change breakpoint command.
-DebugRequest.prototype.changeBreakpointCommandToJSONRequest_ =
- function(args, command) {
-
- var request;
-
- // Check for exception breaks first:
- // en[able] exc[eptions] [all|unc[aught]]
- // en[able] [all|unc[aught]] exc[eptions]
- // dis[able] exc[eptions] [all|unc[aught]]
- // dis[able] [all|unc[aught]] exc[eptions]
- if ((command == 'enable' || command == 'disable') &&
- args && args.length > 1) {
- var nextPos = args.indexOf(' ');
- var arg1 = (nextPos > 0) ? args.substring(0, nextPos) : args;
- var excType = null;
-
- // Check for:
- // en[able] exc[eptions] [all|unc[aught]]
- // dis[able] exc[eptions] [all|unc[aught]]
- if (arg1 == 'exc' || arg1 == 'exception' || arg1 == 'exceptions') {
-
- var arg2 = (nextPos > 0) ?
- args.substring(nextPos + 1, args.length) : 'all';
- if (!arg2) {
- arg2 = 'all'; // if unspecified, set for all.
- } if (arg2 == 'unc') { // check for short cut.
- arg2 = 'uncaught';
- }
- excType = arg2;
-
- // Check for:
- // en[able] [all|unc[aught]] exc[eptions]
- // dis[able] [all|unc[aught]] exc[eptions]
- } else if (arg1 == 'all' || arg1 == 'unc' || arg1 == 'uncaught') {
-
- var arg2 = (nextPos > 0) ?
- args.substring(nextPos + 1, args.length) : null;
- if (arg2 == 'exc' || arg1 == 'exception' || arg1 == 'exceptions') {
- excType = arg1;
- if (excType == 'unc') {
- excType = 'uncaught';
- }
- }
- }
-
- // If we matched one of the command formats, then excType will be non-null:
- if (excType) {
- // Build a evaluate request from the text command.
- request = this.createRequest('setexceptionbreak');
-
- request.arguments = {};
- request.arguments.type = excType;
- request.arguments.enabled = (command == 'enable');
-
- return request.toJSONProtocol();
- }
- }
-
- // Build a evaluate request from the text command.
- request = this.createRequest('changebreakpoint');
-
- // Process arguments if any.
- if (args && args.length > 0) {
- request.arguments = {};
- var pos = args.indexOf(' ');
- var breakpointArg = args;
- var otherArgs;
- if (pos > 0) {
- breakpointArg = args.substring(0, pos);
- otherArgs = args.substring(pos + 1, args.length);
- }
-
- request.arguments.breakpoint = parseInt(breakpointArg);
-
- switch(command) {
- case 'cond':
- request.arguments.condition = otherArgs ? otherArgs : null;
- break;
- case 'enable':
- request.arguments.enabled = true;
- break;
- case 'disable':
- request.arguments.enabled = false;
- break;
- case 'ignore':
- request.arguments.ignoreCount = parseInt(otherArgs);
- break;
- default:
- throw new Error('Invalid arguments.');
- }
- } else {
- throw new Error('Invalid arguments.');
- }
-
- return request.toJSONProtocol();
-};
-
-
-// Create a JSON request for the disconnect command.
-DebugRequest.prototype.disconnectCommandToJSONRequest_ = function(args) {
- var request;
- request = this.createRequest('disconnect');
- return request.toJSONProtocol();
-};
-
-
-// Create a JSON request for the info command.
-DebugRequest.prototype.infoCommandToJSONRequest_ = function(args) {
- var request;
- if (args && (args == 'break' || args == 'br')) {
- // Build a evaluate request from the text command.
- request = this.createRequest('listbreakpoints');
- last_cmd = 'info break';
- } else if (args && (args == 'locals' || args == 'lo')) {
- // Build a evaluate request from the text command.
- request = this.createRequest('frame');
- last_cmd = 'info locals';
- } else if (args && (args == 'args' || args == 'ar')) {
- // Build a evaluate request from the text command.
- request = this.createRequest('frame');
- last_cmd = 'info args';
- } else {
- throw new Error('Invalid info arguments.');
- }
-
- return request.toJSONProtocol();
-};
-
-
-DebugRequest.prototype.v8FlagsToJSONRequest_ = function(args) {
- var request;
- request = this.createRequest('v8flags');
- request.arguments = {};
- request.arguments.flags = args;
- return request.toJSONProtocol();
-};
-
-
-DebugRequest.prototype.gcToJSONRequest_ = function(args) {
- var request;
- if (!args) {
- args = 'all';
- }
- var args = args.split(/\s+/g);
- var cmd = args[0];
-
- switch(cmd) {
- case 'all':
- case 'quick':
- case 'full':
- case 'young':
- case 'old':
- case 'compact':
- case 'sweep':
- case 'scavenge': {
- if (cmd == 'young') { cmd = 'quick'; }
- else if (cmd == 'old') { cmd = 'full'; }
-
- request = this.createRequest('gc');
- request.arguments = {};
- request.arguments.type = cmd;
- break;
- }
- // Else fall thru to the default case below to report the error.
- default:
- throw new Error('Missing arguments after ' + cmd + '.');
- }
- return request.toJSONProtocol();
-};
-
-
// Create a JSON request for the threads command.
DebugRequest.prototype.threadsCommandToJSONRequest_ = function(args) {
// Build a threads request from the text command.
if (args == 'compile') {
trace_compile = !trace_compile;
print('Tracing of compiled scripts ' + (trace_compile ? 'on' : 'off'));
- } else if (args === 'debug json' || args === 'json' || args === 'packets') {
- trace_debug_json = !trace_debug_json;
- print('Tracing of debug json packets ' +
- (trace_debug_json ? 'on' : 'off'));
} else {
throw new Error('Invalid trace arguments.');
}
print('warning: arguments to \'help\' are ignored');
}
- print('Note: <> denotes symbollic values to be replaced with real values.');
- print('Note: [] denotes optional parts of commands, or optional options / arguments.');
- print(' e.g. d[elete] - you get the same command if you type d or delete.');
- print('');
- print('[break] - break as soon as possible');
- print('b[reak] location [condition]');
- print(' - break on named function: location is a function name');
- print(' - break on function: location is #<id>#');
- print(' - break on script position: location is name:line[:column]');
- print('');
- print('clear <breakpoint #> - deletes the specified user defined breakpoint');
- print('d[elete] <breakpoint #> - deletes the specified user defined breakpoint');
- print('dis[able] <breakpoint #> - disables the specified user defined breakpoint');
- print('dis[able] exc[eptions] [[all] | unc[aught]]');
- print(' - disables breaking on exceptions');
- print('en[able] <breakpoint #> - enables the specified user defined breakpoint');
- print('en[able] exc[eptions] [[all] | unc[aught]]');
- print(' - enables breaking on exceptions');
- print('');
- print('b[ack]t[race] [n] | [-n] | [from to]');
- print(' - prints the stack back trace');
- print('f[rame] - prints info about the current frame context');
- print('f[rame] <frame #> - set context to specified frame #');
+ print('break');
+ print('break location [condition]');
+ print(' break on named function: location is a function name');
+ print(' break on function: location is #<id>#');
+ print(' break on script position: location is name:line[:column]');
+ print('clear <breakpoint #>');
+ print('backtrace [n] | [-n] | [from to]');
+ print('frame <frame #>');
print('scopes');
print('scope <scope #>');
- print('');
- print('up - set context to caller of current frame');
- print('do[wn] - set context to callee of current frame');
- print('inf[o] br[eak] - prints info about breakpoints in use');
- print('inf[o] ar[gs] - prints info about arguments of the current function');
- print('inf[o] lo[cals] - prints info about locals in the current function');
- print('inf[o] liveobjectlist|lol - same as \'lol info\'');
- print('');
print('step [in | next | out| min [step count]]');
- print('c[ontinue] - continue executing after a breakpoint');
- print('s[tep] [<N>] - step into the next N callees (default N is 1)');
- print('s[tep]i [<N>] - step into the next N callees (default N is 1)');
- print('n[ext] [<N>] - step over the next N callees (default N is 1)');
- print('fin[ish] [<N>] - step out of N frames (default N is 1)');
- print('');
- print('p[rint] <expression> - prints the result of the specified expression');
- print('dir <expression> - prints the object structure of the result');
- print('set <var> = <expression> - executes the specified statement');
- print('');
- print('l[ist] - list the source code around for the current pc');
- print('l[ist] [- | <start>,<end>] - list the specified range of source code');
+ print('print <expression>');
+ print('dir <expression>');
print('source [from line [num lines]]');
- print('scr[ipts] [native|extensions|all]');
- print('scr[ipts] [<filter text>] - list scripts with the specified text in its description');
- print('');
- print('gc - runs the garbage collector');
- print('');
+ print('scripts');
+ print('continue');
print('trace compile');
- // hidden command: trace debug json - toggles tracing of debug json packets
- print('');
- print('disconnect|exit|quit - disconnects and quits the debugger');
- print('help - prints this help information');
+ print('help');
}
}
-function refObjectToString_(protocolPackage, handle) {
- var value = protocolPackage.lookup(handle);
- var result = '';
- if (value.isString()) {
- result = '"' + value.value() + '"';
- } else if (value.isPrimitive()) {
- result = value.valueString();
- } else if (value.isObject()) {
- result += formatObject_(value, true);
- }
- return result;
-}
-
-
-// Rounds number 'num' to 'length' decimal places.
-function roundNumber(num, length) {
- var factor = Math.pow(10, length);
- return Math.round(num * factor) / factor;
-}
-
-
// Convert a JSON response to text for display in a text based debugger.
function DebugResponseDetails(response) {
details = {text:'', running:false}
details.text = result;
break;
- case 'changebreakpoint':
- result = 'successfully changed breakpoint';
- details.text = result;
- break;
-
case 'listbreakpoints':
result = 'breakpoints: (' + body.breakpoints.length + ')';
for (var i = 0; i < body.breakpoints.length; i++) {
if (breakpoint.script_name) {
result += ' script_name=' + breakpoint.script_name;
}
- result += ' line=' + (breakpoint.line + 1);
+ result += ' line=' + breakpoint.line;
if (breakpoint.column != null) {
- result += ' column=' + (breakpoint.column + 1);
+ result += ' column=' + breakpoint.column;
}
if (breakpoint.groupId) {
result += ' groupId=' + breakpoint.groupId;
}
result += ' hit_count=' + breakpoint.hit_count;
}
- if (body.breakpoints.length === 0) {
- result = "No user defined breakpoints\n";
- } else {
- result += '\n';
- }
- if (body.breakOnExceptions) {
- result += '* breaking on ALL exceptions is enabled\n';
- } else if (body.breakOnUncaughtExceptions) {
- result += '* breaking on UNCAUGHT exceptions is enabled\n';
- } else {
- result += '* all exception breakpoints are disabled\n';
- }
- details.text = result;
- break;
-
- case 'setexceptionbreak':
- result = 'Break on ' + body.type + ' exceptions: ';
- result += body.enabled ? 'enabled' : 'disabled';
details.text = result;
break;
break;
case 'frame':
- if (last_cmd === 'info locals') {
- var locals = body.locals;
- if (locals.length === 0) {
- result = 'No locals';
- } else {
- for (var i = 0; i < locals.length; i++) {
- var local = locals[i];
- result += local.name + ' = ';
- result += refObjectToString_(response, local.value.ref);
- result += '\n';
- }
- }
- } else if (last_cmd === 'info args') {
- var args = body.arguments;
- if (args.length === 0) {
- result = 'No arguments';
- } else {
- for (var i = 0; i < args.length; i++) {
- var arg = args[i];
- result += arg.name + ' = ';
- result += refObjectToString_(response, arg.value.ref);
- result += '\n';
- }
- }
- } else {
- result = SourceUnderline(body.sourceLineText,
- body.column);
- Debug.State.currentSourceLine = body.line;
- Debug.State.currentFrame = body.index;
- Debug.State.displaySourceStartLine = -1;
- Debug.State.displaySourceEndLine = -1;
- }
- details.text = result;
+ details.text = SourceUnderline(body.sourceLineText,
+ body.column);
+ Debug.State.currentSourceLine = body.line;
+ Debug.State.currentFrame = body.index;
break;
case 'scopes':
if (body[i].name) {
result += body[i].name;
} else {
- if (body[i].compilationType == Debug.ScriptCompilationType.Eval
- && body[i].evalFromScript
- ) {
+ if (body[i].compilationType == Debug.ScriptCompilationType.Eval) {
result += 'eval from ';
var script_value = response.lookup(body[i].evalFromScript.ref);
result += ' ' + script_value.field('name');
result += sourceStart;
result += ']';
}
- if (body.length == 0) {
- result = "no matching scripts found";
- }
details.text = result;
break;
details.text = "(running)";
break;
- case 'v8flags':
- details.text = "flags set";
- break;
-
- case 'gc':
- details.text = "GC " + body.before + " => " + body.after;
- if (body.after > (1024*1024)) {
- details.text +=
- " (" + roundNumber(body.before/(1024*1024), 1) + "M => " +
- roundNumber(body.after/(1024*1024), 1) + "M)";
- } else if (body.after > 1024) {
- details.text +=
- " (" + roundNumber(body.before/1024, 1) + "K => " +
- roundNumber(body.after/1024, 1) + "K)";
- }
- break;
-
default:
details.text =
'Response for unknown command \'' + response.command() + '\'' +
}
-ProtocolValue.prototype.valueString = function() {
- return this.value_.text;
-}
-
-
function ProtocolReference(handle) {
this.handle_ = handle;
}
var property_value_json;
switch (typeof property_value) {
case 'object':
- if (property_value === null) {
- property_value_json = 'null';
- } else if (typeof property_value.toJSONProtocol == 'function') {
+ if (typeof property_value.toJSONProtocol == 'function') {
property_value_json = property_value.toJSONProtocol(true)
} else if (property_value.constructor.name == 'Array'){
property_value_json = SimpleArrayToJSON_(property_value);
Debug.enableBreakPoint = function(break_point_number) {
var break_point = this.findBreakPoint(break_point_number, false);
- // Only enable if the breakpoint hasn't been deleted:
- if (break_point) {
- break_point.enable();
- }
+ break_point.enable();
};
Debug.disableBreakPoint = function(break_point_number) {
var break_point = this.findBreakPoint(break_point_number, false);
- // Only enable if the breakpoint hasn't been deleted:
- if (break_point) {
- break_point.disable();
- }
+ break_point.disable();
};
};
-Debug.disableAllBreakPoints = function() {
- // Disable all user defined breakpoints:
- for (var i = 1; i < next_break_point_number; i++) {
- Debug.disableBreakPoint(i);
- }
- // Disable all exception breakpoints:
- %ChangeBreakOnException(Debug.ExceptionBreak.Caught, false);
- %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, false);
-};
-
-
Debug.findScriptBreakPoint = function(break_point_number, remove) {
var script_break_point;
for (var i = 0; i < script_break_points.length; i++) {
this.clearBreakPointRequest_(request, response);
} else if (request.command == 'clearbreakpointgroup') {
this.clearBreakPointGroupRequest_(request, response);
- } else if (request.command == 'disconnect') {
- this.disconnectRequest_(request, response);
- } else if (request.command == 'setexceptionbreak') {
- this.setExceptionBreakRequest_(request, response);
} else if (request.command == 'listbreakpoints') {
this.listBreakpointsRequest_(request, response);
} else if (request.command == 'backtrace') {
this.changeLiveRequest_(request, response);
} else if (request.command == 'flags') {
this.debuggerFlagsRequest_(request, response);
- } else if (request.command == 'v8flags') {
- this.v8FlagsRequest_(request, response);
-
- // GC tools:
- } else if (request.command == 'gc') {
- this.gcRequest_(request, response);
-
} else {
throw new Error('Unknown command "' + request.command + '" in request');
}
array.push(description);
}
- response.body = {
- breakpoints: array,
- breakOnExceptions: Debug.isBreakOnException(),
- breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException()
- }
-}
-
-
-DebugCommandProcessor.prototype.disconnectRequest_ =
- function(request, response) {
- Debug.disableAllBreakPoints();
- this.continueRequest_(request, response);
-}
-
-
-DebugCommandProcessor.prototype.setExceptionBreakRequest_ =
- function(request, response) {
- // Check for legal request.
- if (!request.arguments) {
- response.failed('Missing arguments');
- return;
- }
-
- // Pull out and check the 'type' argument:
- var type = request.arguments.type;
- if (!type) {
- response.failed('Missing argument "type"');
- return;
- }
-
- // Initialize the default value of enable:
- var enabled;
- if (type == 'all') {
- enabled = !Debug.isBreakOnException();
- } else if (type == 'uncaught') {
- enabled = !Debug.isBreakOnUncaughtException();
- }
-
- // Pull out and check the 'enabled' argument if present:
- if (!IS_UNDEFINED(request.arguments.enabled)) {
- enabled = request.arguments.enabled;
- if ((enabled != true) && (enabled != false)) {
- response.failed('Illegal value for "enabled":"' + enabled + '"');
- }
- }
-
- // Now set the exception break state:
- if (type == 'all') {
- %ChangeBreakOnException(Debug.ExceptionBreak.Caught, enabled);
- } else if (type == 'uncaught') {
- %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, enabled);
- } else {
- response.failed('Unknown "type":"' + type + '"');
- }
-
- // Add the cleared break point number to the response.
- response.body = { 'type': type, 'enabled': enabled };
+ response.body = { breakpoints: array }
}
idsToInclude[ids[i]] = true;
}
}
-
- var filterStr = null;
- var filterNum = null;
- if (!IS_UNDEFINED(request.arguments.filter)) {
- var num = %ToNumber(request.arguments.filter);
- if (!isNaN(num)) {
- filterNum = num;
- }
- filterStr = request.arguments.filter;
- }
}
// Collect all scripts in the heap.
if (idsToInclude && !idsToInclude[scripts[i].id]) {
continue;
}
- if (filterStr || filterNum) {
- var script = scripts[i];
- var found = false;
- if (filterNum && !found) {
- if (script.id && script.id === filterNum) {
- found = true;
- }
- }
- if (filterStr && !found) {
- if (script.name && script.name.indexOf(filterStr) >= 0) {
- found = true;
- }
- }
- if (!found) continue;
- }
if (types & ScriptTypeFlag(scripts[i].type)) {
response.body.push(MakeMirror(scripts[i]));
}
}
-DebugCommandProcessor.prototype.v8FlagsRequest_ = function(request, response) {
- var flags = request.arguments.flags;
- if (!flags) flags = '';
- %SetFlags(flags);
-};
-
-
-DebugCommandProcessor.prototype.gcRequest_ = function(request, response) {
- var type = request.arguments.type;
- if (!type) type = 'all';
-
- var before = %GetHeapUsage();
- %CollectGarbage(type);
- var after = %GetHeapUsage();
-
- response.body = { "before": before, "after": after };
-};
-
-
-
-
// Check whether the previously processed command caused the VM to become
// running.
DebugCommandProcessor.prototype.isRunning = function() {