summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authoryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-01 14:26:40 +0000
committeryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-01 14:26:40 +0000
commit24b3b4de275cd9d9970c2f14d47ada7612043b06 (patch)
tree5b1b9da85194666ca1ffb9b13c7672c5724e7129 /webkit/glue
parentb4a2a3064c780cb1a092b192c8badb884eb1544d (diff)
downloadchromium_src-24b3b4de275cd9d9970c2f14d47ada7612043b06.zip
chromium_src-24b3b4de275cd9d9970c2f14d47ada7612043b06.tar.gz
chromium_src-24b3b4de275cd9d9970c2f14d47ada7612043b06.tar.bz2
1. Supported removal of breakpoints from UI.
2. Fixed bug in resume debugger functionality. 3. Implemented pause in debugger. 4. Removed deprecated messages and their handlers. Review URL: http://codereview.chromium.org/60012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.cc2
-rw-r--r--webkit/glue/devtools/debugger_agent_manager.cc8
-rw-r--r--webkit/glue/devtools/debugger_agent_manager.h4
-rw-r--r--webkit/glue/devtools/js/debugger_agent.js116
-rw-r--r--webkit/glue/devtools/js/inspector_controller_impl.js13
5 files changed, 138 insertions, 5 deletions
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc
index b52db2a..4edd3db 100644
--- a/webkit/glue/devtools/debugger_agent_impl.cc
+++ b/webkit/glue/devtools/debugger_agent_impl.cc
@@ -33,7 +33,7 @@ DebuggerAgentImpl::~DebuggerAgentImpl() {
}
void DebuggerAgentImpl::DebugBreak() {
- // TODO(yurys): implement
+ DebuggerAgentManager::DebugBreak(this);
}
void DebuggerAgentImpl::DebuggerOutput(const std::string& command) {
diff --git a/webkit/glue/devtools/debugger_agent_manager.cc b/webkit/glue/devtools/debugger_agent_manager.cc
index d6ab21c..3af22e6 100644
--- a/webkit/glue/devtools/debugger_agent_manager.cc
+++ b/webkit/glue/devtools/debugger_agent_manager.cc
@@ -59,6 +59,14 @@ void DebuggerAgentManager::DebugDetach(DebuggerAgentImpl* debugger_agent) {
}
// static
+void DebuggerAgentManager::DebugBreak(DebuggerAgentImpl* debugger_agent) {
+#if USE(V8)
+ DCHECK(attached_agents_->contains(debugger_agent));
+ v8::Debug::DebugBreak();
+#endif
+}
+
+// static
void DebuggerAgentManager::DebuggerOutput(const std::string& out) {
DebuggerAgentImpl* agent = GetAgentForCurrentV8Context();
if (!agent) {
diff --git a/webkit/glue/devtools/debugger_agent_manager.h b/webkit/glue/devtools/debugger_agent_manager.h
index 380bb0d..ba48966 100644
--- a/webkit/glue/devtools/debugger_agent_manager.h
+++ b/webkit/glue/devtools/debugger_agent_manager.h
@@ -24,10 +24,14 @@ class DebuggerAgentImpl;
// would expect some actions from the handler. If there is no appropriate
// debugger agent to handle such messages the manager should perform the action
// itself, otherwise v8 may hang waiting for the action.
+//
+// TODO(yurys): disable plugin message handling while v8 is paused on a
+// breakpoint.
class DebuggerAgentManager {
public:
static void DebugAttach(DebuggerAgentImpl* debugger_agent);
static void DebugDetach(DebuggerAgentImpl* debugger_agent);
+ static void DebugBreak(DebuggerAgentImpl* debugger_agent);
static void DebugCommand(const std::string& command);
static void ExecuteDebuggerCommand(const std::string& command);
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js
index b22ff20..401c998 100644
--- a/webkit/glue/devtools/js/debugger_agent.js
+++ b/webkit/glue/devtools/js/debugger_agent.js
@@ -55,6 +55,14 @@ devtools.DebuggerAgent.prototype.requestScripts = function() {
/**
+ * Tells the v8 debugger to stop on as soon as possible.
+ */
+devtools.DebuggerAgent.prototype.pauseExecution = function() {
+ RemoteDebuggerAgent.DebugBreak();
+};
+
+
+/**
* @param {number} sourceId Id of the script fot the breakpoint.
* @param {number} line Number of the line for the breakpoint.
*/
@@ -86,6 +94,31 @@ devtools.DebuggerAgent.prototype.addBreakpoint = function(sourceId, line) {
/**
+ * @param {number} sourceId Id of the script fot the breakpoint.
+ * @param {number} line Number of the line for the breakpoint.
+ */
+devtools.DebuggerAgent.prototype.removeBreakpoint = function(sourceId, line) {
+ var script = this.parsedScripts_[sourceId];
+ if (!script) {
+ return;
+ }
+
+ var breakpointInfo = script.getBreakpointInfo(line);
+ script.removeBreakpointInfo(breakpointInfo);
+ breakpointInfo.markAsRemoved();
+
+ var id = breakpointInfo.getV8Id();
+
+ // If we don't know id of this breakpoint in the v8 debugger we cannot send
+ // 'clearbreakpoint' request. In that case it will be removed in
+ // 'setbreakpoint' response handler when we learn the id.
+ if (id != -1) {
+ this.requestClearBreakpoint_(id);
+ }
+};
+
+
+/**
* Tells the v8 debugger to step into the next statement.
*/
devtools.DebuggerAgent.prototype.stepIntoStatement = function() {
@@ -113,7 +146,7 @@ devtools.DebuggerAgent.prototype.stepOverStatement = function() {
* Tells the v8 debugger to continue execution after it has been stopped on a
* breakpoint or an exception.
*/
-devtools.DebuggerAgent.prototype.continueExecution = function() {
+devtools.DebuggerAgent.prototype.resumeExecution = function() {
var cmd = new devtools.DebugCommand('continue');
devtools.DebuggerAgent.sendCommand_(cmd);
};
@@ -129,6 +162,19 @@ devtools.DebuggerAgent.prototype.getCurrentCallFrame = function() {
/**
+ * Removes specified breakpoint from the v8 debugger.
+ * @param {number} breakpointId Id of the breakpoint in the v8 debugger.
+ */
+devtools.DebuggerAgent.prototype.requestClearBreakpoint_ = function(
+ breakpointId) {
+ var cmd = new devtools.DebugCommand('clearbreakpoint', {
+ 'breakpoint': breakpointId
+ });
+ devtools.DebuggerAgent.sendCommand_(cmd);
+};
+
+
+/**
* Sends 'backtrace' request to v8.
*/
devtools.DebuggerAgent.prototype.requestBacktrace_ = function() {
@@ -183,6 +229,8 @@ devtools.DebuggerAgent.prototype.handleDebuggerOutput_ = function(output) {
this.handleScriptsResponse_(msg);
} else if (msg.getCommand() == 'setbreakpoint') {
this.handleSetBreakpointResponse_(msg);
+ } else if (msg.getCommand() == 'clearbreakpoint') {
+ this.handleClearBreakpointResponse_(msg);
} else if (msg.getCommand() == 'backtrace') {
this.handleBacktraceResponse_(msg);
}
@@ -199,7 +247,9 @@ devtools.DebuggerAgent.prototype.handleBreakEvent_ = function(msg) {
this.currentCallFrame_ = {
'sourceID': body.script.id,
'line': body.sourceLine - body.script.lineOffset +1,
- 'script': body.script
+ 'script': body.script,
+ 'scopeChain': [],
+ 'thisObject': {}
};
this.requestBacktrace_();
@@ -240,6 +290,19 @@ devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) {
}
var idInV8 = msg.getBody().breakpoint;
breakpointInfo.setV8Id(idInV8);
+
+ if (breakpointInfo.isRemoved()) {
+ this.requestClearBreakpoint_(idInV8);
+ }
+};
+
+
+/**
+ * @param {devtools.DebuggerMessage} msg
+ */
+devtools.DebuggerAgent.prototype.handleClearBreakpointResponse_ = function(
+ msg) {
+ // Do nothing.
};
@@ -285,7 +348,9 @@ devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg) {
'line': nextFrame.line - script.lineOffset +1,
'type': 'function',
'functionName': funcName, //nextFrame.text,
- 'caller': caller
+ 'caller': caller,
+ 'scopeChain': [],
+ 'thisObject': {}
};
caller = f;
}
@@ -304,7 +369,7 @@ devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg) {
*/
devtools.ScriptInfo = function(scriptId, lineOffset) {
this.scriptId_ = scriptId;
- this.lineOffset_ = lineOffset;
+ this.lineOffset_ = lineOffset;
this.lineToBreakpointInfo_ = {};
};
@@ -338,6 +403,15 @@ devtools.ScriptInfo.prototype.addBreakpointInfo = function(breakpoint) {
};
+/**
+ * @param {devtools.BreakpointInfo} breakpoint Breakpoint info to be removed.
+ */
+devtools.ScriptInfo.prototype.removeBreakpointInfo = function(breakpoint) {
+ var line = breakpoint.getLine();
+ delete this.lineToBreakpointInfo_[line];
+};
+
+
/**
* @param {number} scriptId Id of the owning script.
@@ -348,6 +422,15 @@ devtools.BreakpointInfo = function(sourceId, line) {
this.sourceId_ = sourceId;
this.line_ = line;
this.v8id_ = -1;
+ this.removed_ = false;
+};
+
+
+/**
+ * @return {number}
+ */
+devtools.BreakpointInfo.prototype.getSourceId = function(n) {
+ return this.sourceId_;
};
@@ -360,6 +443,14 @@ devtools.BreakpointInfo.prototype.getLine = function(n) {
/**
+ * @return {number} Unique identifier of this breakpoint in the v8 debugger.
+ */
+devtools.BreakpointInfo.prototype.getV8Id = function(n) {
+ return this.v8id_;
+};
+
+
+/**
* Sets id of this breakpoint in the v8 debugger.
* @param {number} id
*/
@@ -368,6 +459,23 @@ devtools.BreakpointInfo.prototype.setV8Id = function(id) {
};
+/**
+ * Marks this breakpoint as removed from the front-end.
+ */
+devtools.BreakpointInfo.prototype.markAsRemoved = function() {
+ this.removed_ = true;
+};
+
+
+/**
+ * @return {boolean} Whether this breakpoint has been removed from the
+ * front-end.
+ */
+devtools.BreakpointInfo.prototype.isRemoved = function() {
+ return this.removed_;
+};
+
+
/**
* JSON based commands sent to v8 debugger.
diff --git a/webkit/glue/devtools/js/inspector_controller_impl.js b/webkit/glue/devtools/js/inspector_controller_impl.js
index 955b8ff..2ce61f5 100644
--- a/webkit/glue/devtools/js/inspector_controller_impl.js
+++ b/webkit/glue/devtools/js/inspector_controller_impl.js
@@ -22,6 +22,12 @@ devtools.InspectorControllerImpl = function() {
},
get Element() {
return devtools.DomNode;
+ },
+ /**
+ * See usages in ScopeChainSidebarPane.js where it's called as
+ * constructor.
+ */
+ Object : function() {
}
};
};
@@ -109,10 +115,17 @@ devtools.InspectorControllerImpl.prototype.addBreakpoint = function(
devtools.InspectorControllerImpl.prototype.removeBreakpoint = function(
sourceID, line) {
+ devtools.tools.getDebuggerAgent().removeBreakpoint(sourceID, line);
+};
+
+
+devtools.InspectorController.prototype.pauseInDebugger = function() {
+ devtools.tools.getDebuggerAgent().pauseExecution();
};
devtools.InspectorControllerImpl.prototype.resumeDebugger = function() {
+ devtools.tools.getDebuggerAgent().resumeExecution();
};