| OLD | NEW |
| 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 // Default number of frames to include in the response to backtrace request. | 5 // Default number of frames to include in the response to backtrace request. |
| 6 var kDefaultBacktraceLength = 10; | 6 var kDefaultBacktraceLength = 10; |
| 7 | 7 |
| 8 var Debug = {}; | 8 var Debug = {}; |
| 9 | 9 |
| 10 // Regular expression to skip "crud" at the beginning of a source line which is | 10 // Regular expression to skip "crud" at the beginning of a source line which is |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 // TODO(yurys): remove request.arguments.compactFormat check once | 1381 // TODO(yurys): remove request.arguments.compactFormat check once |
| 1382 // ChromeDevTools are switched to 'inlineRefs' | 1382 // ChromeDevTools are switched to 'inlineRefs' |
| 1383 if (args.inlineRefs || args.compactFormat) { | 1383 if (args.inlineRefs || args.compactFormat) { |
| 1384 response.setOption('inlineRefs', true); | 1384 response.setOption('inlineRefs', true); |
| 1385 } | 1385 } |
| 1386 if (!IS_UNDEFINED(args.maxStringLength)) { | 1386 if (!IS_UNDEFINED(args.maxStringLength)) { |
| 1387 response.setOption('maxStringLength', args.maxStringLength); | 1387 response.setOption('maxStringLength', args.maxStringLength); |
| 1388 } | 1388 } |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 if (request.command == 'continue') { | 1391 var key = request.command.toLowerCase(); |
| 1392 this.continueRequest_(request, response); | 1392 var handler = DebugCommandProcessor.prototype.dispatch_[key]; |
| 1393 } else if (request.command == 'break') { | 1393 if (IS_FUNCTION(handler)) { |
| 1394 this.breakRequest_(request, response); | 1394 %_CallFunction(this, request, response, handler); |
| 1395 } else if (request.command == 'setbreakpoint') { | |
| 1396 this.setBreakPointRequest_(request, response); | |
| 1397 } else if (request.command == 'changebreakpoint') { | |
| 1398 this.changeBreakPointRequest_(request, response); | |
| 1399 } else if (request.command == 'clearbreakpoint') { | |
| 1400 this.clearBreakPointRequest_(request, response); | |
| 1401 } else if (request.command == 'clearbreakpointgroup') { | |
| 1402 this.clearBreakPointGroupRequest_(request, response); | |
| 1403 } else if (request.command == 'disconnect') { | |
| 1404 this.disconnectRequest_(request, response); | |
| 1405 } else if (request.command == 'setexceptionbreak') { | |
| 1406 this.setExceptionBreakRequest_(request, response); | |
| 1407 } else if (request.command == 'listbreakpoints') { | |
| 1408 this.listBreakpointsRequest_(request, response); | |
| 1409 } else if (request.command == 'backtrace') { | |
| 1410 this.backtraceRequest_(request, response); | |
| 1411 } else if (request.command == 'frame') { | |
| 1412 this.frameRequest_(request, response); | |
| 1413 } else if (request.command == 'scopes') { | |
| 1414 this.scopesRequest_(request, response); | |
| 1415 } else if (request.command == 'scope') { | |
| 1416 this.scopeRequest_(request, response); | |
| 1417 } else if (request.command == 'setVariableValue') { | |
| 1418 this.setVariableValueRequest_(request, response); | |
| 1419 } else if (request.command == 'evaluate') { | |
| 1420 this.evaluateRequest_(request, response); | |
| 1421 } else if (request.command == 'lookup') { | |
| 1422 this.lookupRequest_(request, response); | |
| 1423 } else if (request.command == 'references') { | |
| 1424 this.referencesRequest_(request, response); | |
| 1425 } else if (request.command == 'source') { | |
| 1426 this.sourceRequest_(request, response); | |
| 1427 } else if (request.command == 'scripts') { | |
| 1428 this.scriptsRequest_(request, response); | |
| 1429 } else if (request.command == 'threads') { | |
| 1430 this.threadsRequest_(request, response); | |
| 1431 } else if (request.command == 'suspend') { | |
| 1432 this.suspendRequest_(request, response); | |
| 1433 } else if (request.command == 'version') { | |
| 1434 this.versionRequest_(request, response); | |
| 1435 } else if (request.command == 'changelive') { | |
| 1436 this.changeLiveRequest_(request, response); | |
| 1437 } else if (request.command == 'restartframe') { | |
| 1438 this.restartFrameRequest_(request, response); | |
| 1439 } else if (request.command == 'flags') { | |
| 1440 this.debuggerFlagsRequest_(request, response); | |
| 1441 } else if (request.command == 'v8flags') { | |
| 1442 this.v8FlagsRequest_(request, response); | |
| 1443 | |
| 1444 // GC tools: | |
| 1445 } else if (request.command == 'gc') { | |
| 1446 this.gcRequest_(request, response); | |
| 1447 | |
| 1448 } else { | 1395 } else { |
| 1449 throw new Error('Unknown command "' + request.command + '" in request'); | 1396 throw new Error('Unknown command "' + request.command + '" in request'); |
| 1450 } | 1397 } |
| 1451 } catch (e) { | 1398 } catch (e) { |
| 1452 // If there is no response object created one (without command). | 1399 // If there is no response object created one (without command). |
| 1453 if (!response) { | 1400 if (!response) { |
| 1454 response = this.createResponse(); | 1401 response = this.createResponse(); |
| 1455 } | 1402 } |
| 1456 response.success = false; | 1403 response.success = false; |
| 1457 response.message = %ToString(e); | 1404 response.message = %ToString(e); |
| (...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2485 if (!type) type = 'all'; | 2432 if (!type) type = 'all'; |
| 2486 | 2433 |
| 2487 var before = %GetHeapUsage(); | 2434 var before = %GetHeapUsage(); |
| 2488 %CollectGarbage(type); | 2435 %CollectGarbage(type); |
| 2489 var after = %GetHeapUsage(); | 2436 var after = %GetHeapUsage(); |
| 2490 | 2437 |
| 2491 response.body = { "before": before, "after": after }; | 2438 response.body = { "before": before, "after": after }; |
| 2492 }; | 2439 }; |
| 2493 | 2440 |
| 2494 | 2441 |
| 2442 DebugCommandProcessor.prototype.dispatch_ = (function() { |
| 2443 var proto = DebugCommandProcessor.prototype; |
| 2444 return { |
| 2445 "continue": proto.continueRequest_, |
| 2446 "break" : proto.breakRequest_, |
| 2447 "setbreakpoint" : proto.setBreakPointRequest_, |
| 2448 "changebreakpoint": proto.changeBreakPointRequest_, |
| 2449 "clearbreakpoint": proto.clearBreakPointRequest_, |
| 2450 "clearbreakpointgroup": proto.clearBreakPointGroupRequest_, |
| 2451 "disconnect": proto.disconnectRequest_, |
| 2452 "setexceptionbreak": proto.setExceptionBreakRequest_, |
| 2453 "listbreakpoints": proto.listBreakpointsRequest_, |
| 2454 "backtrace": proto.backtraceRequest_, |
| 2455 "frame": proto.frameRequest_, |
| 2456 "scopes": proto.scopesRequest_, |
| 2457 "scope": proto.scopeRequest_, |
| 2458 "setvariablevalue": proto.setVariableValueRequest_, |
| 2459 "evaluate": proto.evaluateRequest_, |
| 2460 "lookup": proto.lookupRequest_, |
| 2461 "references": proto.referencesRequest_, |
| 2462 "source": proto.sourceRequest_, |
| 2463 "scripts": proto.scriptsRequest_, |
| 2464 "threads": proto.threadsRequest_, |
| 2465 "suspend": proto.suspendRequest_, |
| 2466 "version": proto.versionRequest_, |
| 2467 "changelive": proto.changeLiveRequest_, |
| 2468 "restartframe": proto.restartFrameRequest_, |
| 2469 "flags": proto.debuggerFlagsRequest_, |
| 2470 "v8flag": proto.v8FlagsRequest_, |
| 2471 "gc": proto.gcRequest_, |
| 2472 }; |
| 2473 })(); |
| 2474 |
| 2475 |
| 2495 // Check whether the previously processed command caused the VM to become | 2476 // Check whether the previously processed command caused the VM to become |
| 2496 // running. | 2477 // running. |
| 2497 DebugCommandProcessor.prototype.isRunning = function() { | 2478 DebugCommandProcessor.prototype.isRunning = function() { |
| 2498 return this.running_; | 2479 return this.running_; |
| 2499 }; | 2480 }; |
| 2500 | 2481 |
| 2501 | 2482 |
| 2502 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { | 2483 DebugCommandProcessor.prototype.systemBreak = function(cmd, args) { |
| 2503 return %SystemBreak(); | 2484 return %SystemBreak(); |
| 2504 }; | 2485 }; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2592 | 2573 |
| 2593 default: | 2574 default: |
| 2594 json = null; | 2575 json = null; |
| 2595 } | 2576 } |
| 2596 return json; | 2577 return json; |
| 2597 } | 2578 } |
| 2598 | 2579 |
| 2599 Debug.TestApi = { | 2580 Debug.TestApi = { |
| 2600 CommandProcessorResolveValue: DebugCommandProcessor.resolveValue_ | 2581 CommandProcessorResolveValue: DebugCommandProcessor.resolveValue_ |
| 2601 }; | 2582 }; |
| OLD | NEW |