summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authormnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 09:13:29 +0000
committermnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 09:13:29 +0000
commit45f32d9f9d48f4897418d0db85c3814f869a39eb (patch)
tree50ff2e0db364fac3cf1bbdf3257346eb559257ed /webkit/glue
parentf93914857eb403a7aecf9154d14efae2703077e9 (diff)
downloadchromium_src-45f32d9f9d48f4897418d0db85c3814f869a39eb.zip
chromium_src-45f32d9f9d48f4897418d0db85c3814f869a39eb.tar.gz
chromium_src-45f32d9f9d48f4897418d0db85c3814f869a39eb.tar.bz2
Sync with the profiler changes in V8.
- Use context prior to calling 'ResumeProfiler'. - Check the status of the profiler using 'IsProfilerPaused'. Review URL: http://codereview.chromium.org/115767 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16868 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/devtools/debugger_agent.h7
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.cc15
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.h4
-rw-r--r--webkit/glue/devtools/js/debugger_agent.js109
-rw-r--r--webkit/glue/devtools/js/devtools_host_stub.js18
5 files changed, 92 insertions, 61 deletions
diff --git a/webkit/glue/devtools/debugger_agent.h b/webkit/glue/devtools/debugger_agent.h
index b310fb3..8205491 100644
--- a/webkit/glue/devtools/debugger_agent.h
+++ b/webkit/glue/devtools/debugger_agent.h
@@ -23,6 +23,9 @@
/* Stops profiling (samples collection). */ \
METHOD0(StopProfiling) \
\
+ /* Requests current profiler status. */ \
+ METHOD0(IsProfilingStarted) \
+ \
/* Retrieves a portion of profiler log. */ \
METHOD1(GetLogLines, int /* position */)
@@ -35,6 +38,10 @@ DEFINE_RPC_CLASS(DebuggerAgent, DEBUGGER_AGENT_STRUCT)
/* Response to GetContextId. */ \
METHOD1(DidGetContextId, int /* context id */) \
\
+ /* Response to IsProfilingStarted. */ \
+ METHOD1(DidIsProfilingStarted, bool /* is_started */) \
+ \
+ /* Response to GetLogLines. */ \
METHOD2(DidGetLogLines, std::string /* log */, int /* new_position */)
DEFINE_RPC_CLASS(DebuggerAgentDelegate, DEBUGGER_AGENT_DELEGATE_STRUCT)
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc
index 3d18bb5..eb38ab6 100644
--- a/webkit/glue/devtools/debugger_agent_impl.cc
+++ b/webkit/glue/devtools/debugger_agent_impl.cc
@@ -59,6 +59,10 @@ void DebuggerAgentImpl::GetContextId() {
}
void DebuggerAgentImpl::StartProfiling() {
+ v8::HandleScope scope;
+ WebCore::V8Proxy* proxy = V8Proxy::retrieve(GetPage()->mainFrame());
+ DCHECK(proxy && proxy->ContextInitialized());
+ v8::Context::Scope context_scope(proxy->GetContext());
v8::V8::ResumeProfiler();
}
@@ -66,11 +70,15 @@ void DebuggerAgentImpl::StopProfiling() {
v8::V8::PauseProfiler();
}
+void DebuggerAgentImpl::IsProfilingStarted() {
+ delegate_->DidIsProfilingStarted(!v8::V8::IsProfilerPaused());
+}
+
void DebuggerAgentImpl::GetLogLines(int position) {
static char buffer[65536];
int read_size = v8::V8::GetLogLines(position, buffer, sizeof(buffer) - 1);
buffer[read_size] = '\0';
- DidGetLogLines(buffer, position + read_size);
+ delegate_->DidGetLogLines(buffer, position + read_size);
}
void DebuggerAgentImpl::DebuggerOutput(const std::string& command) {
@@ -78,11 +86,6 @@ void DebuggerAgentImpl::DebuggerOutput(const std::string& command) {
webdevtools_agent_->ForceRepaint();
}
-void DebuggerAgentImpl::DidGetLogLines(
- const std::string& log, int new_position) {
- delegate_->DidGetLogLines(log, new_position);
-}
-
// static
void DebuggerAgentImpl::ResetUtilityContext(
Document* document,
diff --git a/webkit/glue/devtools/debugger_agent_impl.h b/webkit/glue/devtools/debugger_agent_impl.h
index bfeffe3..c61eb29 100644
--- a/webkit/glue/devtools/debugger_agent_impl.h
+++ b/webkit/glue/devtools/debugger_agent_impl.h
@@ -42,12 +42,12 @@ class DebuggerAgentImpl : public DebuggerAgent {
virtual void StopProfiling();
+ virtual void IsProfilingStarted();
+
virtual void GetLogLines(int position);
void DebuggerOutput(const std::string& out);
- void DidGetLogLines(const std::string& log, int new_position);
-
// Executes function with the given name in the utility context. Passes node
// and json args as parameters. Note that the function called must be
// implemented in the inject.js file.
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js
index 4d84f6d..890f704 100644
--- a/webkit/glue/devtools/js/debugger_agent.js
+++ b/webkit/glue/devtools/js/debugger_agent.js
@@ -15,23 +15,25 @@ goog.provide('devtools.DebuggerAgent');
devtools.DebuggerAgent = function() {
RemoteDebuggerAgent.DebuggerOutput =
goog.bind(this.handleDebuggerOutput_, this);
- RemoteDebuggerAgent.DidGetContextId =
+ RemoteDebuggerAgent.DidGetContextId =
goog.bind(this.didGetContextId_, this);
+ RemoteDebuggerAgent.DidIsProfilingStarted =
+ goog.bind(this.didIsProfilingStarted_, this);
RemoteDebuggerAgent.DidGetLogLines =
goog.bind(this.didGetLogLines_, this);
-
+
/**
* Id of the inspected page global context. It is used for filtering scripts.
- * @type {number}
+ * @type {number}
*/
this.contextId_ = null;
-
+
/**
* Mapping from script id to script info.
* @type {Object}
*/
this.parsedScripts_ = null;
-
+
/**
* Mapping from the request id to the devtools.BreakpointInfo for the
* breakpoints whose v8 ids are not set yet. These breakpoints are waiting for
@@ -40,50 +42,50 @@ devtools.DebuggerAgent = function() {
* @type {Object}
*/
this.requestNumberToBreakpointInfo_ = null;
-
+
/**
* Information on current stack top frame.
* See JavaScriptCallFrame.idl.
* @type {?devtools.CallFrame}
*/
this.currentCallFrame_ = null;
-
+
/**
* Whether to stop in the debugger on the exceptions.
* @type {boolean}
*/
this.pauseOnExceptions_ = true;
-
+
/**
* Mapping: request sequence number->callback.
* @type {Object}
*/
- this.requestSeqToCallback_ = null;
+ this.requestSeqToCallback_ = null;
/**
* Whether the scripts list has been requested.
* @type {boolean}
*/
this.scriptsCacheInitialized_ = false;
-
+
/**
* Whether user has stopped profiling and we are retrieving the rest of
* profiler's log.
* @type {boolean}
*/
this.isProcessingProfile_ = false;
-
+
/**
* The position in log file to read from.
* @type {number}
*/
this.lastProfileLogPosition_ = 0;
-
+
/**
* Profiler processor instance.
* @type {devtools.profiler.Processor}
*/
- this.profilerProcessor_ = new devtools.profiler.Processor();
+ this.profilerProcessor_ = new devtools.profiler.Processor();
};
@@ -152,7 +154,7 @@ devtools.DebuggerAgent.prototype.resolveScriptSource = function(
devtools.DebuggerAgent.sendCommand_(cmd);
// Force v8 execution so that it gets to processing the requested command.
devtools.tools.evaluateJavaScript('javascript:void(0)');
-
+
this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) {
if (msg.isSuccess()) {
var scriptJson = msg.getBody()[0];
@@ -181,14 +183,14 @@ devtools.DebuggerAgent.prototype.addBreakpoint = function(sourceId, line) {
if (!script) {
return;
}
-
+
line = devtools.DebuggerAgent.webkitToV8LineNumber_(line);
-
+
var breakpointInfo = script.getBreakpointInfo(line);
if (breakpointInfo) {
return;
}
-
+
breakpointInfo = new devtools.BreakpointInfo(sourceId, line);
script.addBreakpointInfo(breakpointInfo);
@@ -197,9 +199,9 @@ devtools.DebuggerAgent.prototype.addBreakpoint = function(sourceId, line) {
'target': sourceId,
'line': line
});
-
+
this.requestNumberToBreakpointInfo_[cmd.getSequenceNumber()] = breakpointInfo;
-
+
devtools.DebuggerAgent.sendCommand_(cmd);
};
@@ -213,7 +215,7 @@ devtools.DebuggerAgent.prototype.removeBreakpoint = function(sourceId, line) {
if (!script) {
return;
}
-
+
line = devtools.DebuggerAgent.webkitToV8LineNumber_(line);
var breakpointInfo = script.getBreakpointInfo(line);
@@ -269,7 +271,7 @@ devtools.DebuggerAgent.prototype.resumeExecution = function() {
* @return {boolean} True iff the debugger will pause execution on the
* exceptions.
*/
-devtools.DebuggerAgent.prototype.pauseOnExceptions = function() {
+devtools.DebuggerAgent.prototype.pauseOnExceptions = function() {
return this.pauseOnExceptions_;
};
@@ -329,7 +331,7 @@ devtools.DebuggerAgent.prototype.resolveChildren = function(object, callback) {
object.resolvedValue = result;
callback(object);
});
-
+
return;
} else {
if (!object.resolvedValue) {
@@ -348,10 +350,10 @@ devtools.DebuggerAgent.prototype.resolveChildren = function(object, callback) {
devtools.DebuggerAgent.prototype.startProfiling = function() {
if (this.isProcessingProfile_) {
return;
- }
+ }
RemoteDebuggerAgent.StartProfiling();
- RemoteDebuggerAgent.GetLogLines(this.lastProfileLogPosition_);
- WebInspector.setRecordingProfile(true);
+ // Query if profiling has been really started.
+ RemoteDebuggerAgent.IsProfilingStarted();
};
@@ -449,8 +451,8 @@ devtools.DebuggerAgent.prototype.handleDebuggerOutput_ = function(output) {
debugPrint('Failed to handle debugger reponse:\n' + e);
throw e;
}
-
-
+
+
if (msg.getType() == 'event') {
if (msg.getEvent() == 'break') {
this.handleBreakEvent_(msg);
@@ -507,15 +509,15 @@ devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg) {
if (body.script) {
sourceId = body.script.id;
}
-
+
var line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(body.sourceLine);
-
+
this.currentCallFrame_ = new devtools.CallFrame();
this.currentCallFrame_.sourceID = sourceId;
this.currentCallFrame_.line = line;
this.currentCallFrame_.script = body.script;
this.requestBacktrace_();
- } else {
+ } else {
this.resumeExecution();
}
};
@@ -574,7 +576,7 @@ devtools.DebuggerAgent.prototype.isScriptFromInspectedContext_ = function(
*/
devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) {
var requestSeq = msg.getRequestSeq();
- var breakpointInfo = this.requestNumberToBreakpointInfo_[requestSeq];
+ var breakpointInfo = this.requestNumberToBreakpointInfo_[requestSeq];
if (!breakpointInfo) {
// TODO(yurys): handle this case
return;
@@ -586,7 +588,7 @@ devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) {
}
var idInV8 = msg.getBody().breakpoint;
breakpointInfo.setV8Id(idInV8);
-
+
if (breakpointInfo.isRemoved()) {
this.requestClearBreakpoint_(idInV8);
}
@@ -607,6 +609,19 @@ devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) {
/**
+ * Handles current profiler status.
+ */
+devtools.DebuggerAgent.prototype.didIsProfilingStarted_ = function(
+ is_started) {
+ if (is_started) {
+ // Start to query log data.
+ RemoteDebuggerAgent.GetLogLines(this.lastProfileLogPosition_);
+ }
+ WebInspector.setRecordingProfile(is_started);
+};
+
+
+/**
* Handles a portion of a profiler log retrieved by GetLogLines call.
* @param {string} log A portion of profiler log.
* @param {number} newPosition The position in log file to read from
@@ -619,7 +634,7 @@ devtools.DebuggerAgent.prototype.didGetLogLines_ = function(
this.lastProfileLogPosition_ = newPosition;
} else if (this.isProcessingProfile_) {
this.isProcessingProfile_ = false;
- WebInspector.setRecordingProfile(false);
+ WebInspector.setRecordingProfile(false);
WebInspector.addProfile(this.profilerProcessor_.createProfileForView());
return;
}
@@ -658,9 +673,9 @@ devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg) {
if (!this.currentCallFrame_) {
return;
}
-
+
var script = this.currentCallFrame_.script;
-
+
var callerFrame = null;
var f = null;
var frames = msg.getBody().frames;
@@ -671,9 +686,9 @@ devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg) {
f.caller = callerFrame;
callerFrame = f;
}
-
+
this.currentCallFrame_ = f;
-
+
WebInspector.pausedScript();
DevToolsHost.activateWindow();
};
@@ -710,24 +725,24 @@ devtools.DebuggerAgent.prototype.evaluateInCallFrame_ = function(expression) {
*/
devtools.DebuggerAgent.formatCallFrame_ = function(stackFrame, script, msg) {
var sourceId = script.id;
-
+
var func = stackFrame.func;
var sourceId = func.scriptId;
var funcName = func.name || func.inferredName || '(anonymous function)';
-
+
var scope = {};
-
+
// Add arguments.
devtools.DebuggerAgent.argumentsArrayToMap_(stackFrame.arguments, scope);
-
+
// Add local variables.
devtools.DebuggerAgent.propertiesToMap_(stackFrame.locals, scope);
var thisObject = devtools.DebuggerAgent.formatObjectReference_(
- stackFrame.receiver);
+ stackFrame.receiver);
// Add variable with name 'this' to the scope.
scope['this'] = thisObject;
-
+
var line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(stackFrame.line);
var result = new devtools.CallFrame();
result.sourceID = sourceId;
@@ -799,7 +814,7 @@ devtools.DebuggerAgent.argumentsArrayToMap_ = function(array, map) {
/**
- * @param {Object} v An object reference from the debugger response.
+ * @param {Object} v An object reference from the debugger response.
* @return {*} The value representation expected by ScriptsPanel.
*/
devtools.DebuggerAgent.formatObjectReference_ = function(v) {
@@ -854,7 +869,7 @@ devtools.DebuggerAgent.v8ToWwebkitLineNumber_ = function(line) {
devtools.ScriptInfo = function(scriptId, lineOffset) {
this.scriptId_ = scriptId;
this.lineOffset_ = lineOffset;
-
+
this.lineToBreakpointInfo_ = {};
};
@@ -904,7 +919,7 @@ devtools.ScriptInfo.prototype.removeBreakpointInfo = function(breakpoint) {
*/
devtools.BreakpointInfo = function(sourceId, line) {
this.sourceId_ = sourceId;
- this.line_ = line;
+ this.line_ = line;
this.v8id_ = -1;
this.removed_ = false;
};
@@ -1017,7 +1032,7 @@ devtools.CallFrame.handleEvaluateResponse_ = function(response) {
*/
devtools.DebugCommand = function(command, opt_arguments) {
this.command_ = command;
- this.type_ = 'request';
+ this.type_ = 'request';
this.seq_ = ++devtools.DebugCommand.nextSeq_;
if (opt_arguments) {
this.arguments_ = opt_arguments;
diff --git a/webkit/glue/devtools/js/devtools_host_stub.js b/webkit/glue/devtools/js/devtools_host_stub.js
index b8dae47..801d42e 100644
--- a/webkit/glue/devtools/js/devtools_host_stub.js
+++ b/webkit/glue/devtools/js/devtools_host_stub.js
@@ -26,6 +26,12 @@ RemoteDebuggerAgentStub.prototype.StopProfiling = function() {
RemoteDebuggerAgentStub.prototype.StartProfiling = function() {
};
+RemoteDebuggerAgentStub.prototype.IsProfilingStarted = function() {
+ setTimeout(function() {
+ RemoteDebuggerAgent.DidIsProfilingStarted(true);
+ }, 100);
+};
+
RemoteDebuggerAgentStub.prototype.GetLogLines = function(pos) {
if (pos < RemoteDebuggerAgentStub.ProfilerLogBuffer.length) {
setTimeout(function() {
@@ -51,7 +57,7 @@ RemoteDomAgentStub.sendDocumentElement_ = function() {
1, // id
1, // type = Node.ELEMENT_NODE,
'HTML', // nodeName
- '', // nodeValue
+ '', // nodeValue
['foo','bar'], // attributes
2, // childNodeCount
]);
@@ -66,7 +72,7 @@ RemoteDomAgentStub.sendChildNodes_ = function(id) {
2, // id
1, // type = Node.ELEMENT_NODE,
'DIV', // nodeName
- '', // nodeValue
+ '', // nodeValue
['foo','bar'], // attributes
1, // childNodeCount
],
@@ -74,17 +80,17 @@ RemoteDomAgentStub.sendChildNodes_ = function(id) {
3, // id
3, // type = Node.TEXT_NODE,
'', // nodeName
- 'Text', // nodeValue
+ 'Text', // nodeValue
]
]);
} else if (id == 2) {
- RemoteDomAgent.SetChildNodes(id,
+ RemoteDomAgent.SetChildNodes(id,
[
[
4, // id
1, // type = Node.ELEMENT_NODE,
'span', // nodeName
- '', // nodeValue
+ '', // nodeValue
['foo','bar'], // attributes
0, // childNodeCount
]
@@ -167,7 +173,7 @@ RemoteToolsAgentStub.prototype.EvaluateJavaScript = function(callId, script) {
};
-RemoteToolsAgentStub.prototype.ExecuteUtilityFunction = function(callId,
+RemoteToolsAgentStub.prototype.ExecuteUtilityFunction = function(callId,
functionName, nodeId, args) {
setTimeout(function() {
var result = [];