~ubuntu-branches/ubuntu/saucy/nodejs/saucy-proposed

« back to all changes in this revision

Viewing changes to deps/v8/src/debug-debugger.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2006-2008 the V8 project authors. All rights reserved.
 
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
4
4
// met:
26
26
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
// Default number of frames to include in the response to backtrace request.
29
 
const kDefaultBacktraceLength = 10;
 
29
var kDefaultBacktraceLength = 10;
30
30
 
31
 
const Debug = {};
 
31
var Debug = {};
32
32
 
33
33
// Regular expression to skip "crud" at the beginning of a source line which is
34
34
// not really code. Currently the regular expression matches whitespace and
35
35
// comments.
36
 
const sourceLineBeginningSkip = /^(?:\s*(?:\/\*.*?\*\/)*)*/;
 
36
var sourceLineBeginningSkip = /^(?:\s*(?:\/\*.*?\*\/)*)*/;
37
37
 
38
38
// Debug events which can occour in the V8 JavaScript engine. These originate
39
39
// from the API include file debug.h.
286
286
  copy.condition_ = this.condition_;
287
287
  copy.ignoreCount_ = this.ignoreCount_;
288
288
  return copy;
289
 
}
 
289
};
290
290
 
291
291
 
292
292
ScriptBreakPoint.prototype.number = function() {
335
335
    locations.push(this.break_points_[i].actual_location);
336
336
  }
337
337
  return locations;
338
 
}
 
338
};
339
339
 
340
340
 
341
341
ScriptBreakPoint.prototype.update_positions = function(line, column) {
342
342
  this.line_ = line;
343
343
  this.column_ = column;
344
 
}
 
344
};
345
345
 
346
346
 
347
347
ScriptBreakPoint.prototype.hit_count = function() {
477
477
// break points set in this script.
478
478
function UpdateScriptBreakPoints(script) {
479
479
  for (var i = 0; i < script_break_points.length; i++) {
480
 
    if (script_break_points[i].type() == Debug.ScriptBreakPointType.ScriptName &&
481
 
        script_break_points[i].matchesScript(script)) {
482
 
      script_break_points[i].set(script);
 
480
    var break_point = script_break_points[i];
 
481
    if ((break_point.type() == Debug.ScriptBreakPointType.ScriptName ||
 
482
         break_point.type() == Debug.ScriptBreakPointType.ScriptRegExp) &&
 
483
        break_point.matchesScript(script)) {
 
484
      break_point.set(script);
483
485
    }
484
486
  }
485
487
}
585
587
  var script = %FunctionGetScript(func);
586
588
  var script_offset = %FunctionGetScriptSourcePosition(func);
587
589
  return script.locationFromLine(opt_line, opt_column, script_offset);
588
 
}
 
590
};
589
591
 
590
592
 
591
593
// Returns the character position in a script based on a line number and an
593
595
Debug.findScriptSourcePosition = function(script, opt_line, opt_column) {
594
596
  var location = script.locationFromLine(opt_line, opt_column);
595
597
  return location ? location.position : null;
596
 
}
 
598
};
597
599
 
598
600
 
599
601
Debug.findBreakPoint = function(break_point_number, remove) {
627
629
    }
628
630
  }
629
631
  return [];
630
 
}
 
632
};
631
633
 
632
634
Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) {
633
635
  if (!IS_FUNCTION(func)) throw new Error('Parameters have wrong types.');
677
679
{
678
680
  break_point = MakeBreakPoint(position);
679
681
  break_point.setCondition(condition);
680
 
  if (!enabled)
 
682
  if (!enabled) {
681
683
    break_point.disable();
 
684
  }
682
685
  var scripts = this.scripts();
683
686
  for (var i = 0; i < scripts.length; i++) {
684
687
    if (script_id == scripts[i].id) {
771
774
    }
772
775
  }
773
776
  return script_break_point;
774
 
}
 
777
};
775
778
 
776
779
 
777
780
// Sets a breakpoint in a script identified through id or name at the
799
802
  }
800
803
 
801
804
  return script_break_point.number();
802
 
}
 
805
};
803
806
 
804
807
 
805
808
Debug.setScriptBreakPointById = function(script_id,
808
811
  return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
809
812
                                  script_id, opt_line, opt_column,
810
813
                                  opt_condition, opt_groupId);
