Commit efdc8ace authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] migrate Debugger to new style

BUG=none
R=dgozman@chromium.org
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel

Review-Url: https://codereview.chromium.org/2471583003
Cr-Commit-Position: refs/heads/master@{#40782}
parent 3019b497
This diff is collapsed.
...@@ -24,8 +24,8 @@ class V8InspectorSessionImpl; ...@@ -24,8 +24,8 @@ class V8InspectorSessionImpl;
class V8Regex; class V8Regex;
class V8StackTraceImpl; class V8StackTraceImpl;
using protocol::ErrorString;
using protocol::Maybe; using protocol::Maybe;
using protocol::Response;
class V8DebuggerAgentImpl : public protocol::Debugger::Backend { class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
public: public:
...@@ -49,67 +49,64 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { ...@@ -49,67 +49,64 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
void restore(); void restore();
// Part of the protocol. // Part of the protocol.
void enable(ErrorString*) override; Response enable() override;
void disable(ErrorString*) override; Response disable() override;
void setBreakpointsActive(ErrorString*, bool active) override; Response setBreakpointsActive(bool active) override;
void setSkipAllPauses(ErrorString*, bool skip) override; Response setSkipAllPauses(bool skip) override;
void setBreakpointByUrl( Response setBreakpointByUrl(
ErrorString*, int lineNumber, const Maybe<String16>& optionalURL, int lineNumber, Maybe<String16> optionalURL,
const Maybe<String16>& optionalURLRegex, Maybe<String16> optionalURLRegex, Maybe<int> optionalColumnNumber,
const Maybe<int>& optionalColumnNumber, Maybe<String16> optionalCondition, String16*,
const Maybe<String16>& optionalCondition, String16*,
std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations)
override; override;
void setBreakpoint( Response setBreakpoint(
ErrorString*, std::unique_ptr<protocol::Debugger::Location>, std::unique_ptr<protocol::Debugger::Location>,
const Maybe<String16>& optionalCondition, String16*, Maybe<String16> optionalCondition, String16*,
std::unique_ptr<protocol::Debugger::Location>* actualLocation) override; std::unique_ptr<protocol::Debugger::Location>* actualLocation) override;
void removeBreakpoint(ErrorString*, const String16& breakpointId) override; Response removeBreakpoint(const String16& breakpointId) override;
void continueToLocation( Response continueToLocation(
ErrorString*, std::unique_ptr<protocol::Debugger::Location>) override; std::unique_ptr<protocol::Debugger::Location>) override;
void searchInContent( Response searchInContent(
ErrorString*, const String16& scriptId, const String16& query, const String16& scriptId, const String16& query,
const Maybe<bool>& optionalCaseSensitive, Maybe<bool> optionalCaseSensitive, Maybe<bool> optionalIsRegex,
const Maybe<bool>& optionalIsRegex,
std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>>*) std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>>*)
override; override;
void setScriptSource( Response setScriptSource(
ErrorString*, const String16& inScriptId, const String16& inScriptSource, const String16& inScriptId, const String16& inScriptSource,
const Maybe<bool>& dryRun, Maybe<bool> dryRun,
Maybe<protocol::Array<protocol::Debugger::CallFrame>>* optOutCallFrames, Maybe<protocol::Array<protocol::Debugger::CallFrame>>* optOutCallFrames,
Maybe<bool>* optOutStackChanged, Maybe<bool>* optOutStackChanged,
Maybe<protocol::Runtime::StackTrace>* optOutAsyncStackTrace, Maybe<protocol::Runtime::StackTrace>* optOutAsyncStackTrace,
Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) override; Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) override;
void restartFrame( Response restartFrame(
ErrorString*, const String16& callFrameId, const String16& callFrameId,
std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>* std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>*
newCallFrames, newCallFrames,
Maybe<protocol::Runtime::StackTrace>* asyncStackTrace) override; Maybe<protocol::Runtime::StackTrace>* asyncStackTrace) override;
void getScriptSource(ErrorString*, const String16& scriptId, Response getScriptSource(const String16& scriptId,
String16* scriptSource) override; String16* scriptSource) override;
void pause(ErrorString*) override; Response pause() override;
void resume(ErrorString*) override; Response resume() override;
void stepOver(ErrorString*) override; Response stepOver() override;
void stepInto(ErrorString*) override; Response stepInto() override;
void stepOut(ErrorString*) override; Response stepOut() override;
void setPauseOnExceptions(ErrorString*, const String16& pauseState) override; Response setPauseOnExceptions(const String16& pauseState) override;
void evaluateOnCallFrame( Response evaluateOnCallFrame(
ErrorString*, const String16& callFrameId, const String16& expression, const String16& callFrameId, const String16& expression,
const Maybe<String16>& objectGroup, Maybe<String16> objectGroup, Maybe<bool> includeCommandLineAPI,
const Maybe<bool>& includeCommandLineAPI, const Maybe<bool>& silent, Maybe<bool> silent, Maybe<bool> returnByValue,
const Maybe<bool>& returnByValue, const Maybe<bool>& generatePreview, Maybe<bool> generatePreview,
std::unique_ptr<protocol::Runtime::RemoteObject>* result, std::unique_ptr<protocol::Runtime::RemoteObject>* result,
Maybe<protocol::Runtime::ExceptionDetails>*) override; Maybe<protocol::Runtime::ExceptionDetails>*) override;
void setVariableValue( Response setVariableValue(
ErrorString*, int scopeNumber, const String16& variableName, int scopeNumber, const String16& variableName,
std::unique_ptr<protocol::Runtime::CallArgument> newValue, std::unique_ptr<protocol::Runtime::CallArgument> newValue,
const String16& callFrame) override; const String16& callFrame) override;
void setAsyncCallStackDepth(ErrorString*, int depth) override; Response setAsyncCallStackDepth(int depth) override;
void setBlackboxPatterns( Response setBlackboxPatterns(
ErrorString*,
std::unique_ptr<protocol::Array<String16>> patterns) override; std::unique_ptr<protocol::Array<String16>> patterns) override;
void setBlackboxedRanges( Response setBlackboxedRanges(
ErrorString*, const String16& scriptId, const String16& scriptId,
std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>>
positions) override; positions) override;
...@@ -144,16 +141,15 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { ...@@ -144,16 +141,15 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
v8::Isolate* isolate() { return m_isolate; } v8::Isolate* isolate() { return m_isolate; }
private: private:
bool checkEnabled(ErrorString*); void enableImpl();
void enable();
SkipPauseRequest shouldSkipExceptionPause(JavaScriptCallFrame* topCallFrame); SkipPauseRequest shouldSkipExceptionPause(JavaScriptCallFrame* topCallFrame);
SkipPauseRequest shouldSkipStepPause(JavaScriptCallFrame* topCallFrame); SkipPauseRequest shouldSkipStepPause(JavaScriptCallFrame* topCallFrame);
void schedulePauseOnNextStatementIfSteppingInto(); void schedulePauseOnNextStatementIfSteppingInto();
std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>> Response currentCallFrames(
currentCallFrames(ErrorString*); std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>*);
std::unique_ptr<protocol::Runtime::StackTrace> currentAsyncStackTrace(); std::unique_ptr<protocol::Runtime::StackTrace> currentAsyncStackTrace();
void changeJavaScriptRecursionLevel(int step); void changeJavaScriptRecursionLevel(int step);
...@@ -163,8 +159,7 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { ...@@ -163,8 +159,7 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
std::unique_ptr<protocol::Debugger::Location> resolveBreakpoint( std::unique_ptr<protocol::Debugger::Location> resolveBreakpoint(
const String16& breakpointId, const String16& scriptId, const String16& breakpointId, const String16& scriptId,
const ScriptBreakpoint&, BreakpointSource); const ScriptBreakpoint&, BreakpointSource);
void removeBreakpoint(const String16& breakpointId); void removeBreakpointImpl(const String16& breakpointId);
bool assertPaused(ErrorString*);
void clearBreakDetails(); void clearBreakDetails();
bool isCurrentCallStackEmptyOrBlackboxed(); bool isCurrentCallStackEmptyOrBlackboxed();
...@@ -174,7 +169,7 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend { ...@@ -174,7 +169,7 @@ class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
void internalSetAsyncCallStackDepth(int); void internalSetAsyncCallStackDepth(int);
void increaseCachedSkipStackGeneration(); void increaseCachedSkipStackGeneration();
bool setBlackboxPattern(ErrorString*, const String16& pattern); Response setBlackboxPattern(const String16& pattern);
using ScriptsMap = using ScriptsMap =
protocol::HashMap<String16, std::unique_ptr<V8DebuggerScript>>; protocol::HashMap<String16, std::unique_ptr<V8DebuggerScript>>;
......
...@@ -329,11 +329,11 @@ void V8Debugger::clearStepping() { ...@@ -329,11 +329,11 @@ void V8Debugger::clearStepping() {
v8::DebugInterface::ClearStepping(m_isolate); v8::DebugInterface::ClearStepping(m_isolate);
} }
bool V8Debugger::setScriptSource( Response V8Debugger::setScriptSource(
const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun,
ErrorString* error,
Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails,
JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged) { JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged,
bool* compileError) {
class EnableLiveEditScope { class EnableLiveEditScope {
public: public:
explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) {
...@@ -349,6 +349,7 @@ bool V8Debugger::setScriptSource( ...@@ -349,6 +349,7 @@ bool V8Debugger::setScriptSource(
v8::Isolate* m_isolate; v8::Isolate* m_isolate;
}; };
*compileError = false;
DCHECK(enabled()); DCHECK(enabled());
v8::HandleScope scope(m_isolate); v8::HandleScope scope(m_isolate);
...@@ -369,10 +370,9 @@ bool V8Debugger::setScriptSource( ...@@ -369,10 +370,9 @@ bool V8Debugger::setScriptSource(
if (tryCatch.HasCaught()) { if (tryCatch.HasCaught()) {
v8::Local<v8::Message> message = tryCatch.Message(); v8::Local<v8::Message> message = tryCatch.Message();
if (!message.IsEmpty()) if (!message.IsEmpty())
*error = toProtocolStringWithTypeCheck(message->Get()); return Response::Error(toProtocolStringWithTypeCheck(message->Get()));
else else
*error = "Unknown error."; return Response::InternalError();
return false;
} }
v8result = maybeResult.ToLocalChecked(); v8result = maybeResult.ToLocalChecked();
} }
...@@ -397,7 +397,7 @@ bool V8Debugger::setScriptSource( ...@@ -397,7 +397,7 @@ bool V8Debugger::setScriptSource(
JavaScriptCallFrames frames = currentCallFrames(); JavaScriptCallFrames frames = currentCallFrames();
newCallFrames->swap(frames); newCallFrames->swap(frames);
} }
return true; return Response::OK();
} }
// Compile error. // Compile error.
case 1: { case 1: {
...@@ -419,11 +419,11 @@ bool V8Debugger::setScriptSource( ...@@ -419,11 +419,11 @@ bool V8Debugger::setScriptSource(
->Value()) - ->Value()) -
1) 1)
.build(); .build();
return false; *compileError = true;
return Response::OK();
} }
} }
*error = "Unknown error."; return Response::InternalError();
return false;
} }
JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) { JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) {
......
...@@ -23,7 +23,7 @@ class V8DebuggerAgentImpl; ...@@ -23,7 +23,7 @@ class V8DebuggerAgentImpl;
class V8InspectorImpl; class V8InspectorImpl;
class V8StackTraceImpl; class V8StackTraceImpl;
using protocol::ErrorString; using protocol::Response;
class V8Debugger { class V8Debugger {
public: public:
...@@ -53,12 +53,11 @@ class V8Debugger { ...@@ -53,12 +53,11 @@ class V8Debugger {
void stepOutOfFunction(); void stepOutOfFunction();
void clearStepping(); void clearStepping();
bool setScriptSource(const String16& sourceID, Response setScriptSource(
v8::Local<v8::String> newSource, bool dryRun, const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun,
ErrorString*, protocol::Maybe<protocol::Runtime::ExceptionDetails>*,
protocol::Maybe<protocol::Runtime::ExceptionDetails>*, JavaScriptCallFrames* newCallFrames, protocol::Maybe<bool>* stackChanged,
JavaScriptCallFrames* newCallFrames, bool* compileError);
protocol::Maybe<bool>* stackChanged);
JavaScriptCallFrames currentCallFrames(int limit = 0); JavaScriptCallFrames currentCallFrames(int limit = 0);
// Each script inherits debug data from v8::Context where it has been // Each script inherits debug data from v8::Context where it has been
......
...@@ -104,11 +104,10 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, ...@@ -104,11 +104,10 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector,
} }
V8InspectorSessionImpl::~V8InspectorSessionImpl() { V8InspectorSessionImpl::~V8InspectorSessionImpl() {
protocol::ErrorString errorString;
m_consoleAgent->disable(); m_consoleAgent->disable();
m_profilerAgent->disable(); m_profilerAgent->disable();
m_heapProfilerAgent->disable(); m_heapProfilerAgent->disable();
m_debuggerAgent->disable(&errorString); m_debuggerAgent->disable();
m_runtimeAgent->disable(); m_runtimeAgent->disable();
discardInjectedScripts(); discardInjectedScripts();
...@@ -382,19 +381,12 @@ void V8InspectorSessionImpl::breakProgram(const StringView& breakReason, ...@@ -382,19 +381,12 @@ void V8InspectorSessionImpl::breakProgram(const StringView& breakReason,
} }
void V8InspectorSessionImpl::setSkipAllPauses(bool skip) { void V8InspectorSessionImpl::setSkipAllPauses(bool skip) {
protocol::ErrorString errorString; m_debuggerAgent->setSkipAllPauses(skip);
m_debuggerAgent->setSkipAllPauses(&errorString, skip);
} }
void V8InspectorSessionImpl::resume() { void V8InspectorSessionImpl::resume() { m_debuggerAgent->resume(); }
protocol::ErrorString errorString;
m_debuggerAgent->resume(&errorString);
}
void V8InspectorSessionImpl::stepOver() { void V8InspectorSessionImpl::stepOver() { m_debuggerAgent->stepOver(); }
protocol::ErrorString errorString;
m_debuggerAgent->stepOver(&errorString);
}
std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>>
V8InspectorSessionImpl::searchInTextByLines(const StringView& text, V8InspectorSessionImpl::searchInTextByLines(const StringView& text,
......
...@@ -330,8 +330,7 @@ def resolve_type(protocol, prop): ...@@ -330,8 +330,7 @@ def resolve_type(protocol, prop):
def new_style(domain): def new_style(domain):
domains = [ "Schema", "Console", "Profiler", "HeapProfiler", "Runtime" ] return True
return domain["domain"] in domains
def join_arrays(dict, keys): def join_arrays(dict, keys):
......
...@@ -14,5 +14,4 @@ description. ...@@ -14,5 +14,4 @@ description.
Local modifications: Local modifications:
- This only includes the lib/ and templates/ directories, scripts, build - This only includes the lib/ and templates/ directories, scripts, build
and the LICENSE files. and the LICENSE files.
- New style domains [ "Schema", "Console", "Profiler", "HeapProfiler", - Used new style for all domains d in CodeGenerator.py.
"Runtime" ] are added in CodeGenerator.py.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment