devtools.DebuggerAgent = function()
{
RemoteDebuggerAgent.debuggerOutput = this.handleDebuggerOutput_.bind(this);
RemoteDebuggerAgent.setContextId = this.setContextId_.bind(this);
this.contextId_ = null;
this.parsedScripts_ = null;
this.requestNumberToBreakpointInfo_ = null;
this.callFrames_ = [];
this.pauseOnExceptions_ = false;
this.requestSeqToCallback_ = null;
this.scriptsPanelInitialized_ = false;
this.requestScriptsWhenContextIdSet_ = false;
this.waitingForInitialScriptsResponse_ = false;
this.pendingBacktraceResponseHandler_ = null;
this.urlToBreakpoints_ = {};
this.currentExceptionMessage_ = null;
this.breakpointsActivated_ = true;
};
devtools.DebuggerAgent.ScopeType = {
Global: 0,
Local: 1,
With: 2,
Closure: 3,
Catch: 4
};
devtools.DebuggerAgent.prototype.reset = function()
{
this.contextId_ = null;
this.requestScriptsWhenContextIdSet_ = false;
this.waitingForInitialScriptsResponse_ = false;
this.parsedScripts_ = {};
this.requestNumberToBreakpointInfo_ = {};
this.callFrames_ = [];
this.requestSeqToCallback_ = {};
};
devtools.DebuggerAgent.prototype.initUI = function()
{
if (this.scriptsPanelInitialized_)
return;
this.scriptsPanelInitialized_ = true;
if (this.contextId_) {
for (var scriptId in this.parsedScripts_) {
var script = this.parsedScripts_[scriptId];
WebInspector.parsedScriptSource(scriptId, script.getUrl(), undefined , script.getLineOffset() + 1);
this.restoreBreakpoints_(scriptId, script.getUrl());
}
return;
}
this.waitingForInitialScriptsResponse_ = true;
RemoteDebuggerAgent.getContextId();
this.requestScriptsWhenContextIdSet_ = true;
};
devtools.DebuggerAgent.prototype.resolveScriptSource = function(scriptId, callback)
{
var script = this.parsedScripts_[scriptId];
if (!script || script.isUnresolved()) {
callback(null);
return;
}
var cmd = new devtools.DebugCommand("scripts", {
"ids": [scriptId],
"includeSource": true
});
devtools.DebuggerAgent.sendCommand_(cmd);
RemoteDebuggerAgent.processDebugCommands();
var self = this;
this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) {
if (msg.isSuccess()) {
var scriptJson = msg.getBody()[0];
if (scriptJson) {
script.source = scriptJson.source;
callback(scriptJson.source);
}
else
callback(null);
} else
callback(null);
};
};
devtools.DebuggerAgent.prototype.pauseExecution = function()
{
RemoteDebuggerCommandExecutor.DebuggerPauseScript();
};
devtools.DebuggerAgent.prototype.addBreakpoint = function(sourceId, line, enabled, condition)
{
var script = this.parsedScripts_[sourceId];
if (!script)
return;
line = devtools.DebuggerAgent.webkitToV8LineNumber_(line);
var commandArguments;
if (script.getUrl()) {
var breakpoints = this.urlToBreakpoints_[script.getUrl()];
if (breakpoints && breakpoints[line])
return;
if (!breakpoints) {
breakpoints = {};
this.urlToBreakpoints_[script.getUrl()] = breakpoints;
}
var breakpointInfo = new devtools.BreakpointInfo(line, enabled, condition);
breakpoints[line] = breakpointInfo;
commandArguments = {
"groupId": this.contextId_,
"type": "script",
"target": script.getUrl(),
"line": line,
"condition": condition
};
} else {
var breakpointInfo = script.getBreakpointInfo(line);
if (breakpointInfo)
return;
breakpointInfo = new devtools.BreakpointInfo(line, enabled, condition);
script.addBreakpointInfo(breakpointInfo);
commandArguments = {
"groupId": this.contextId_,
"type": "scriptId",
"target": sourceId,
"line": line,
"condition": condition
};
}
if (!enabled)
return;
var cmd = new devtools.DebugCommand("setbreakpoint", commandArguments);
this.requestNumberToBreakpointInfo_[cmd.getSequenceNumber()] = breakpointInfo;
devtools.DebuggerAgent.sendCommand_(cmd);
RemoteDebuggerAgent.processDebugCommands();
};
devtools.DebuggerAgent.prototype.editScriptSource = function(sourceId, newContent, callback)
{
var commandArguments = {
"script_id": sourceId,
"new_source": newContent
};
var cmd = new devtools.DebugCommand("changelive", commandArguments);
devtools.DebuggerAgent.sendCommand_(cmd);
this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) {
if (!msg.isSuccess())
WebInspector.log("Unable to modify source code within given scope. Only function bodies are editable at the moment.", WebInspector.ConsoleMessage.MessageLevel.Warning);
this.resolveScriptSource(sourceId, callback);
if (WebInspector.panels.scripts.paused)
this.requestBacktrace_();
}.bind(this);
RemoteDebuggerAgent.processDebugCommands();
};
devtools.DebuggerAgent.prototype.removeBreakpoint = function(sourceId, line)
{
var script = this.parsedScripts_[sourceId];
if (!script)
return;
line = devtools.DebuggerAgent.webkitToV8LineNumber_(line);
var breakpointInfo;
if (script.getUrl()) {
var breakpoints = this.urlToBreakpoints_[script.getUrl()];
if (!breakpoints)
return;
breakpointInfo = breakpoints[line];
delete breakpoints[line];
} else {
breakpointInfo = script.getBreakpointInfo(line);
if (breakpointInfo)
script.removeBreakpointInfo(breakpointInfo);
}
if (!breakpointInfo)
return;
breakpointInfo.markAsRemoved();
var id = breakpointInfo.getV8Id();
if (id !== -1) {
this.requestClearBreakpoint_(id);
}
};
devtools.DebuggerAgent.prototype.setBreakpointsActivated = function(activated)
{
this.breakpointsActivated_ = activated;
};
devtools.DebuggerAgent.prototype.stepIntoStatement = function()
{
this.stepCommand_("in");
};
devtools.DebuggerAgent.prototype.stepOutOfFunction = function()
{
this.stepCommand_("out");
};
devtools.DebuggerAgent.prototype.stepOverStatement = function()
{
this.stepCommand_("next");
};
devtools.DebuggerAgent.prototype.resumeExecution = function()
{
this.clearExceptionMessage_();
var cmd = new devtools.DebugCommand("continue");
devtools.DebuggerAgent.sendCommand_(cmd);
};
devtools.DebuggerAgent.prototype.createExceptionMessage_ = function(url, line, message)
{
this.currentExceptionMessage_ = new WebInspector.ConsoleMessage(
WebInspector.ConsoleMessage.MessageSource.JS,
WebInspector.ConsoleMessage.MessageType.Log,
WebInspector.ConsoleMessage.MessageLevel.Error,
line,
url,
0 ,
1 ,
"[Exception] " + message);
};
devtools.DebuggerAgent.prototype.showPendingExceptionMessage_ = function()
{
if (!this.currentExceptionMessage_)
return;
var msg = this.currentExceptionMessage_;
var resource = WebInspector.resourceURLMap[msg.url];
if (resource) {
msg.resource = resource;
WebInspector.panels.resources.addMessageToResource(resource, msg);
} else
this.currentExceptionMessage_ = null;
};
devtools.DebuggerAgent.prototype.clearExceptionMessage_ = function()
{
if (this.currentExceptionMessage_) {
var messageElement = this.currentExceptionMessage_._resourceMessageLineElement;
var bubble = messageElement.parentElement;
bubble.removeChild(messageElement);
if (!bubble.firstChild) {
bubble.parentElement.removeChild(bubble);
}
this.currentExceptionMessage_ = null;
}
};
devtools.DebuggerAgent.prototype.pauseOnExceptions = function()
{
return this.pauseOnExceptions_;
};
devtools.DebuggerAgent.prototype.setPauseOnExceptions = function(value)
{
this.pauseOnExceptions_ = value;
};
devtools.DebuggerAgent.prototype.requestEvaluate = function(arguments, callback)
{
var cmd = new devtools.DebugCommand("evaluate", arguments);
devtools.DebuggerAgent.sendCommand_(cmd);
this.requestSeqToCallback_[cmd.getSequenceNumber()] = callback;
};
devtools.DebuggerAgent.prototype.resolveChildren = function(object, callback, noIntrinsic)
{
if ("handle" in object) {
var result = [];
devtools.DebuggerAgent.formatObjectProperties_(object, result, noIntrinsic);
callback(result);
} else {
this.requestLookup_([object.ref], function(msg) {
var result = [];
if (msg.isSuccess()) {
var handleToObject = msg.getBody();
var resolved = handleToObject[object.ref];
devtools.DebuggerAgent.formatObjectProperties_(resolved, result, noIntrinsic);
callback(result);
} else
callback([]);
});
}
};
devtools.DebuggerAgent.prototype.resolveScope = function(scope, callback)
{
var cmd = new devtools.DebugCommand("scope", {
"frameNumber": scope.frameNumber,
"number": scope.index,
"compactFormat": true
});
devtools.DebuggerAgent.sendCommand_(cmd);
this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) {
var result = [];
if (msg.isSuccess()) {
var scopeObjectJson = msg.getBody().object;
devtools.DebuggerAgent.formatObjectProperties_(scopeObjectJson, result, true );
}
callback(result);
};
};
devtools.DebuggerAgent.prototype.resolveFrameVariables_ = function(callFrameId, callback)
{
var result = {};
var frame = this.callFrames_[callFrameId];
if (!frame) {
callback(result);
return;
}
var waitingResponses = 0;
function scopeResponseHandler(msg) {
waitingResponses--;
if (msg.isSuccess()) {
var properties = msg.getBody().object.properties;
for (var j = 0; j < properties.length; j++)
result[properties[j].name] = true;
}
if (waitingResponses === 0)
callback(result);
};
for (var i = 0; i < frame.scopeChain.length; i++) {
var scope = frame.scopeChain[i].objectId;
if (scope.type === devtools.DebuggerAgent.ScopeType.Global) {
continue;
}
var cmd = new devtools.DebugCommand("scope", {
"frameNumber": scope.frameNumber,
"number": scope.index,
"compactFormat": true
});
devtools.DebuggerAgent.sendCommand_(cmd);
this.requestSeqToCallback_[cmd.getSequenceNumber()] = scopeResponseHandler;
waitingResponses++;
}
};
devtools.DebuggerAgent.prototype.resolveCompletionsOnFrame = function(expressionString, callFrameId, reportCompletions)
{
if (expressionString) {
expressionString = "var obj = " + expressionString +
"; var names = {}; for (var n in obj) { names[n] = true; };" +
"names;";
this.evaluateInCallFrame(
callFrameId,
expressionString,
function(result) {
var names = {};
if (!result.isException) {
var props = result.value.objectId.properties;
for (var i = 0; i < props.length; i++)
names[props[i].name] = true;
}
reportCompletions(names, result.isException);
});
} else {
this.resolveFrameVariables_(callFrameId,
function(result) {
reportCompletions(result, false );
});
}
};
devtools.DebuggerAgent.prototype.getScriptContextType = function(scriptId)
{
return this.parsedScripts_[scriptId].getContextType();
};
devtools.DebuggerAgent.prototype.requestClearBreakpoint_ = function(breakpointId)
{
var cmd = new devtools.DebugCommand("clearbreakpoint", {
"breakpoint": breakpointId
});
devtools.DebuggerAgent.sendCommand_(cmd);
};
devtools.DebuggerAgent.prototype.requestBacktrace_ = function()
{
var cmd = new devtools.DebugCommand("backtrace", {
"compactFormat":true
});
devtools.DebuggerAgent.sendCommand_(cmd);
};
devtools.DebuggerAgent.sendCommand_ = function(cmd)
{
RemoteDebuggerCommandExecutor.DebuggerCommand(cmd.toJSONProtocol());
};
devtools.DebuggerAgent.prototype.stepCommand_ = function(action)
{
this.clearExceptionMessage_();
var cmd = new devtools.DebugCommand("continue", {
"stepaction": action,
"stepcount": 1
});
devtools.DebuggerAgent.sendCommand_(cmd);
};
devtools.DebuggerAgent.prototype.requestLookup_ = function(handles, callback)
{
var cmd = new devtools.DebugCommand("lookup", {
"compactFormat":true,
"handles": handles
});
devtools.DebuggerAgent.sendCommand_(cmd);
this.requestSeqToCallback_[cmd.getSequenceNumber()] = callback;
};
devtools.DebuggerAgent.prototype.setContextId_ = function(contextId)
{
this.contextId_ = contextId;
if (this.requestScriptsWhenContextIdSet_) {
this.requestScriptsWhenContextIdSet_ = false;
var cmd = new devtools.DebugCommand("scripts", {
"includeSource": false
});
devtools.DebuggerAgent.sendCommand_(cmd);
RemoteDebuggerAgent.processDebugCommands();
var debuggerAgent = this;
this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) {
if (contextId === debuggerAgent.contextId_)
debuggerAgent.handleScriptsResponse_(msg);
debuggerAgent.waitingForInitialScriptsResponse_ = false;
if (debuggerAgent.pendingBacktraceResponseHandler_) {
debuggerAgent.pendingBacktraceResponseHandler_();
debuggerAgent.pendingBacktraceResponseHandler_ = null;
}
};
}
};
devtools.DebuggerAgent.prototype.handleDebuggerOutput_ = function(output)
{
var msg;
try {
msg = new devtools.DebuggerMessage(output);
} catch(e) {
debugPrint("Failed to handle debugger response:\n" + e);
throw e;
}
if (msg.getType() === "event") {
if (msg.getEvent() === "break")
this.handleBreakEvent_(msg);
else if (msg.getEvent() === "exception")
this.handleExceptionEvent_(msg);
else if (msg.getEvent() === "afterCompile")
this.handleAfterCompileEvent_(msg);
} else if (msg.getType() === "response") {
if (msg.getCommand() === "scripts")
this.invokeCallbackForResponse_(msg);
else if (msg.getCommand() === "setbreakpoint")
this.handleSetBreakpointResponse_(msg);
else if (msg.getCommand() === "changelive")
this.invokeCallbackForResponse_(msg);
else if (msg.getCommand() === "clearbreakpoint")
this.handleClearBreakpointResponse_(msg);
else if (msg.getCommand() === "backtrace")
this.handleBacktraceResponse_(msg);
else if (msg.getCommand() === "lookup")
this.invokeCallbackForResponse_(msg);
else if (msg.getCommand() === "evaluate")
this.invokeCallbackForResponse_(msg);
else if (msg.getCommand() === "scope")
this.invokeCallbackForResponse_(msg);
}
};
devtools.DebuggerAgent.prototype.handleBreakEvent_ = function(msg)
{
if (!this.breakpointsActivated_) {
this.resumeExecution();
return;
}
WebInspector.currentPanel = WebInspector.panels.scripts;
var body = msg.getBody();
var line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(body.sourceLine);
this.requestBacktrace_();
};
devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg)
{
var body = msg.getBody();
if (this.pauseOnExceptions_ && body.script) {
var line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(body.sourceLine);
this.createExceptionMessage_(body.script.name, line, body.exception.text);
this.requestBacktrace_();
WebInspector.currentPanel = WebInspector.panels.scripts;
} else
this.resumeExecution();
};
devtools.DebuggerAgent.prototype.handleScriptsResponse_ = function(msg)
{
var scripts = msg.getBody();
for (var i = 0; i < scripts.length; i++) {
var script = scripts[i];
if (!this.isScriptFromInspectedContext_(script, msg))
continue;
if (script.id in this.parsedScripts_)
continue;
this.addScriptInfo_(script, msg);
}
};
devtools.DebuggerAgent.prototype.isScriptFromInspectedContext_ = function(script, msg)
{
if (!script.context) {
return false;
}
var context = msg.lookup(script.context.ref);
var scriptContextId = context.data;
if (typeof scriptContextId === "undefined")
return false; if (this.contextId_ === null)
return true;
var comma = context.data.indexOf(",");
if (comma < 0)
return false;
return (context.data.substring(comma + 1) == this.contextId_);
};
devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg)
{
var requestSeq = msg.getRequestSeq();
var breakpointInfo = this.requestNumberToBreakpointInfo_[requestSeq];
if (!breakpointInfo) {
return;
}
delete this.requestNumberToBreakpointInfo_[requestSeq];
if (!msg.isSuccess()) {
return;
}
var idInV8 = msg.getBody().breakpoint;
breakpointInfo.setV8Id(idInV8);
if (breakpointInfo.isRemoved())
this.requestClearBreakpoint_(idInV8);
};
devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg)
{
if (!this.contextId_) {
return;
}
var script = msg.getBody().script;
if (!this.isScriptFromInspectedContext_(script, msg))
return;
this.addScriptInfo_(script, msg);
};
devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script, msg)
{
var context = msg.lookup(script.context.ref);
var contextType;
var comma = context.data.indexOf(",");
if (comma < 0)
return
contextType = context.data.substring(0, comma);
this.parsedScripts_[script.id] = new devtools.ScriptInfo(script.id, script.name, script.lineOffset, contextType);
if (this.scriptsPanelInitialized_) {
WebInspector.parsedScriptSource(script.id, script.name, script.source, script.lineOffset + 1);
this.restoreBreakpoints_(script.id, script.name);
}
};
devtools.DebuggerAgent.prototype.handleClearBreakpointResponse_ = function(msg)
{
};
devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg)
{
if (this.waitingForInitialScriptsResponse_)
this.pendingBacktraceResponseHandler_ = this.doHandleBacktraceResponse_.bind(this, msg);
else
this.doHandleBacktraceResponse_(msg);
};
devtools.DebuggerAgent.prototype.doHandleBacktraceResponse_ = function(msg)
{
var frames = msg.getBody().frames;
this.callFrames_ = [];
for (var i = 0; i < frames.length; ++i)
this.callFrames_.push(this.formatCallFrame_(frames[i]));
WebInspector.pausedScript(this.callFrames_);
this.showPendingExceptionMessage_();
InspectorFrontendHost.bringToFront();
};
devtools.DebuggerAgent.prototype.evaluateInCallFrame = function(callFrameId, code, callback)
{
var callFrame = this.callFrames_[callFrameId];
callFrame.evaluate_(code, callback);
};
devtools.DebuggerAgent.prototype.invokeCallbackForResponse_ = function(msg)
{
var callback = this.requestSeqToCallback_[msg.getRequestSeq()];
if (!callback) {
return false;
}
delete this.requestSeqToCallback_[msg.getRequestSeq()];
callback(msg);
return true;
};
devtools.DebuggerAgent.prototype.formatCallFrame_ = function(stackFrame)
{
var func = stackFrame.func;
var sourceId = func.scriptId;
var existingScript = this.parsedScripts_[sourceId];
if (!existingScript) {
this.parsedScripts_[sourceId] = new devtools.ScriptInfo(sourceId, null , 0 , "unknown" , true );
WebInspector.parsedScriptSource(sourceId, null, null, 0);
}
var funcName = func.name || func.inferredName || "(anonymous function)";
var line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(stackFrame.line);
var scopeChain = [];
var ScopeType = devtools.DebuggerAgent.ScopeType;
for (var i = 0; i < stackFrame.scopes.length; i++) {
var scope = stackFrame.scopes[i];
scope.frameNumber = stackFrame.index;
var scopeObjectProxy = new WebInspector.ObjectProxy(0, scope, [], "", true);
scopeObjectProxy.isScope = true;
switch(scope.type) {
case ScopeType.Global:
scopeObjectProxy.isDocument = true;
break;
case ScopeType.Local:
scopeObjectProxy.isLocal = true;
scopeObjectProxy.thisObject = devtools.DebuggerAgent.formatObjectProxy_(stackFrame.receiver);
break;
case ScopeType.With:
case ScopeType.Catch:
scopeObjectProxy.isWithBlock = true;
break;
case ScopeType.Closure:
scopeObjectProxy.isClosure = true;
break;
}
scopeChain.push(scopeObjectProxy);
}
return new devtools.CallFrame(stackFrame.index, "function", funcName, sourceId, line, scopeChain);
};
devtools.DebuggerAgent.prototype.restoreBreakpoints_ = function(sourceID, scriptUrl)
{
var breakpoints = this.urlToBreakpoints_[scriptUrl];
for (var line in breakpoints) {
if (parseInt(line) == line) {
var v8Line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(parseInt(line));
WebInspector.restoredBreakpoint(sourceID, scriptUrl, v8Line, breakpoints[line].enabled(), breakpoints[line].condition());
}
}
};
devtools.DebuggerAgent.formatObjectProperties_ = function(object, result, noIntrinsic)
{
devtools.DebuggerAgent.propertiesToProxies_(object.properties, result);
if (noIntrinsic)
return;
result.push(new WebInspector.ObjectPropertyProxy("__proto__", devtools.DebuggerAgent.formatObjectProxy_(object.protoObject)));
result.push(new WebInspector.ObjectPropertyProxy("constructor", devtools.DebuggerAgent.formatObjectProxy_(object.constructorFunction)));
};
devtools.DebuggerAgent.propertiesToProxies_ = function(properties, result)
{
var map = {};
for (var i = 0; i < properties.length; ++i) {
var property = properties[i];
var name = String(property.name);
if (name in map)
continue;
map[name] = true;
var value = devtools.DebuggerAgent.formatObjectProxy_(property.value);
var propertyProxy = new WebInspector.ObjectPropertyProxy(name, value);
result.push(propertyProxy);
}
};
devtools.DebuggerAgent.formatObjectProxy_ = function(v)
{
var description;
var hasChildren = false;
if (v.type === "object") {
description = v.className;
hasChildren = true;
} else if (v.type === "function") {
if (v.source)
description = v.source;
else
description = "function " + v.name + "()";
hasChildren = true;
} else if (v.type === "undefined")
description = "undefined";
else if (v.type === "null")
description = "null";
else if (typeof v.value !== "undefined") {
description = v.value;
} else
description = "<unresolved ref: " + v.ref + ", type: " + v.type + ">";
var proxy = new WebInspector.ObjectProxy(0, v, [], description, hasChildren);
proxy.type = v.type;
proxy.isV8Ref = true;
return proxy;
};
devtools.DebuggerAgent.webkitToV8LineNumber_ = function(line)
{
return line - 1;
};
devtools.DebuggerAgent.v8ToWwebkitLineNumber_ = function(line)
{
return line + 1;
};
devtools.ScriptInfo = function(scriptId, url, lineOffset, contextType, opt_isUnresolved)
{
this.scriptId_ = scriptId;
this.lineOffset_ = lineOffset;
this.contextType_ = contextType;
this.url_ = url;
this.isUnresolved_ = opt_isUnresolved;
this.lineToBreakpointInfo_ = {};
};
devtools.ScriptInfo.prototype.getLineOffset = function()
{
return this.lineOffset_;
};
devtools.ScriptInfo.prototype.getContextType = function()
{
return this.contextType_;
};
devtools.ScriptInfo.prototype.getUrl = function()
{
return this.url_;
};
devtools.ScriptInfo.prototype.isUnresolved = function()
{
return this.isUnresolved_;
};
devtools.ScriptInfo.prototype.getBreakpointInfo = function(line)
{
return this.lineToBreakpointInfo_[line];
};
devtools.ScriptInfo.prototype.addBreakpointInfo = function(breakpoint)
{
this.lineToBreakpointInfo_[breakpoint.getLine()] = breakpoint;
};
devtools.ScriptInfo.prototype.removeBreakpointInfo = function(breakpoint)
{
var line = breakpoint.getLine();
delete this.lineToBreakpointInfo_[line];
};
devtools.BreakpointInfo = function(line, enabled, condition)
{
this.line_ = line;
this.enabled_ = enabled;
this.condition_ = condition;
this.v8id_ = -1;
this.removed_ = false;
};
devtools.BreakpointInfo.prototype.getLine = function(n)
{
return this.line_;
};
devtools.BreakpointInfo.prototype.getV8Id = function(n)
{
return this.v8id_;
};
devtools.BreakpointInfo.prototype.setV8Id = function(id)
{
this.v8id_ = id;
};
devtools.BreakpointInfo.prototype.markAsRemoved = function()
{
this.removed_ = true;
};
devtools.BreakpointInfo.prototype.isRemoved = function()
{
return this.removed_;
};
devtools.BreakpointInfo.prototype.enabled = function()
{
return this.enabled_;
};
devtools.BreakpointInfo.prototype.condition = function()
{
return this.condition_;
};
devtools.CallFrame = function(id, type, functionName, sourceID, line, scopeChain)
{
this.id = id;
this.type = type;
this.functionName = functionName;
this.sourceID = sourceID;
this.line = line;
this.scopeChain = scopeChain;
};
devtools.CallFrame.prototype.evaluate_ = function(expression, callback)
{
devtools.tools.getDebuggerAgent().requestEvaluate({
"expression": expression,
"frame": this.id,
"global": false,
"disable_break": false,
"compactFormat": true,
"maxStringLength": -1
},
function(response) {
var result = {};
if (response.isSuccess())
result.value = devtools.DebuggerAgent.formatObjectProxy_(response.getBody());
else {
result.value = response.getMessage();
result.isException = true;
}
callback(result);
});
};
devtools.DebugCommand = function(command, opt_arguments)
{
this.command_ = command;
this.type_ = "request";
this.seq_ = ++devtools.DebugCommand.nextSeq_;
if (opt_arguments)
this.arguments_ = opt_arguments;
};
devtools.DebugCommand.nextSeq_ = 1;
devtools.DebugCommand.prototype.getSequenceNumber = function()
{
return this.seq_;
};
devtools.DebugCommand.prototype.toJSONProtocol = function()
{
var json = {
"seq": this.seq_,
"type": this.type_,
"command": this.command_
}
if (this.arguments_)
json.arguments = this.arguments_;
return JSON.stringify(json);
};
devtools.DebuggerMessage = function(msg)
{
this.packet_ = JSON.parse(msg);
this.refs_ = [];
if (this.packet_.refs) {
for (var i = 0; i < this.packet_.refs.length; i++)
this.refs_[this.packet_.refs[i].handle] = this.packet_.refs[i];
}
};
devtools.DebuggerMessage.prototype.getType = function()
{
return this.packet_.type;
};
devtools.DebuggerMessage.prototype.getEvent = function()
{
return this.packet_.event;
};
devtools.DebuggerMessage.prototype.getCommand = function()
{
return this.packet_.command;
};
devtools.DebuggerMessage.prototype.getRequestSeq = function()
{
return this.packet_.request_seq;
};
devtools.DebuggerMessage.prototype.isRunning = function()
{
return this.packet_.running ? true : false;
};
devtools.DebuggerMessage.prototype.isSuccess = function()
{
return this.packet_.success ? true : false;
};
devtools.DebuggerMessage.prototype.getMessage = function()
{
return this.packet_.message;
};
devtools.DebuggerMessage.prototype.getBody = function()
{
return this.packet_.body;
};
devtools.DebuggerMessage.prototype.lookup = function(handle)
{
return this.refs_[handle];
};