811
 
}
 
814
};
812
815
 
813
816
 
814
817
Debug.setScriptBreakPointByName = function(script_name,
817
820
  return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptName,
818
821
                                  script_name, opt_line, opt_column,
819
822
                                  opt_condition, opt_groupId);
820
 
}
 
823
};
821
824
 
822
825
 
823
826
Debug.setScriptBreakPointByRegExp = function(script_regexp,
826
829
  return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptRegExp,
827
830
                                  script_regexp, opt_line, opt_column,
828
831
                                  opt_condition, opt_groupId);
829
 
}
 
832
};
830
833
 
831
834
 
832
835
Debug.enableScriptBreakPoint = function(break_point_number) {
841
844
};
842
845
 
843
846
 
844
 
Debug.changeScriptBreakPointCondition = function(break_point_number, condition) {
 
847
Debug.changeScriptBreakPointCondition = function(
 
848
    break_point_number, condition) {
845
849
  var script_break_point = this.findScriptBreakPoint(break_point_number, false);
846
850
  script_break_point.setCondition(condition);
847
851
};
848
852
 
849
853
 
850
 
Debug.changeScriptBreakPointIgnoreCount = function(break_point_number, ignoreCount) {
 
854
Debug.changeScriptBreakPointIgnoreCount = function(
 
855
    break_point_number, ignoreCount) {
851
856
  if (ignoreCount < 0) {
852
857
    throw new Error('Invalid argument');
853
858
  }
858
863
 
859
864
Debug.scriptBreakPoints = function() {
860
865
  return script_break_points;
861
 
}
 
866
};
862
867
 
863
868
 
864
869
Debug.clearStepping = function() {
865
870
  %ClearStepping();
866
 
}
 
871
};
867
872
 
868
873
Debug.setBreakOnException = function() {
869
874
  return %ChangeBreakOnException(Debug.ExceptionBreak.Caught, true);
940
945
  var count = opt_count ? %ToNumber(opt_count) : 1;
941
946
 
942
947
  return %PrepareStep(this.break_id, action, count);
943
 
}
 
948
};
944
949
 
945
950
ExecutionState.prototype.evaluateGlobal = function(source, disable_break,
946
951
    opt_additional_context) {
960
965
ExecutionState.prototype.frame = function(opt_index) {
961
966
  // If no index supplied return the selected frame.
962
967
  if (opt_index == null) opt_index = this.selected_frame;
963
 
  if (opt_index < 0 || opt_index >= this.frameCount())
 
968
  if (opt_index < 0 || opt_index >= this.frameCount()) {
964
969
    throw new Error('Illegal frame index.');
 
970
  }
965
971
  return new FrameMirror(this.break_id, opt_index);
966
972
};
967
973
 
1088
1094
 
1089
1095
ExceptionEvent.prototype.exception = function() {
1090
1096
  return this.exception_;
1091
 
}
 
1097
};
1092
1098
 
1093
1099
 
1094
1100
ExceptionEvent.prototype.uncaught = function() {
1095
1101
  return this.uncaught_;
1096
 
}
 
1102
};
1097
1103
 
1098
1104
 
1099
1105
ExceptionEvent.prototype.func = function() {
1185
1191
  o.body.script = this.script_;
1186
1192
 
1187
1193
  return o.toJSONProtocol();
1188
 
}
 
1194
};
1189
1195
 
1190
1196
 
1191
1197
function MakeNewFunctionEvent(func) {
1241
1247
  o.body = {};
1242
1248
  o.body.script = { id: this.id() };
1243
1249
  return o.toJSONProtocol();
1244
 
}
 
1250
};
1245
1251
 
1246
1252
 
1247
1253
function MakeScriptObject_(script, include_source) {
1258
1264
    o.source = script.source();
1259
1265
  }
1260
1266
  return o;
1261
 
};
 
1267
}
1262
1268
 
1263
1269
 
1264
1270
function DebugCommandProcessor(exec_state, opt_is_running) {
1265
1271
  this.exec_state_ = exec_state;
1266
1272
  this.running_ = opt_is_running || false;
1267
 
};
 
1273
}
1268
1274
 
1269
1275
 
1270
1276
DebugCommandProcessor.prototype.processDebugRequest = function (request) {
1271
1277
  return this.processDebugJSONRequest(request);
1272
 
}
 
