Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: src/debug/debug.js

Issue 2222893002: Move family of MakeError functions to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix in prologue.js Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function (global, utils) { 5 (function (global, utils) {
6 "use strict"; 6 "use strict";
7 7
8 // ---------------------------------------------------------------------------- 8 // ----------------------------------------------------------------------------
9 // Imports 9 // Imports
10 10
11 var FrameMirror = global.FrameMirror; 11 var FrameMirror = global.FrameMirror;
12 var GlobalArray = global.Array; 12 var GlobalArray = global.Array;
13 var GlobalRegExp = global.RegExp; 13 var GlobalRegExp = global.RegExp;
14 var IsNaN = global.isNaN; 14 var IsNaN = global.isNaN;
15 var JSONParse = global.JSON.parse; 15 var JSONParse = global.JSON.parse;
16 var JSONStringify = global.JSON.stringify; 16 var JSONStringify = global.JSON.stringify;
17 var LookupMirror = global.LookupMirror; 17 var LookupMirror = global.LookupMirror;
18 var MakeError;
19 var MakeTypeError;
20 var MakeMirror = global.MakeMirror; 18 var MakeMirror = global.MakeMirror;
21 var MakeMirrorSerializer = global.MakeMirrorSerializer; 19 var MakeMirrorSerializer = global.MakeMirrorSerializer;
22 var MathMin = global.Math.min; 20 var MathMin = global.Math.min;
23 var Mirror = global.Mirror; 21 var Mirror = global.Mirror;
24 var MirrorType; 22 var MirrorType;
25 var ParseInt = global.parseInt; 23 var ParseInt = global.parseInt;
26 var ValueMirror = global.ValueMirror; 24 var ValueMirror = global.ValueMirror;
27 25
28 utils.Import(function(from) { 26 utils.Import(function(from) {
29 MakeError = from.MakeError;
30 MakeTypeError = from.MakeTypeError;
31 MirrorType = from.MirrorType; 27 MirrorType = from.MirrorType;
32 }); 28 });
33 29
34 //---------------------------------------------------------------------------- 30 //----------------------------------------------------------------------------
35 31
36 // Default number of frames to include in the response to backtrace request. 32 // Default number of frames to include in the response to backtrace request.
37 var kDefaultBacktraceLength = 10; 33 var kDefaultBacktraceLength = 10;
38 34
39 var Debug = {}; 35 var Debug = {};
40 36
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, 236 function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
241 opt_groupId, opt_position_alignment) { 237 opt_groupId, opt_position_alignment) {
242 this.type_ = type; 238 this.type_ = type;
243 if (type == Debug.ScriptBreakPointType.ScriptId) { 239 if (type == Debug.ScriptBreakPointType.ScriptId) {
244 this.script_id_ = script_id_or_name; 240 this.script_id_ = script_id_or_name;
245 } else if (type == Debug.ScriptBreakPointType.ScriptName) { 241 } else if (type == Debug.ScriptBreakPointType.ScriptName) {
246 this.script_name_ = script_id_or_name; 242 this.script_name_ = script_id_or_name;
247 } else if (type == Debug.ScriptBreakPointType.ScriptRegExp) { 243 } else if (type == Debug.ScriptBreakPointType.ScriptRegExp) {
248 this.script_regexp_object_ = new GlobalRegExp(script_id_or_name); 244 this.script_regexp_object_ = new GlobalRegExp(script_id_or_name);
249 } else { 245 } else {
250 throw MakeError(kDebugger, "Unexpected breakpoint type " + type); 246 throw %make_error(kDebugger, "Unexpected breakpoint type " + type);
251 } 247 }
252 this.line_ = opt_line || 0; 248 this.line_ = opt_line || 0;
253 this.column_ = opt_column; 249 this.column_ = opt_column;
254 this.groupId_ = opt_groupId; 250 this.groupId_ = opt_groupId;
255 this.position_alignment_ = IS_UNDEFINED(opt_position_alignment) 251 this.position_alignment_ = IS_UNDEFINED(opt_position_alignment)
256 ? Debug.BreakPositionAlignment.Statement : opt_position_alignment; 252 ? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
257 this.active_ = true; 253 this.active_ = true;
258 this.condition_ = null; 254 this.condition_ = null;
259 this.break_points_ = []; 255 this.break_points_ = [];
260 } 256 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // We might want to account columns here as well. 359 // We might want to account columns here as well.
364 if (!(script.line_offset <= this.line_ && 360 if (!(script.line_offset <= this.line_ &&
365 this.line_ < script.line_offset + %ScriptLineCount(script))) { 361 this.line_ < script.line_offset + %ScriptLineCount(script))) {
366 return false; 362 return false;
367 } 363 }
368 if (this.type_ == Debug.ScriptBreakPointType.ScriptName) { 364 if (this.type_ == Debug.ScriptBreakPointType.ScriptName) {
369 return this.script_name_ == script.nameOrSourceURL(); 365 return this.script_name_ == script.nameOrSourceURL();
370 } else if (this.type_ == Debug.ScriptBreakPointType.ScriptRegExp) { 366 } else if (this.type_ == Debug.ScriptBreakPointType.ScriptRegExp) {
371 return this.script_regexp_object_.test(script.nameOrSourceURL()); 367 return this.script_regexp_object_.test(script.nameOrSourceURL());
372 } else { 368 } else {
373 throw MakeError(kDebugger, "Unexpected breakpoint type " + this.type_); 369 throw %make_error(kDebugger, "Unexpected breakpoint type " + this.type_);
374 } 370 }
375 } 371 }
376 }; 372 };
377 373
378 374
379 // Set the script break point in a script. 375 // Set the script break point in a script.
380 ScriptBreakPoint.prototype.set = function (script) { 376 ScriptBreakPoint.prototype.set = function (script) {
381 var column = this.column(); 377 var column = this.column();
382 var line = this.line(); 378 var line = this.line();
383 // If the column is undefined the break is on the line. To help locate the 379 // If the column is undefined the break is on the line. To help locate the
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (script_break_points[i].matchesScript(script)) { 455 if (script_break_points[i].matchesScript(script)) {
460 result.push(script_break_points[i]); 456 result.push(script_break_points[i]);
461 } 457 }
462 } 458 }
463 return result; 459 return result;
464 } 460 }
465 461
466 462
467 Debug.setListener = function(listener, opt_data) { 463 Debug.setListener = function(listener, opt_data) {
468 if (!IS_FUNCTION(listener) && !IS_UNDEFINED(listener) && !IS_NULL(listener)) { 464 if (!IS_FUNCTION(listener) && !IS_UNDEFINED(listener) && !IS_NULL(listener)) {
469 throw MakeTypeError(kDebuggerType); 465 throw %make_type_error(kDebuggerType);
470 } 466 }
471 %SetDebugEventListener(listener, opt_data); 467 %SetDebugEventListener(listener, opt_data);
472 }; 468 };
473 469
474 470
475 // Returns a Script object. If the parameter is a function the return value 471 // Returns a Script object. If the parameter is a function the return value
476 // is the script in which the function is defined. If the parameter is a string 472 // is the script in which the function is defined. If the parameter is a string
477 // the return value is the script for which the script name has that string 473 // the return value is the script for which the script name has that string
478 // value. If it is a regexp and there is a unique script whose name matches 474 // value. If it is a regexp and there is a unique script whose name matches
479 // we return that, otherwise undefined. 475 // we return that, otherwise undefined.
(...skipping 29 matching lines...) Expand all
509 // Returns the script source. If the parameter is a function the return value 505 // Returns the script source. If the parameter is a function the return value
510 // is the script source for the script in which the function is defined. If the 506 // is the script source for the script in which the function is defined. If the
511 // parameter is a string the return value is the script for which the script 507 // parameter is a string the return value is the script for which the script
512 // name has that string value. 508 // name has that string value.
513 Debug.scriptSource = function(func_or_script_name) { 509 Debug.scriptSource = function(func_or_script_name) {
514 return this.findScript(func_or_script_name).source; 510 return this.findScript(func_or_script_name).source;
515 }; 511 };
516 512
517 513
518 Debug.source = function(f) { 514 Debug.source = function(f) {
519 if (!IS_FUNCTION(f)) throw MakeTypeError(kDebuggerType); 515 if (!IS_FUNCTION(f)) throw %make_type_error(kDebuggerType);
520 return %FunctionGetSourceCode(f); 516 return %FunctionGetSourceCode(f);
521 }; 517 };
522 518
523 519
524 Debug.sourcePosition = function(f) { 520 Debug.sourcePosition = function(f) {
525 if (!IS_FUNCTION(f)) throw MakeTypeError(kDebuggerType); 521 if (!IS_FUNCTION(f)) throw %make_type_error(kDebuggerType);
526 return %FunctionGetScriptSourcePosition(f); 522 return %FunctionGetScriptSourcePosition(f);
527 }; 523 };
528 524
529 525
530 Debug.findFunctionSourceLocation = function(func, opt_line, opt_column) { 526 Debug.findFunctionSourceLocation = function(func, opt_line, opt_column) {
531 var script = %FunctionGetScript(func); 527 var script = %FunctionGetScript(func);
532 var script_offset = %FunctionGetScriptSourcePosition(func); 528 var script_offset = %FunctionGetScriptSourcePosition(func);
533 return %ScriptLocationFromLine(script, opt_line, opt_column, script_offset); 529 return %ScriptLocationFromLine(script, opt_line, opt_column, script_offset);
534 }; 530 };
535 531
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 565 }
570 for (var i = 0; i < break_points.length; i++) { 566 for (var i = 0; i < break_points.length; i++) {
571 if (break_points[i].number() == break_point_number) { 567 if (break_points[i].number() == break_point_number) {
572 return [break_points[i].actual_location]; 568 return [break_points[i].actual_location];
573 } 569 }
574 } 570 }
575 return []; 571 return [];
576 }; 572 };
577 573
578 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { 574 Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) {
579 if (!IS_FUNCTION(func)) throw MakeTypeError(kDebuggerType); 575 if (!IS_FUNCTION(func)) throw %make_type_error(kDebuggerType);
580 // Break points in API functions are not supported. 576 // Break points in API functions are not supported.
581 if (%FunctionIsAPIFunction(func)) { 577 if (%FunctionIsAPIFunction(func)) {
582 throw MakeError(kDebugger, 'Cannot set break point in native code.'); 578 throw %make_error(kDebugger, 'Cannot set break point in native code.');
583 } 579 }
584 // Find source position. 580 // Find source position.
585 var source_position = 581 var source_position =
586 this.findFunctionSourceLocation(func, opt_line, opt_column).position; 582 this.findFunctionSourceLocation(func, opt_line, opt_column).position;
587 // Find the script for the function. 583 // Find the script for the function.
588 var script = %FunctionGetScript(func); 584 var script = %FunctionGetScript(func);
589 // Break in builtin JavaScript code is not supported. 585 // Break in builtin JavaScript code is not supported.
590 if (script.type == Debug.ScriptType.Native) { 586 if (script.type == Debug.ScriptType.Native) {
591 throw MakeError(kDebugger, 'Cannot set break point in native code.'); 587 throw %make_error(kDebugger, 'Cannot set break point in native code.');
592 } 588 }
593 // If the script for the function has a name convert this to a script break 589 // If the script for the function has a name convert this to a script break
594 // point. 590 // point.
595 if (script && script.id) { 591 if (script && script.id) {
596 // Find line and column for the position in the script and set a script 592 // Find line and column for the position in the script and set a script
597 // break point from that. 593 // break point from that.
598 var location = script.locationFromPosition(source_position, false); 594 var location = script.locationFromPosition(source_position, false);
599 return this.setScriptBreakPointById(script.id, 595 return this.setScriptBreakPointById(script.id,
600 location.line, location.column, 596 location.line, location.column,
601 opt_condition); 597 opt_condition);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 break_point.setCondition(condition); 653 break_point.setCondition(condition);
658 }; 654 };
659 655
660 656
661 Debug.clearBreakPoint = function(break_point_number) { 657 Debug.clearBreakPoint = function(break_point_number) {
662 var break_point = this.findBreakPoint(break_point_number, true); 658 var break_point = this.findBreakPoint(break_point_number, true);
663 if (break_point) { 659 if (break_point) {
664 return %ClearBreakPoint(break_point); 660 return %ClearBreakPoint(break_point);
665 } else { 661 } else {
666 break_point = this.findScriptBreakPoint(break_point_number, true); 662 break_point = this.findScriptBreakPoint(break_point_number, true);
667 if (!break_point) throw MakeError(kDebugger, 'Invalid breakpoint'); 663 if (!break_point) throw %make_error(kDebugger, 'Invalid breakpoint');
668 } 664 }
669 }; 665 };
670 666
671 667
672 Debug.clearAllBreakPoints = function() { 668 Debug.clearAllBreakPoints = function() {
673 for (var i = 0; i < break_points.length; i++) { 669 for (var i = 0; i < break_points.length; i++) {
674 var break_point = break_points[i]; 670 var break_point = break_points[i];
675 %ClearBreakPoint(break_point); 671 %ClearBreakPoint(break_point);
676 } 672 }
677 break_points = []; 673 break_points = [];
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 805
810 Debug.clearBreakOnUncaughtException = function() { 806 Debug.clearBreakOnUncaughtException = function() {
811 return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, false); 807 return %ChangeBreakOnException(Debug.ExceptionBreak.Uncaught, false);
812 }; 808 };
813 809
814 Debug.isBreakOnUncaughtException = function() { 810 Debug.isBreakOnUncaughtException = function() {
815 return !!%IsBreakOnException(Debug.ExceptionBreak.Uncaught); 811 return !!%IsBreakOnException(Debug.ExceptionBreak.Uncaught);
816 }; 812 };
817 813
818 Debug.showBreakPoints = function(f, full, opt_position_alignment) { 814 Debug.showBreakPoints = function(f, full, opt_position_alignment) {
819 if (!IS_FUNCTION(f)) throw MakeError(kDebuggerType); 815 if (!IS_FUNCTION(f)) throw %make_error(kDebuggerType);
820 var source = full ? this.scriptSource(f) : this.source(f); 816 var source = full ? this.scriptSource(f) : this.source(f);
821 var offset = full ? 0 : this.sourcePosition(f); 817 var offset = full ? 0 : this.sourcePosition(f);
822 var position_alignment = IS_UNDEFINED(opt_position_alignment) 818 var position_alignment = IS_UNDEFINED(opt_position_alignment)
823 ? Debug.BreakPositionAlignment.Statement : opt_position_alignment; 819 ? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
824 var locations = %GetBreakLocations(f, position_alignment); 820 var locations = %GetBreakLocations(f, position_alignment);
825 if (!locations) return source; 821 if (!locations) return source;
826 locations.sort(function(x, y) { return x - y; }); 822 locations.sort(function(x, y) { return x - y; });
827 var result = ""; 823 var result = "";
828 var prev_pos = 0; 824 var prev_pos = 0;
829 var pos; 825 var pos;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 this.selected_frame = 0; 879 this.selected_frame = 0;
884 } 880 }
885 881
886 ExecutionState.prototype.prepareStep = function(action) { 882 ExecutionState.prototype.prepareStep = function(action) {
887 if (action === Debug.StepAction.StepIn || 883 if (action === Debug.StepAction.StepIn ||
888 action === Debug.StepAction.StepOut || 884 action === Debug.StepAction.StepOut ||
889 action === Debug.StepAction.StepNext || 885 action === Debug.StepAction.StepNext ||
890 action === Debug.StepAction.StepFrame) { 886 action === Debug.StepAction.StepFrame) {
891 return %PrepareStep(this.break_id, action); 887 return %PrepareStep(this.break_id, action);
892 } 888 }
893 throw MakeTypeError(kDebuggerType); 889 throw %make_type_error(kDebuggerType);
894 }; 890 };
895 891
896 ExecutionState.prototype.evaluateGlobal = function(source, disable_break, 892 ExecutionState.prototype.evaluateGlobal = function(source, disable_break,
897 opt_additional_context) { 893 opt_additional_context) {
898 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source, 894 return MakeMirror(%DebugEvaluateGlobal(this.break_id, source,
899 TO_BOOLEAN(disable_break), 895 TO_BOOLEAN(disable_break),
900 opt_additional_context)); 896 opt_additional_context));
901 }; 897 };
902 898
903 ExecutionState.prototype.frameCount = function() { 899 ExecutionState.prototype.frameCount = function() {
904 return %GetFrameCount(this.break_id); 900 return %GetFrameCount(this.break_id);
905 }; 901 };
906 902
907 ExecutionState.prototype.frame = function(opt_index) { 903 ExecutionState.prototype.frame = function(opt_index) {
908 // If no index supplied return the selected frame. 904 // If no index supplied return the selected frame.
909 if (opt_index == null) opt_index = this.selected_frame; 905 if (opt_index == null) opt_index = this.selected_frame;
910 if (opt_index < 0 || opt_index >= this.frameCount()) { 906 if (opt_index < 0 || opt_index >= this.frameCount()) {
911 throw MakeTypeError(kDebuggerFrame); 907 throw %make_type_error(kDebuggerFrame);
912 } 908 }
913 return new FrameMirror(this.break_id, opt_index); 909 return new FrameMirror(this.break_id, opt_index);
914 }; 910 };
915 911
916 ExecutionState.prototype.setSelectedFrame = function(index) { 912 ExecutionState.prototype.setSelectedFrame = function(index) {
917 var i = TO_NUMBER(index); 913 var i = TO_NUMBER(index);
918 if (i < 0 || i >= this.frameCount()) { 914 if (i < 0 || i >= this.frameCount()) {
919 throw MakeTypeError(kDebuggerFrame); 915 throw %make_type_error(kDebuggerFrame);
920 } 916 }
921 this.selected_frame = i; 917 this.selected_frame = i;
922 }; 918 };
923 919
924 ExecutionState.prototype.selectedFrame = function() { 920 ExecutionState.prototype.selectedFrame = function() {
925 return this.selected_frame; 921 return this.selected_frame;
926 }; 922 };
927 923
928 ExecutionState.prototype.debugCommandProcessor = function(opt_is_running) { 924 ExecutionState.prototype.debugCommandProcessor = function(opt_is_running) {
929 return new DebugCommandProcessor(this, opt_is_running); 925 return new DebugCommandProcessor(this, opt_is_running);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 var response; // Generated response. 1279 var response; // Generated response.
1284 try { 1280 try {
1285 try { 1281 try {
1286 // Convert the JSON string to an object. 1282 // Convert the JSON string to an object.
1287 request = JSONParse(json_request); 1283 request = JSONParse(json_request);
1288 1284
1289 // Create an initial response. 1285 // Create an initial response.
1290 response = this.createResponse(request); 1286 response = this.createResponse(request);
1291 1287
1292 if (!request.type) { 1288 if (!request.type) {
1293 throw MakeError(kDebugger, 'Type not specified'); 1289 throw %make_error(kDebugger, 'Type not specified');
1294 } 1290 }
1295 1291
1296 if (request.type != 'request') { 1292 if (request.type != 'request') {
1297 throw MakeError(kDebugger, 1293 throw %make_error(kDebugger,
1298 "Illegal type '" + request.type + "' in request"); 1294 "Illegal type '" + request.type + "' in request");
1299 } 1295 }
1300 1296
1301 if (!request.command) { 1297 if (!request.command) {
1302 throw MakeError(kDebugger, 'Command not specified'); 1298 throw %make_error(kDebugger, 'Command not specified');
1303 } 1299 }
1304 1300
1305 if (request.arguments) { 1301 if (request.arguments) {
1306 var args = request.arguments; 1302 var args = request.arguments;
1307 // TODO(yurys): remove request.arguments.compactFormat check once 1303 // TODO(yurys): remove request.arguments.compactFormat check once
1308 // ChromeDevTools are switched to 'inlineRefs' 1304 // ChromeDevTools are switched to 'inlineRefs'
1309 if (args.inlineRefs || args.compactFormat) { 1305 if (args.inlineRefs || args.compactFormat) {
1310 response.setOption('inlineRefs', true); 1306 response.setOption('inlineRefs', true);
1311 } 1307 }
1312 if (!IS_UNDEFINED(args.maxStringLength)) { 1308 if (!IS_UNDEFINED(args.maxStringLength)) {
1313 response.setOption('maxStringLength', args.maxStringLength); 1309 response.setOption('maxStringLength', args.maxStringLength);
1314 } 1310 }
1315 } 1311 }
1316 1312
1317 var key = request.command.toLowerCase(); 1313 var key = request.command.toLowerCase();
1318 var handler = DebugCommandProcessor.prototype.dispatch_[key]; 1314 var handler = DebugCommandProcessor.prototype.dispatch_[key];
1319 if (IS_FUNCTION(handler)) { 1315 if (IS_FUNCTION(handler)) {
1320 %_Call(handler, this, request, response); 1316 %_Call(handler, this, request, response);
1321 } else { 1317 } else {
1322 throw MakeError(kDebugger, 1318 throw %make_error(kDebugger,
1323 'Unknown command "' + request.command + '" in request'); 1319 'Unknown command "' + request.command + '" in request');
1324 } 1320 }
1325 } catch (e) { 1321 } catch (e) {
1326 // If there is no response object created one (without command). 1322 // If there is no response object created one (without command).
1327 if (!response) { 1323 if (!response) {
1328 response = this.createResponse(); 1324 response = this.createResponse();
1329 } 1325 }
1330 response.success = false; 1326 response.success = false;
1331 response.message = TO_STRING(e); 1327 response.message = TO_STRING(e);
1332 } 1328 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 1360
1365 // Get the stepaction argument. 1361 // Get the stepaction argument.
1366 if (stepaction) { 1362 if (stepaction) {
1367 if (stepaction == 'in') { 1363 if (stepaction == 'in') {
1368 action = Debug.StepAction.StepIn; 1364 action = Debug.StepAction.StepIn;
1369 } else if (stepaction == 'next') { 1365 } else if (stepaction == 'next') {
1370 action = Debug.StepAction.StepNext; 1366 action = Debug.StepAction.StepNext;
1371 } else if (stepaction == 'out') { 1367 } else if (stepaction == 'out') {
1372 action = Debug.StepAction.StepOut; 1368 action = Debug.StepAction.StepOut;
1373 } else { 1369 } else {
1374 throw MakeError(kDebugger, 1370 throw %make_error(kDebugger,
1375 'Invalid stepaction argument "' + stepaction + '".'); 1371 'Invalid stepaction argument "' + stepaction + '".');
1376 } 1372 }
1377 } 1373 }
1378 1374
1379 // Set up the VM for stepping. 1375 // Set up the VM for stepping.
1380 this.exec_state_.prepareStep(action); 1376 this.exec_state_.prepareStep(action);
1381 } 1377 }
1382 1378
1383 // VM should be running after executing this request. 1379 // VM should be running after executing this request.
1384 response.running = true; 1380 response.running = true;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { 1480 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) {
1485 response.body.type = 'scriptId'; 1481 response.body.type = 'scriptId';
1486 response.body.script_id = break_point.script_id(); 1482 response.body.script_id = break_point.script_id();
1487 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { 1483 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) {
1488 response.body.type = 'scriptName'; 1484 response.body.type = 'scriptName';
1489 response.body.script_name = break_point.script_name(); 1485 response.body.script_name = break_point.script_name();
1490 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { 1486 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) {
1491 response.body.type = 'scriptRegExp'; 1487 response.body.type = 'scriptRegExp';
1492 response.body.script_regexp = break_point.script_regexp_object().source; 1488 response.body.script_regexp = break_point.script_regexp_object().source;
1493 } else { 1489 } else {
1494 throw MakeError(kDebugger, 1490 throw %make_error(kDebugger,
1495 "Unexpected breakpoint type: " + break_point.type()); 1491 "Unexpected breakpoint type: " + break_point.type());
1496 } 1492 }
1497 response.body.line = break_point.line(); 1493 response.body.line = break_point.line();
1498 response.body.column = break_point.column(); 1494 response.body.column = break_point.column();
1499 response.body.actual_locations = break_point.actual_locations(); 1495 response.body.actual_locations = break_point.actual_locations();
1500 } else { 1496 } else {
1501 response.body.type = 'function'; 1497 response.body.type = 'function';
1502 response.body.actual_locations = [break_point.actual_location]; 1498 response.body.actual_locations = [break_point.actual_location];
1503 } 1499 }
1504 }; 1500 };
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) { 1614 if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) {
1619 description.type = 'scriptId'; 1615 description.type = 'scriptId';
1620 description.script_id = break_point.script_id(); 1616 description.script_id = break_point.script_id();
1621 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) { 1617 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptName) {
1622 description.type = 'scriptName'; 1618 description.type = 'scriptName';
1623 description.script_name = break_point.script_name(); 1619 description.script_name = break_point.script_name();
1624 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) { 1620 } else if (break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) {
1625 description.type = 'scriptRegExp'; 1621 description.type = 'scriptRegExp';
1626 description.script_regexp = break_point.script_regexp_object().source; 1622 description.script_regexp = break_point.script_regexp_object().source;
1627 } else { 1623 } else {
1628 throw MakeError(kDebugger, 1624 throw %make_error(kDebugger,
1629 "Unexpected breakpoint type: " + break_point.type()); 1625 "Unexpected breakpoint type: " + break_point.type());
1630 } 1626 }
1631 array.push(description); 1627 array.push(description);
1632 } 1628 }
1633 1629
1634 response.body = { 1630 response.body = {
1635 breakpoints: array, 1631 breakpoints: array,
1636 breakOnExceptions: Debug.isBreakOnException(), 1632 breakOnExceptions: Debug.isBreakOnException(),
1637 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException() 1633 breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException()
1638 }; 1634 };
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 }; 1763 };
1768 1764
1769 1765
1770 DebugCommandProcessor.prototype.resolveFrameFromScopeDescription_ = 1766 DebugCommandProcessor.prototype.resolveFrameFromScopeDescription_ =
1771 function(scope_description) { 1767 function(scope_description) {
1772 // Get the frame for which the scope or scopes are requested. 1768 // Get the frame for which the scope or scopes are requested.
1773 // With no frameNumber argument use the currently selected frame. 1769 // With no frameNumber argument use the currently selected frame.
1774 if (scope_description && !IS_UNDEFINED(scope_description.frameNumber)) { 1770 if (scope_description && !IS_UNDEFINED(scope_description.frameNumber)) {
1775 var frame_index = scope_description.frameNumber; 1771 var frame_index = scope_description.frameNumber;
1776 if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) { 1772 if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) {
1777 throw MakeTypeError(kDebuggerFrame); 1773 throw %make_type_error(kDebuggerFrame);
1778 } 1774 }
1779 return this.exec_state_.frame(frame_index); 1775 return this.exec_state_.frame(frame_index);
1780 } else { 1776 } else {
1781 return this.exec_state_.frame(); 1777 return this.exec_state_.frame();
1782 } 1778 }
1783 }; 1779 };
1784 1780
1785 1781
1786 // Gets scope host object from request. It is either a function 1782 // Gets scope host object from request. It is either a function
1787 // ('functionHandle' argument must be specified) or a stack frame 1783 // ('functionHandle' argument must be specified) or a stack frame
1788 // ('frameNumber' may be specified and the current frame is taken by default). 1784 // ('frameNumber' may be specified and the current frame is taken by default).
1789 DebugCommandProcessor.prototype.resolveScopeHolder_ = 1785 DebugCommandProcessor.prototype.resolveScopeHolder_ =
1790 function(scope_description) { 1786 function(scope_description) {
1791 if (scope_description && "functionHandle" in scope_description) { 1787 if (scope_description && "functionHandle" in scope_description) {
1792 if (!IS_NUMBER(scope_description.functionHandle)) { 1788 if (!IS_NUMBER(scope_description.functionHandle)) {
1793 throw MakeError(kDebugger, 'Function handle must be a number'); 1789 throw %make_error(kDebugger, 'Function handle must be a number');
1794 } 1790 }
1795 var function_mirror = LookupMirror(scope_description.functionHandle); 1791 var function_mirror = LookupMirror(scope_description.functionHandle);
1796 if (!function_mirror) { 1792 if (!function_mirror) {
1797 throw MakeError(kDebugger, 'Failed to find function object by handle'); 1793 throw %make_error(kDebugger, 'Failed to find function object by handle');
1798 } 1794 }
1799 if (!function_mirror.isFunction()) { 1795 if (!function_mirror.isFunction()) {
1800 throw MakeError(kDebugger, 1796 throw %make_error(kDebugger,
1801 'Value of non-function type is found by handle'); 1797 'Value of non-function type is found by handle');
1802 } 1798 }
1803 return function_mirror; 1799 return function_mirror;
1804 } else { 1800 } else {
1805 // No frames no scopes. 1801 // No frames no scopes.
1806 if (this.exec_state_.frameCount() == 0) { 1802 if (this.exec_state_.frameCount() == 0) {
1807 throw MakeError(kDebugger, 'No scopes'); 1803 throw %make_error(kDebugger, 'No scopes');
1808 } 1804 }
1809 1805
1810 // Get the frame for which the scopes are requested. 1806 // Get the frame for which the scopes are requested.
1811 var frame = this.resolveFrameFromScopeDescription_(scope_description); 1807 var frame = this.resolveFrameFromScopeDescription_(scope_description);
1812 return frame; 1808 return frame;
1813 } 1809 }
1814 } 1810 }
1815 1811
1816 1812
1817 DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) { 1813 DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 1846
1851 1847
1852 // Reads value from protocol description. Description may be in form of type 1848 // Reads value from protocol description. Description may be in form of type
1853 // (for singletons), raw value (primitive types supported in JSON), 1849 // (for singletons), raw value (primitive types supported in JSON),
1854 // string value description plus type (for primitive values) or handle id. 1850 // string value description plus type (for primitive values) or handle id.
1855 // Returns raw value or throws exception. 1851 // Returns raw value or throws exception.
1856 DebugCommandProcessor.resolveValue_ = function(value_description) { 1852 DebugCommandProcessor.resolveValue_ = function(value_description) {
1857 if ("handle" in value_description) { 1853 if ("handle" in value_description) {
1858 var value_mirror = LookupMirror(value_description.handle); 1854 var value_mirror = LookupMirror(value_description.handle);
1859 if (!value_mirror) { 1855 if (!value_mirror) {
1860 throw MakeError(kDebugger, "Failed to resolve value by handle, ' #" + 1856 throw %make_error(kDebugger, "Failed to resolve value by handle, ' #" +
1861 value_description.handle + "# not found"); 1857 value_description.handle + "# not found");
1862 } 1858 }
1863 return value_mirror.value(); 1859 return value_mirror.value();
1864 } else if ("stringDescription" in value_description) { 1860 } else if ("stringDescription" in value_description) {
1865 if (value_description.type == MirrorType.BOOLEAN_TYPE) { 1861 if (value_description.type == MirrorType.BOOLEAN_TYPE) {
1866 return TO_BOOLEAN(value_description.stringDescription); 1862 return TO_BOOLEAN(value_description.stringDescription);
1867 } else if (value_description.type == MirrorType.NUMBER_TYPE) { 1863 } else if (value_description.type == MirrorType.NUMBER_TYPE) {
1868 return TO_NUMBER(value_description.stringDescription); 1864 return TO_NUMBER(value_description.stringDescription);
1869 } if (value_description.type == MirrorType.STRING_TYPE) { 1865 } if (value_description.type == MirrorType.STRING_TYPE) {
1870 return TO_STRING(value_description.stringDescription); 1866 return TO_STRING(value_description.stringDescription);
1871 } else { 1867 } else {
1872 throw MakeError(kDebugger, "Unknown type"); 1868 throw %make_error(kDebugger, "Unknown type");
1873 } 1869 }
1874 } else if ("value" in value_description) { 1870 } else if ("value" in value_description) {
1875 return value_description.value; 1871 return value_description.value;
1876 } else if (value_description.type == MirrorType.UNDEFINED_TYPE) { 1872 } else if (value_description.type == MirrorType.UNDEFINED_TYPE) {
1877 return UNDEFINED; 1873 return UNDEFINED;
1878 } else if (value_description.type == MirrorType.NULL_TYPE) { 1874 } else if (value_description.type == MirrorType.NULL_TYPE) {
1879 return null; 1875 return null;
1880 } else { 1876 } else {
1881 throw MakeError(kDebugger, "Failed to parse value description"); 1877 throw %make_error(kDebugger, "Failed to parse value description");
1882 } 1878 }
1883 }; 1879 };
1884 1880
1885 1881
1886 DebugCommandProcessor.prototype.setVariableValueRequest_ = 1882 DebugCommandProcessor.prototype.setVariableValueRequest_ =
1887 function(request, response) { 1883 function(request, response) {
1888 if (!request.arguments) { 1884 if (!request.arguments) {
1889 response.failed('Missing arguments'); 1885 response.failed('Missing arguments');
1890 return; 1886 return;
1891 } 1887 }
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 "IsBreakPointTriggered", IsBreakPointTriggered, 2475 "IsBreakPointTriggered", IsBreakPointTriggered,
2480 "UpdateScriptBreakPoints", UpdateScriptBreakPoints, 2476 "UpdateScriptBreakPoints", UpdateScriptBreakPoints,
2481 ]); 2477 ]);
2482 2478
2483 // Export to liveedit.js 2479 // Export to liveedit.js
2484 utils.Export(function(to) { 2480 utils.Export(function(to) {
2485 to.GetScriptBreakPoints = GetScriptBreakPoints; 2481 to.GetScriptBreakPoints = GetScriptBreakPoints;
2486 }); 2482 });
2487 2483
2488 }) 2484 })
OLDNEW
« src/bootstrapper.cc ('K') | « src/contexts.h ('k') | src/debug/mirrors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698