// Process arguments if any.
if (args && args.length > 0) {
var target = args;
+ var type = 'function';
+ var line;
+ var column;
var condition;
+ var pos;
- var pos = args.indexOf(' ');
+ // Check for breakpoint condition.
+ pos = args.indexOf(' ');
if (pos > 0) {
target = args.substring(0, pos);
condition = args.substring(pos + 1, args.length);
}
+ // Check for script breakpoint (name:line[:column]). If no ':' in break
+ // specification it is considered a function break point.
+ pos = target.indexOf(':');
+ if (pos > 0) {
+ type = 'script';
+ var tmp = target.substring(pos + 1, target.length);
+ target = target.substring(0, pos);
+
+ // Check for both line and column.
+ pos = tmp.indexOf(':');
+ if (pos > 0) {
+ column = parseInt(tmp.substring(pos + 1, tmp.length)) - 1;
+ line = parseInt(tmp.substring(0, pos)) - 1;
+ } else {
+ line = parseInt(tmp) - 1;
+ }
+ } else if (target[0] == '#' && target[target.length - 1] == '#') {
+ type = 'handle';
+ target = target.substring(1, target.length - 1);
+ } else {
+ type = 'function';
+ }
+
request.arguments = {};
- request.arguments.type = 'function';
+ request.arguments.type = type;
request.arguments.target = target;
+ request.arguments.line = line;
+ request.arguments.column = column;
request.arguments.condition = condition;
} else {
throw new Error('Invalid break arguments.');
}
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 [from frame #] [to frame #]]');
print('frame <frame #>');
var ignoreCount = request.arguments.ignoreCount;
// Check for legal arguments.
- if (!type || !target) {
+ if (!type || IS_UNDEFINED(target)) {
response.failed('Missing argument "type" or "target"');
return;
}
- if (type != 'function' && type != 'script' && type != 'scriptId') {
+ if (type != 'function' && type != 'handle' &&
+ type != 'script' && type != 'scriptId') {
response.failed('Illegal type "' + type + '"');
return;
}
// Set function break point.
break_point_number = Debug.setBreakPoint(f, line, column, condition);
+ } else if (type == 'handle') {
+ // Find the object pointed by the specified handle.
+ var handle = parseInt(target, 10);
+ var mirror = LookupMirror(handle);
+ if (!mirror) {
+ return response.failed('Object #' + handle + '# not found');
+ }
+ if (!mirror.isFunction()) {
+ return response.failed('Object #' + handle + '# is not a function');
+ }
+
+ // Set function break point.
+ break_point_number = Debug.setBreakPoint(mirror.value(),
+ line, column, condition);
} else if (type == 'script') {
// set script break point.
break_point_number =
var json_response = dcp.processDebugJSONRequest(request);
var response = safeEval(json_response);
if (success) {
- assertTrue(response.success, json_response);
+ assertTrue(response.success, request + ' -> ' + json_response);
if (is_script) {
- assertEquals('scriptName', response.body.type, json_response);
+ assertEquals('scriptName', response.body.type, request + ' -> ' + json_response);
} else {
- assertEquals('scriptId', response.body.type, json_response);
+ assertEquals('scriptId', response.body.type, request + ' -> ' + json_response);
}
} else {
- assertFalse(response.success, json_response);
+ assertFalse(response.success, request + ' -> ' + json_response);
}
}
var request = '{' + base_request + '}'
var response = safeEval(dcp.processDebugJSONRequest(request));
assertFalse(response.success);
+
+ var mirror;
testArguments(dcp, '{}', false);
testArguments(dcp, '{"type":"xx"}', false);
testArguments(dcp, '{"type":"function","target":"f","line":-1}', false);
testArguments(dcp, '{"type":"function","target":"f","column":-1}', false);
testArguments(dcp, '{"type":"function","target":"f","ignoreCount":-1}', false);
+ testArguments(dcp, '{"type":"handle","target":"-1"}', false);
+ mirror = debug.MakeMirror(o);
+ testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', false);
// Test some legal setbreakpoint requests.
testArguments(dcp, '{"type":"function","target":"f"}', true, false);
testArguments(dcp, '{"type":"scriptId","target":' + g_script_id + ',"line":' + g_line + '}', true, false);
testArguments(dcp, '{"type":"scriptId","target":' + h_script_id + ',"line":' + h_line + '}', true, false);
+ mirror = debug.MakeMirror(f);
+ testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', true, false);
+ mirror = debug.MakeMirror(o.a);
+ testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', true, false);
+
// Indicate that all was processed.
listenerComplete = true;
}
eval('function h(){}');
+o = {a:function(){},b:function(){}}
+
// Check the script ids for the test functions.
f_script_id = Debug.findScript(f).id;
g_script_id = Debug.findScript(g).id;