1278
};
1273
1279
 
1274
1280
 
1275
1281
function ProtocolMessage(request) {
1297
1303
    this.options_ = {};
1298
1304
  }
1299
1305
  this.options_[name] = value;
1300
 
}
 
1306
};
1301
1307
 
1302
1308
 
1303
1309
ProtocolMessage.prototype.failed = function(message) {
1304
1310
  this.success = false;
1305
1311
  this.message = message;
1306
 
}
 
1312
};
1307
1313
 
1308
1314
 
1309
1315
ProtocolMessage.prototype.toJSONProtocol = function() {
1351
1357
  }
1352
1358
  json.running = this.running;
1353
1359
  return JSON.stringify(json);
1354
 
}
 
1360
};
1355
1361
 
1356
1362
 
1357
1363
DebugCommandProcessor.prototype.createResponse = function(request) {
1359
1365
};
1360
1366
 
1361
1367
 
1362
 
DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request) {
 
1368
DebugCommandProcessor.prototype.processDebugJSONRequest = function(
 
1369
    json_request) {
1363
1370
  var request;  // Current request.
1364
1371
  var response;  // Generated response.
1365
1372
  try {
1420
1427
        this.scopesRequest_(request, response);
1421
1428
      } else if (request.command == 'scope') {
1422
1429
        this.scopeRequest_(request, response);
 
1430
      } else if (request.command == 'setVariableValue') {
 
1431
        this.setVariableValueRequest_(request, response);
1423
1432
      } else if (request.command == 'evaluate') {
1424
1433
        this.evaluateRequest_(request, response);
1425
1434
      } else if (lol_is_enabled && request.command == 'getobj') {
1442
1451
        this.profileRequest_(request, response);
1443
1452
      } else if (request.command == 'changelive') {
1444
1453
        this.changeLiveRequest_(request, response);
 
1454
      } else if (request.command == 'restartframe') {
 
1455
        this.restartFrameRequest_(request, response);
1445
1456
      } else if (request.command == 'flags') {
1446
1457
        this.debuggerFlagsRequest_(request, response);
1447
1458
      } else if (request.command == 'v8flags') {
1541
1552
      }
1542
1553
    }
1543
1554
 
1544
 
    // Setup the VM for stepping.
 
1555
    // Set up the VM for stepping.
1545
1556
    this.exec_state_.prepareStep(action, count);
1546
1557
  }
1547
1558
 
1646
1657
 
1647
1658
  // Add the break point number to the response.
1648
1659
  response.body = { type: type,
1649
 
                    breakpoint: break_point_number }
 
1660
                    breakpoint: break_point_number };
1650
1661
 
1651
1662
  // Add break point information to the response.
1652
1663
  if (break_point instanceof ScriptBreakPoint) {
1660
1671
      response.body.type = 'scriptRegExp';
1661
1672
      response.body.script_regexp = break_point.script_regexp_object().source;
1662
1673
    } else {
1663
 
      throw new Error("Internal error: Unexpected breakpoint type: " + break_point.type());
 
1674
      throw new Error("Internal error: Unexpected breakpoint type: " +
 
1675
                      break_point.type());
1664
1676
    }
1665
1677
    response.body.line = break_point.line();
1666
1678
    response.body.column = break_point.column();
1672
1684
};
1673
1685
 
1674
1686
 
1675
 
DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(request, response) {
 
1687
DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(
 
1688
    request, response) {
1676
1689
  // Check for legal request.
1677
1690
  if (!request.arguments) {
1678
1691
    response.failed('Missing arguments');
1709
1722
  if (!IS_UNDEFINED(ignoreCount)) {
1710
1723
    Debug.changeBreakPointIgnoreCount(break_point, ignoreCount);
1711
1724
  }
1712
 
}
1713
 
 
1714
 
 
1715
 
DebugCommandProcessor.prototype.clearBreakPointGroupRequest_ = function(request, response) {
 
1725
};
 
1726
 
 
1727
 
 
1728
DebugCommandProcessor.prototype.clearBreakPointGroupRequest_ = function(
 
1729
    request, response) {
1716
1730
  // Check for legal request.
1717
1731
  if (!request.arguments) {
1718
1732
    response.failed('Missing arguments');
1743
1757
 
1744
1758
  // Add the cleared break point numbers to the response.
1745
1759
  response.body = { breakpoints: cleared_break_points };
1746
 
}
1747
 
 
1748
 
 
1749
 
DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(request, response) {
 
1760
};
 
1761
 
 
1762
 
 
1763
DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(
 
1764
    request, response) {
1750
1765
  // Check for legal request.
1751
1766
  if (!request.arguments) {
1752
1767
    response.failed('Missing arguments');
1766
1781
  Debug.clearBreakPoint(break_point);
1767
1782
 
1768
1783
  // Add the cleared break point number to the response.
1769
 
  response.body = { breakpoint: break_point }
1770
 
}
1771
 
 
1772
 
 
1773
 
DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(request, response) {
 
1784
  response.body = { breakpoint: break_point };
 
1785
};
 
1786
 
 
1787
 
 
1788
DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(
 
1789
    request, response) {
1774
1790
  var array = [];
1775
1791
  for (var i = 0; i < script_break_points.length; i++) {
1776
1792
    var break_point = script_break_points[i];
1785
1801
      condition: break_point.condition(),
1786
1802
      ignoreCount: break_point.ignoreCount(),
1787
1803
      actual_locations: break_point.actual_locations()
1788
 
    }
 
1804
    };
1789
1805
 
1790
1806
    if (break_point.type() == Debug.ScriptBreakPointType.ScriptId) {
1791
1807
      description.type = 'scriptId';
1797
1813
      description.type = 'scriptRegExp';
1798
1814
      description.script_regexp = break_point.script_regexp_object().source;
1799
1815
    } else {
1800
 
      throw new Error("Internal error: Unexpected breakpoint type: " + break_point.type());
 
1816
      throw new Error("Internal error: Unexpected breakpoint type: " +
 
1817
                      break_point.type());
1801
1818
    }
1802
1819
    array.push(description);
1803
1820
  }
1806
1823
    breakpoints: array,
1807
1824
    breakOnExceptions: Debug.isBreakOnException(),
1808
1825
    breakOnUncaughtExceptions: Debug.isBreakOnUncaughtException()
1809
 
  }
1810
 
}
 
1826
  };
 
1827
};
1811
1828
 
1812
1829
 
1813
1830
DebugCommandProcessor.prototype.disconnectRequest_ =
1814
1831
    function(request, response) {
1815
1832
  Debug.disableAllBreakPoints();
1816
1833
  this.continueRequest_(request, response);
1817
 
}
 
1834
};
1818
1835
 
1819
1836
 
1820
1837
DebugCommandProcessor.prototype.setExceptionBreakRequest_ =
1859
1876
 
1860
1877
  // Add the cleared break point number to the response.
1861
1878
  response.body = { 'type': type, 'enabled': enabled };
1862
 
}
1863
 
 
1864
 
 
1865
 
DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response) {
 
1879
};
 
1880
 
 
1881
 
 
1882
DebugCommandProcessor.prototype.backtraceRequest_ = function(
 
1883
    request, response) {
1866
1884
  // Get the number of frames.
1867
1885
  var total_frames = this.exec_state_.frameCount();
1868
1886
 
1870
1888
  if (total_frames == 0) {
1871
1889
    response.body = {
1872
1890
      totalFrames: total_frames
1873
 
    }
 
1891
    };
1874
1892
    return;
1875
1893
  }
1876
1894
 
1877
1895
  // Default frame range to include in backtrace.
1878
 
  var from_index = 0
 
1896
  var from_index = 0;
1879
1897
  var to_index = kDefaultBacktraceLength;
1880
1898
 
1881
1899
  // Get the range from the arguments.
1888
1906
    }
1889
1907
    if (request.arguments.bottom) {
1890
1908
      var tmp_index = total_frames - from_index;
1891
 
      from_index = total_frames - to_index
 
1909
      from_index = total_frames - to_index;
1892
1910
      to_index = tmp_index;
1893
1911
    }
1894
1912
    if (from_index < 0 || to_index < 0) {
1914
1932
    toFrame: to_index,
1915
1933
    totalFrames: total_frames,
1916
1934
    frames: frames
1917
 
  }
 
1935
  };
1918
1936
};
1919
1937
 
1920
1938
 
1937
1955
};
1938
1956
 
1939
1957
 
1940
 
