⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug-delay.js.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
      }    }    // Get the stepaction argument.    if (stepaction) {      if (stepaction == 'in') {        action = Debug.StepAction.StepIn;      } else if (stepaction == 'min') {        action = Debug.StepAction.StepMin;      } else if (stepaction == 'next') {        action = Debug.StepAction.StepNext;      } else if (stepaction == 'out') {        action = Debug.StepAction.StepOut;      } else {        throw new Error('Invalid stepaction argument "' + stepaction + '".');      }    }    // Setup the VM for stepping.    this.exec_state_.prepareStep(action, count);  }  // VM should be running after executing this request.  response.running = true;};DebugCommandProcessor.prototype.breakRequest_ = function(request, response) {  // Ignore as break command does not do anything when broken.};DebugCommandProcessor.prototype.setBreakPointRequest_ =    function(request, response) {  // Check for legal request.  if (!request.arguments) {    response.failed('Missing arguments');    return;  }  // Pull out arguments.  var type = request.arguments.type;  var target = request.arguments.target;  var line = request.arguments.line;  var column = request.arguments.column;  var enabled = IS_UNDEFINED(request.arguments.enabled) ?      true : request.arguments.enabled;  var condition = request.arguments.condition;  var ignoreCount = request.arguments.ignoreCount;  // Check for legal arguments.  if (!type || !target) {    response.failed('Missing argument "type" or "target"');    return;  }  if (type != 'function' && type != 'script') {    response.failed('Illegal type "' + type + '"');    return;  }  // Either function or script break point.  var break_point_number;  if (type == 'function') {    // Handle function break point.    if (!IS_STRING(target)) {      response.failed('Argument "target" is not a string value');      return;    }    var f;    try {      // Find the function through a global evaluate.      f = this.exec_state_.evaluateGlobal(target).value();    } catch (e) {      response.failed('Error: "' + %ToString(e) +                      '" evaluating "' + target + '"');      return;    }    if (!IS_FUNCTION(f)) {      response.failed('"' + target + '" does not evaluate to a function');      return;    }    // Set function break point.    break_point_number = Debug.setBreakPoint(f, line, column, condition);  } else {    // set script break point.    break_point_number = Debug.setScriptBreakPoint(target,                                                   line, column,                                                   condition);  }  // Set additional break point properties.  var break_point = Debug.findBreakPoint(break_point_number);  if (ignoreCount) {    Debug.changeBreakPointIgnoreCount(break_point_number, ignoreCount);  }  if (!enabled) {    Debug.disableBreakPoint(break_point_number);  }  // Add the break point number to the response.  response.body = { type: type,                    breakpoint: break_point_number }  // Add break point information to the response.  if (break_point instanceof ScriptBreakPoint) {    response.body.type = 'script';    response.body.script_name = break_point.script_name();    response.body.line = break_point.line();    response.body.column = break_point.column();  } else {    response.body.type = 'function';  }};DebugCommandProcessor.prototype.changeBreakPointRequest_ = function(request, response) {  // Check for legal request.  if (!request.arguments) {    response.failed('Missing arguments');    return;  }  // Pull out arguments.  var break_point = %ToNumber(request.arguments.breakpoint);  var enabled = request.arguments.enabled;  var condition = request.arguments.condition;  var ignoreCount = request.arguments.ignoreCount;  // Check for legal arguments.  if (!break_point) {    response.failed('Missing argument "breakpoint"');    return;  }  // Change enabled state if supplied.  if (!IS_UNDEFINED(enabled)) {    if (enabled) {      Debug.enableBreakPoint(break_point);    } else {      Debug.disableBreakPoint(break_point);    }  }  // Change condition if supplied  if (!IS_UNDEFINED(condition)) {    Debug.changeBreakPointCondition(break_point, condition);  }  // Change ignore count if supplied  if (!IS_UNDEFINED(ignoreCount)) {    Debug.changeBreakPointIgnoreCount(break_point, ignoreCount);  }}DebugCommandProcessor.prototype.clearBreakPointRequest_ = function(request, response) {  // Check for legal request.  if (!request.arguments) {    response.failed('Missing arguments');    return;  }  // Pull out arguments.  var break_point = %ToNumber(request.arguments.breakpoint);  // Check for legal arguments.  if (!break_point) {    response.failed('Missing argument "breakpoint"');    return;  }  // Clear break point.  Debug.clearBreakPoint(break_point);}DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response) {  // Get the number of frames.  var total_frames = this.exec_state_.frameCount();  // Default frame range to include in backtrace.  var from_index = 0  var to_index = kDefaultBacktraceLength;  // Get the range from the arguments.  if (request.arguments) {    from_index = request.arguments.fromFrame;    if (from_index < 0) {      return response.failed('Invalid frame number');    }    to_index = request.arguments.toFrame;    if (to_index < 0) {      return response.failed('Invalid frame number');    }  }  // Adjust the index.  to_index = Math.min(total_frames, to_index);  if (to_index <= from_index) {    var error = 'Invalid frame range';    return response.failed(error);  }  // Create the response body.  var frames = [];  for (var i = from_index; i < to_index; i++) {    frames.push(this.exec_state_.frame(i));  }  response.body = {    fromFrame: from_index,    toFrame: to_index,    totalFrames: total_frames,    frames: frames  }};DebugCommandProcessor.prototype.backtracec = function(cmd, args) {  return this.exec_state_.cframesValue();};DebugCommandProcessor.prototype.frameRequest_ = function(request, response) {  // With no arguments just keep the selected frame.  if (request.arguments && request.arguments.number >= 0) {    this.exec_state_.setSelectedFrame(request.arguments.number);  }  response.body = this.exec_state_.frame();};DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) {  if (!request.arguments) {    return response.failed('Missing arguments');  }  // Pull out arguments.  var expression = request.arguments.expression;  var frame = request.arguments.frame;  var global = request.arguments.global;  var disable_break = request.arguments.disable_break;  // The expression argument could be an integer so we convert it to a  // string.  try {    expression = String(expression);  } catch(e) {    return response.failed('Failed to convert expression argument to string');  }  // Check for legal arguments.  if (!IS_UNDEFINED(frame) && global) {    return response.failed('Arguments "frame" and "global" are exclusive');  }  // Global evaluate.  if (global) {    // Evaluate in the global context.    response.body =        this.exec_state_.evaluateGlobal(expression), Boolean(disable_break);    return;  }  // Default value for disable_break is true.  if (IS_UNDEFINED(disable_break)) {    disable_break = true;  }  // Check whether a frame was specified.  if (!IS_UNDEFINED(frame)) {    var frame_number = %ToNumber(frame);    if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {      return response.failed('Invalid frame "' + frame + '"');    }    // Evaluate in the specified frame.    response.body = this.exec_state_.frame(frame_number).evaluate(        expression, Boolean(disable_break));    return;  } else {    // Evaluate in the selected frame.    response.body = this.exec_state_.frame().evaluate(        expression, Boolean(disable_break));    return;  }};DebugCommandProcessor.prototype.sourceRequest_ = function(request, response) {  var from_line;  var to_line;  var frame = this.exec_state_.frame();  if (request.arguments) {    // Pull out arguments.    from_line = request.arguments.fromLine;    to_line = request.arguments.toLine;    if (!IS_UNDEFINED(request.arguments.frame)) {      var frame_number = %ToNumber(request.arguments.frame);      if (frame_number < 0 || frame_number >= this.exec_state_.frameCount()) {        return response.failed('Invalid frame "' + frame + '"');      }      frame = this.exec_state_.frame(frame_number);    }  }  // Get the script selected.  var script = frame.func().script();  if (!script) {    return response.failed('No source');  }  // Get the source slice and fill it into the response.  var slice = script.sourceSlice(from_line, to_line);  if (!slice) {    return response.failed('Invalid line interval');  }  response.body = {};  response.body.source = slice.sourceText();  response.body.fromLine = slice.from_line;  response.body.toLine = slice.to_line;  response.body.fromPosition = slice.from_position;  response.body.toPosition = slice.to_position;  response.body.totalLines = script.lineCount();};DebugCommandProcessor.prototype.scriptsRequest_ = function(request, response) {  var types = ScriptTypeFlag(Debug.ScriptType.Normal);  if (request.arguments) {    // Pull out arguments.    if (!IS_UNDEFINED(request.arguments.types)) {      types = %ToNumber(request.arguments.types);      if (isNaN(types) || types < 0) {        return response.failed('Invalid types "' + request.arguments.types + '"');      }    }  }  // Collect all scripts in the heap.  var scripts = %DebugGetLoadedScripts();  response.body = [];  for (var i = 0; i < scripts.length; i++) {    if (types & ScriptTypeFlag(scripts[i].type)) {      var script = {};      if (scripts[i].name) {        script.name = scripts[i].name;      }      script.lineOffset = scripts[i].line_offset;      script.columnOffset = scripts[i].column_offset;      script.lineCount = scripts[i].lineCount();      script.sourceStart = scripts[i].source.substring(0, 80);      script.sourceLength = scripts[i].source.length;      script.type = scripts[i].type;      response.body.push(script);    }  }};// Check whether the JSON response indicate that the VM should be running.DebugCommandProcessor.prototype.isRunning = function(json_response) {  try {    // Convert the JSON string to an object.    response = %CompileString('(' + json_response + ')', 0, false)();    // Return whether VM should be running after this request.    return response.running;  } catch (e) {     return false;  }}DebugCommandProcessor.prototype.systemBreak = function(cmd, args) {  return %SystemBreak();};function NumberToHex8Str(n) {  var r = "";  for (var i = 0; i < 8; ++i) {    var c = hexCharArray[n & 0x0F];  // hexCharArray is defined in uri.js    r = c + r;    n = n >>> 4;  }  return r;};DebugCommandProcessor.prototype.formatCFrames = function(cframes_value) {  var result = "";  if (cframes_value == null || cframes_value.length == 0) {    result += "(stack empty)";  } else {    for (var i = 0; i < cframes_value.length; ++i) {      if (i != 0) result += "\n";      result += this.formatCFrame(cframes_value[i]);    }  }  return result;};DebugCommandProcessor.prototype.formatCFrame = function(cframe_value) {  var result = "";  result += "0x" + NumberToHex8Str(cframe_value.address);  if (!IS_UNDEFINED(cframe_value.text)) {    result += " " + cframe_value.text;  }  return result;}/** * Convert an Object to its JSON representation (see http://www.json.org/). * This implementation simply runs through all string property names and adds * each property to the JSON representation for some predefined types. For type * "object" the function calls itself recursively unless the object has the * function property "toJSONProtocol" in which case that is used. This is not * a general implementation but sufficient for the debugger. Note that circular * structures will cause infinite recursion. * @param {Object} object The object to format as JSON * @return {string} JSON formatted object value */function SimpleObjectToJSON_(object) {  var content = [];  for (var key in object) {    // Only consider string keys.    if (typeof key == 'string') {      var property_value = object[key];      // Format the value based on its type.      var property_value_json;      switch (typeof property_value) {        case 'object':          if (typeof property_value.toJSONProtocol == 'function') {            property_value_json = property_value.toJSONProtocol(true)          } else if (IS_ARRAY(property_value)){            property_value_json = SimpleArrayToJSON_(property_value);          } else {            property_value_json = SimpleObjectToJSON_(property_value);          }          break;        case 'boolean':          property_value_json = BooleanToJSON_(property_value);          break;        case 'number':          property_value_json = NumberToJSON_(property_value);          break;        case 'string':          property_value_json = StringToJSON_(property_value);          break;        default:          property_value_json = null;      }      // Add the property if relevant.      if (property_value_json) {        content.push(StringToJSON_(key) + ':' + property_value_json);      }    }  }  // Make JSON object representation.  return '{' + content.join(',') + '}';};/** * Convert an array to its JSON representation. This is a VERY simple * implementation just to support what is needed for the debugger. * @param {Array} arrya The array to format as JSON * @return {string} JSON formatted array value */function SimpleArrayToJSON_(array) {  // Make JSON array representation.  var json = '[';  for (var i = 0; i < array.length; i++) {    if (i != 0) {      json += ',';    }    var elem = array[i];    if (elem.toJSONProtocol) {      json += elem.toJSONProtocol(true)    } else if (IS_OBJECT(elem))  {      json += SimpleObjectToJSON_(elem);    } else if (IS_BOOLEAN(elem)) {      json += BooleanToJSON_(elem);    } else if (IS_NUMBER(elem)) {      json += NumberToJSON_(elem);    } else if (IS_STRING(elem)) {      json += StringToJSON_(elem);    } else {      json += elem;    }  }  json += ']';  return json;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -