Index: src/inspector/v8-debugger-agent-impl.cc |
diff --git a/src/inspector/v8-debugger-agent-impl.cc b/src/inspector/v8-debugger-agent-impl.cc |
index 3e1174e8a1ed394730e35c822f26b12ea5b6c301..45713b508be029bd0993c864715b6ce922663384 100644 |
--- a/src/inspector/v8-debugger-agent-impl.cc |
+++ b/src/inspector/v8-debugger-agent-impl.cc |
@@ -60,8 +60,37 @@ static const char kDebuggerNotEnabled[] = "Debugger agent is not enabled"; |
static const char kDebuggerNotPaused[] = |
"Can only perform operation while paused."; |
-static String16 breakpointIdSuffix( |
- V8DebuggerAgentImpl::BreakpointSource source) { |
+namespace { |
+ |
+void TranslateWasmStackTraceLocations(Array<CallFrame>* stackTrace, |
+ WasmTranslation* wasmTranslation) { |
+ for (size_t i = 0, e = stackTrace->length(); i != e; ++i) { |
+ protocol::Debugger::Location* location = stackTrace->get(i)->getLocation(); |
+ String16 scriptId = location->getScriptId(); |
+ int lineNumber = location->getLineNumber(); |
+ int columnNumber = location->getColumnNumber(-1); |
+ |
+ if (!wasmTranslation->TranslateWasmScriptLocationToProtocolLocation( |
+ &scriptId, &lineNumber, &columnNumber)) { |
+ continue; |
+ } |
+ |
+ location->setScriptId(std::move(scriptId)); |
+ location->setLineNumber(lineNumber); |
+ location->setColumnNumber(columnNumber); |
+ } |
+} |
+ |
+ScriptBreakpoint TranslateBackWasmScriptBreakpoint( |
+ const ScriptBreakpoint& breakpoint, WasmTranslation* translation) { |
+ ScriptBreakpoint translatedBreakpoint = breakpoint; |
+ translation->TranslateProtocolLocationToWasmScriptLocation( |
+ &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, |
+ &translatedBreakpoint.column_number); |
+ return translatedBreakpoint; |
+} |
+ |
+String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) { |
switch (source) { |
case V8DebuggerAgentImpl::UserBreakpointSource: |
break; |
@@ -73,9 +102,8 @@ static String16 breakpointIdSuffix( |
return String16(); |
} |
-static String16 generateBreakpointId( |
- const ScriptBreakpoint& breakpoint, |
- V8DebuggerAgentImpl::BreakpointSource source) { |
+String16 generateBreakpointId(const ScriptBreakpoint& breakpoint, |
+ V8DebuggerAgentImpl::BreakpointSource source) { |
String16Builder builder; |
builder.append(breakpoint.script_id); |
builder.append(':'); |
@@ -86,13 +114,13 @@ static String16 generateBreakpointId( |
return builder.toString(); |
} |
-static bool positionComparator(const std::pair<int, int>& a, |
- const std::pair<int, int>& b) { |
+bool positionComparator(const std::pair<int, int>& a, |
+ const std::pair<int, int>& b) { |
if (a.first != b.first) return a.first < b.first; |
return a.second < b.second; |
} |
-static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation( |
+std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation( |
const String16& scriptId, int lineNumber, int columnNumber) { |
return protocol::Debugger::Location::create() |
.setScriptId(scriptId) |
@@ -101,6 +129,8 @@ static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation( |
.build(); |
} |
+} // namespace |
+ |
V8DebuggerAgentImpl::V8DebuggerAgentImpl( |
V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, |
protocol::DictionaryValue* state) |
@@ -120,7 +150,8 @@ V8DebuggerAgentImpl::V8DebuggerAgentImpl( |
m_skippedStepFrameCount(0), |
m_recursionLevelForStepOut(0), |
m_recursionLevelForStepFrame(0), |
- m_skipAllPauses(false) { |
+ m_skipAllPauses(false), |
+ m_wasmTranslation(m_isolate, this) { |
clearBreakDetails(); |
} |
@@ -187,6 +218,7 @@ Response V8DebuggerAgentImpl::disable() { |
m_state->remove(DebuggerAgentState::blackboxPattern); |
m_enabled = false; |
m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); |
+ m_wasmTranslation.Clear(); |
return Response::OK(); |
} |
@@ -503,10 +535,13 @@ V8DebuggerAgentImpl::resolveBreakpoint(const String16& breakpointId, |
scriptIterator->second->endLine() < breakpoint.line_number) |
return nullptr; |
+ ScriptBreakpoint translatedBreakpoint = |
+ TranslateBackWasmScriptBreakpoint(breakpoint, &m_wasmTranslation); |
dgozman
2016/11/16 19:00:09
Why do we always do this? Let's check whether the
Clemens Hammacher
2016/11/16 20:31:30
The translation will only translate something for
|
+ |
int actualLineNumber; |
int actualColumnNumber; |
String16 debuggerBreakpointId = m_debugger->setBreakpoint( |
- breakpoint, &actualLineNumber, &actualColumnNumber); |
+ translatedBreakpoint, &actualLineNumber, &actualColumnNumber); |
if (debuggerBreakpointId.isEmpty()) return nullptr; |
m_serverBreakpoints[debuggerBreakpointId] = |
@@ -515,7 +550,7 @@ V8DebuggerAgentImpl::resolveBreakpoint(const String16& breakpointId, |
m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back( |
debuggerBreakpointId); |
- return buildProtocolLocation(breakpoint.script_id, actualLineNumber, |
+ return buildProtocolLocation(translatedBreakpoint.script_id, actualLineNumber, |
actualColumnNumber); |
} |
@@ -529,9 +564,8 @@ Response V8DebuggerAgentImpl::searchInContent( |
return Response::Error("No script for id: " + scriptId); |
std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = |
- searchInTextByLinesImpl(m_session, |
- toProtocolString(it->second->source(m_isolate)), |
- query, optionalCaseSensitive.fromMaybe(false), |
+ searchInTextByLinesImpl(m_session, it->second->source(m_isolate), query, |
+ optionalCaseSensitive.fromMaybe(false), |
optionalIsRegex.fromMaybe(false)); |
*results = protocol::Array<protocol::Debugger::SearchMatch>::create(); |
for (size_t i = 0; i < matches.size(); ++i) |
@@ -602,7 +636,7 @@ Response V8DebuggerAgentImpl::getScriptSource(const String16& scriptId, |
if (it == m_scripts.end()) |
return Response::Error("No script for id: " + scriptId); |
v8::HandleScope handles(m_isolate); |
- *scriptSource = toProtocolString(it->second->source(m_isolate)); |
+ *scriptSource = it->second->source(m_isolate); |
return Response::OK(); |
} |
@@ -861,6 +895,10 @@ void V8DebuggerAgentImpl::didExecuteScript() { |
changeJavaScriptRecursionLevel(-1); |
} |
+void V8DebuggerAgentImpl::newWasmScript(v8::Local<v8::Object> scriptWrapper) { |
+ m_wasmTranslation.AddScript(scriptWrapper); |
+} |
+ |
void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) { |
if (m_javaScriptPauseScheduled && !m_skipAllPauses && |
!m_debugger->isPaused()) { |
@@ -1004,6 +1042,7 @@ Response V8DebuggerAgentImpl::currentCallFrames( |
protocol::ErrorSupport errorSupport; |
*result = Array<CallFrame>::parse(protocolValue.get(), &errorSupport); |
if (!*result) return Response::Error(errorSupport.errors()); |
+ TranslateWasmStackTraceLocations(result->get(), &m_wasmTranslation); |
dgozman
2016/11/16 19:00:10
Why do we need this? I thought code in V8StackTrac
Clemens Hammacher
2016/11/16 20:31:30
V8StackTraceImpl is only used to transfer material
|
return Response::OK(); |
} |
@@ -1017,7 +1056,7 @@ std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() { |
void V8DebuggerAgentImpl::didParseSource( |
std::unique_ptr<V8DebuggerScript> script, bool success) { |
v8::HandleScope handles(m_isolate); |
- String16 scriptSource = toProtocolString(script->source(m_isolate)); |
+ String16 scriptSource = script->source(m_isolate); |
if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); |
if (!success) |
script->setSourceMappingURL(findSourceMapURL(scriptSource, false)); |
@@ -1046,14 +1085,14 @@ void V8DebuggerAgentImpl::didParseSource( |
m_frontend.scriptParsed( |
scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), |
scriptRef->endLine(), scriptRef->endColumn(), |
- scriptRef->executionContextId(), scriptRef->hash(), |
+ scriptRef->executionContextId(), scriptRef->hash(m_isolate), |
std::move(executionContextAuxDataParam), isLiveEditParam, |
std::move(sourceMapURLParam), hasSourceURLParam); |
else |
m_frontend.scriptFailedToParse( |
scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), |
scriptRef->endLine(), scriptRef->endColumn(), |
- scriptRef->executionContextId(), scriptRef->hash(), |
+ scriptRef->executionContextId(), scriptRef->hash(m_isolate), |
std::move(executionContextAuxDataParam), std::move(sourceMapURLParam), |
hasSourceURLParam); |