DebugCommandProcessor.prototype.frameForScopeRequest_ = function(request) {
1941
 
  // Get the frame for which the scope or scopes are requested. With no frameNumber
1942
 
  // argument use the currently selected frame.
1943
 
  if (request.arguments && !IS_UNDEFINED(request.arguments.frameNumber)) {
1944
 
    frame_index = request.arguments.frameNumber;
 
1958
DebugCommandProcessor.prototype.resolveFrameFromScopeDescription_ =
 
1959
    function(scope_description) {
 
1960
  // Get the frame for which the scope or scopes are requested.
 
1961
  // With no frameNumber argument use the currently selected frame.
 
1962
  if (scope_description && !IS_UNDEFINED(scope_description.frameNumber)) {
 
1963
    frame_index = scope_description.frameNumber;
1945
1964
    if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) {
1946
 
      return response.failed('Invalid frame number');
 
1965
      throw new Error('Invalid frame number');
1947
1966
    }
1948
1967
    return this.exec_state_.frame(frame_index);
1949
1968
  } else {
1950
1969
    return this.exec_state_.frame();
1951
1970
  }
 
1971
};
 
1972
 
 
1973
 
 
1974
// Gets scope host object from request. It is either a function
 
1975
// ('functionHandle' argument must be specified) or a stack frame
 
1976
// ('frameNumber' may be specified and the current frame is taken by default).
 
1977
DebugCommandProcessor.prototype.resolveScopeHolder_ =
 
1978
    function(scope_description) {
 
1979
  if (scope_description && "functionHandle" in scope_description) {
 
1980
    if (!IS_NUMBER(scope_description.functionHandle)) {
 
1981
      throw new Error('Function handle must be a number');
 
1982
    }
 
1983
    var function_mirror = LookupMirror(scope_description.functionHandle);
 
1984
    if (!function_mirror) {
 
1985
      throw new Error('Failed to find function object by handle');
 
1986
    }
 
1987
    if (!function_mirror.isFunction()) {
 
1988
      throw new Error('Value of non-function type is found by handle');
 
1989
    }
 
1990
    return function_mirror;
 
1991
  } else {
 
1992
    // No frames no scopes.
 
1993
    if (this.exec_state_.frameCount() == 0) {
 
1994
      throw new Error('No scopes');
 
1995
    }
 
1996
 
 
1997
    // Get the frame for which the scopes are requested.
 
1998
    var frame = this.resolveFrameFromScopeDescription_(scope_description);
 
1999
    return frame;
 
2000
  }
1952
2001
}
1953
2002
 
1954
2003
 
1955
2004
DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) {
1956
 
  // No frames no scopes.
1957
 
  if (this.exec_state_.frameCount() == 0) {
1958
 
    return response.failed('No scopes');
1959
 
  }
1960
 
 
1961
 
  // Get the frame for which the scopes are requested.
1962
 
  var frame = this.frameForScopeRequest_(request);
1963
 
 
1964
 
  // Fill all scopes for this frame.
1965
 
  var total_scopes = frame.scopeCount();
 
2005
  var scope_holder = this.resolveScopeHolder_(request.arguments);
 
2006
 
 
2007
  // Fill all scopes for this frame or function.
 
2008
  var total_scopes = scope_holder.scopeCount();
1966
2009
  var scopes = [];
1967
2010
  for (var i = 0; i < total_scopes; i++) {
1968
 
    scopes.push(frame.scope(i));
 
2011
    scopes.push(scope_holder.scope(i));
1969
2012
  }
1970
2013
  response.body = {
1971
2014
    fromScope: 0,
1972
2015
    toScope: total_scopes,
1973
2016
    totalScopes: total_scopes,
1974
2017
    scopes: scopes
1975
 
  }
 
2018
  };
1976
2019
};
1977
2020
 
1978
2021
 
1979
2022
DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) {
1980
 
  // No frames no scopes.
1981
 
  if (this.exec_state_.frameCount() == 0) {
1982
 
    return response.failed('No scopes');
1983
 
  }
1984
 
 
1985
 
  // Get the frame for which the scope is requested.
1986
 
  var frame = this.frameForScopeRequest_(request);
 
2023
  // Get the frame or function for which the scope is requested.
 
2024
  var scope_holder = this.resolveScopeHolder_(request.arguments);
1987
2025
 
1988
2026
  // With no scope argument just return top scope.
1989
2027
  var scope_index = 0;
1990
2028
  if (request.arguments && !IS_UNDEFINED(request.arguments.number)) {
1991
2029
    scope_index = %ToNumber(request.arguments.number);
1992
 
    if (scope_index < 0 || frame.scopeCount() <= scope_index) {
 
2030
    if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) {
1993
2031
      return response.failed('Invalid scope number');
1994
2032
    }
1995
2033
  }
1996
2034
 
1997
 
  response.body = frame.scope(scope_index);
 
2035
  response.body = scope_holder.scope(scope_index);
 
2036
};
 
2037
 
 
2038
 
 
2039
// Reads value from protocol description. Description may be in form of type
 
2040
// (for singletons), raw value (primitive types supported in JSON),
 
2041
// string value description plus type (for primitive values) or handle id.
 
2042
// Returns raw value or throws exception.
 
2043
DebugCommandProcessor.resolveValue_ = function(value_description) {
 
2044
  if ("handle" in value_description) {
 
2045
    var value_mirror = LookupMirror(value_description.handle);
 
2046
    if (!value_mirror) {
 
2047
      throw new Error("Failed to resolve value by handle, ' #" +
 
2048
          mapping.handle + "# not found");
 
2049
    }
 
2050
    return value_mirror.value();
 
2051
  } else if ("stringDescription" in value_description) {
 
2052
    if (value_description.type == BOOLEAN_TYPE) {
 
2053
      return Boolean(value_description.stringDescription);
 
2054
    } else if (value_description.type == NUMBER_TYPE) {
 
2055
      return Number(value_description.stringDescription);
 
2056
    } if (value_description.type == STRING_TYPE) {
 
2057
      return String(value_description.stringDescription);
 
2058
    } else {
 
2059
      throw new Error("Unknown type");
 
2060
    }
 
2061
  } else if ("value" in value_description) {
 
2062
    return value_description.value;
 
2063
  } else if (value_description.type == UNDEFINED_TYPE) {
 
2064
    return void 0;
 
2065
  } else if (value_description.type == NULL_TYPE) {
 
2066
    return null;
 
2067
  } else {
 
2068
    throw new Error("Failed to parse value description");
 
2069
  }
 
2070
};
 
2071
 
 
2072
 
 
2073
DebugCommandProcessor.prototype.setVariableValueRequest_ =
 
2074
    function(request, response) {
 
2075
  if (!request.arguments) {
 
2076
    response.failed('Missing arguments');
 
2077
    return;
 
2078
  }
 
2079
 
 
2080
  if (IS_UNDEFINED(request.arguments.name)) {
 
2081
    response.failed('Missing variable name');
 
2082
  }
 
2083
  var variable_name = request.arguments.name;
 
2084
 
 
2085
  var scope_description = request.arguments.scope;
 
2086
 
 
2087
  // Get the frame or function for which the scope is requested.
 
2088
  var scope_holder = this.resolveScopeHolder_(scope_description);
 
2089
 
 
2090
  if (IS_UNDEFINED(scope_description.number)) {
 
2091
    response.failed('Missing scope number');
 
2092
  }
 
2093
  var scope_index = %ToNumber(scope_description.number);
 
2094
 
 
2095
  var scope = scope_holder.scope(scope_index);
 
2096
 
 
2097
  var new_value =
 
2098
      DebugCommandProcessor.resolveValue_(request.arguments.newValue);
 
2099
 
 
2100
  scope.setVariableValue(variable_name, new_value);
 
2101
 
 
2102
  var new_value_mirror = MakeMirror(new_value);
 
2103
 
 
2104
  response.body = {
 
2105
    newValue: new_value_mirror
 
2106
  };
1998
2107
};
1999
2108
 
2000
2109
 
2043
2152
 
2044
2153
  // Global evaluate.
2045
2154
  if (global) {
2046
 
    // Evaluate in the global context.
 
2155
    // Evaluate in the native context.
2047
2156
    response.body = this.exec_state_.evaluateGlobal(
2048
2157
        expression, Boolean(disable_break), additional_context_object);
2049
2158
    return;
2217
2326
    if (!IS_UNDEFINED(request.arguments.types)) {
2218
2327
      types = %ToNumber(request.arguments.types);
2219
2328
      if (isNaN(types) || types < 0) {
2220
 
        return response.failed('Invalid types "' + request.arguments.types + '"');
 
2329
        return response.failed('Invalid types "' +
 
2330
                               request.arguments.types + '"');
2221
2331
      }
2222
2332
    }
2223
2333
 
2286
2396
    var details = %GetThreadDetails(this.exec_state_.break_id, i);
2287
2397
    var thread_info = { current: details[0],
2288
2398
                        id: details[1]
2289
 
                      }
 
2399
                      };
2290
2400
    threads.push(thread_info);
2291
2401
  }
2292
2402
 
2294
2404
  response.body = {
2295
2405
    totalThreads: total_threads,
2296
2406
    threads: threads
2297
 
  }
 
2407
  };
2298
2408
};
2299
2409
 
2300
2410
 
2306
2416
DebugCommandProcessor.prototype.versionRequest_ = function(request, response) {
2307
2417
  response.body = {
2308
2418
    V8Version: %GetV8Version()
2309
 
  }
 
2419
  };
2310
2420
};
2311
2421
 
2312
2422
 
2322
2432
};
2323
2433
 
2324
2434
 
2325
 
DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response) {
2326
 
  if (!Debug.LiveEdit) {
2327
 
    return response.failed('LiveEdit feature is not supported');
2328
 
  }
 
2435
DebugCommandProcessor.prototype.changeLiveRequest_ = function(
 
2436
    request, response) {
2329
2437
  if (!request.arguments) {
2330
2438
    return response.failed('Missing arguments');
2331
2439
  }
2363
2471
};
2364
2472
 
2365
2473
 
 
2474
DebugCommandProcessor.prototype.restartFrameRequest_ = function(
 
2475
    request, response) {
 
2476
  if (!request.arguments) {
 
2477
    return response.failed('Missing arguments');
 
2478
  }
 
2479
  var frame = request.arguments.frame;
 
2480
 
 
2481
  // No frames to evaluate in frame.
 
2482
  if (this.exec_state_.frameCount() == 0) {
 
2483
    return response.failed('No frames');
 
2484
  }
 
2485
 
 
2486
  var frame_mirror;
 
2487
  // Check whether a frame was specified.
 
2488
  if (!IS_UNDEFINED(frame)) {
 
2489
    var frame_number = %ToNumber(frame);
 
2490
    if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {
 
2491
      return response.failed('Invalid frame "' + frame + '"');
 
2492
    }
 
2493
    // Restart specified frame.
 
2494
    frame_mirror = this.exec_state_.frame(frame_number);
 
2495
  } else {
 
2496
    // Restart selected frame.
 
2497
    frame_mirror = this.exec_state_.frame();
 
2498
  }
 
2499
 
 
2500
  var result_description = Debug.LiveEdit.RestartFrame(frame_mirror);
 
2501
  response.body = {result: result_description};
 
2502
};
 
2503
 
 
2504
 
2366
2505
DebugCommandProcessor.prototype.debuggerFlagsRequest_ = function(request,
2367
2506
                                                                 response) {
2368
2507
  // Check for legal request.
2393
2532
      response.body.flags.push({ name: name, value: value });
2394
2533
    }
2395
2534
  }
2396
 
}
 
2535
};
2397
2536
 
2398
2537
 
2399
2538
DebugCommandProcessor.prototype.v8FlagsRequest_ = function(request, response) {
2499
2638
// running.
2500
2639
DebugCommandProcessor.prototype.isRunning = function() {
2501
2640
  return this.running_;
2502
 
}
 
2641
};
2503
2642
 
2504
2643
 
2505
2644
DebugCommandProcessor.prototype.systemBreak = function(cmd, args) {
2515
2654
    n = n >>> 4;
2516
2655
  }
2517
2656
  return r;
2518
 
};
 
2657
}
2519
2658
 
2520
2659
 
2521
2660
/**
2591
2730
    case 'string':
2592
2731
    case 'number':
2593
2732
      json = value;
2594
 
      break
 
2733
      break;
2595
2734
 
2596
2735
    default:
2597
2736
      json = null;
2598
2737
  }
2599
2738
  return json;
2600
2739
}
 
2740
 
 
2741
Debug.TestApi = {
 
2742
  CommandProcessorResolveValue: DebugCommandProcessor.resolveValue_
 
2743
};