Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/inspector/v8-debugger-agent-impl.h" | 5 #include "src/inspector/v8-debugger-agent-impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/debug/debug-interface.h" | 9 #include "src/debug/debug-interface.h" |
| 10 #include "src/inspector/injected-script.h" | 10 #include "src/inspector/injected-script.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 | 56 |
| 57 static const int kMaxSkipStepFrameCount = 128; | 57 static const int kMaxSkipStepFrameCount = 128; |
| 58 static const char kBacktraceObjectGroup[] = "backtrace"; | 58 static const char kBacktraceObjectGroup[] = "backtrace"; |
| 59 static const char kDebuggerNotEnabled[] = "Debugger agent is not enabled"; | 59 static const char kDebuggerNotEnabled[] = "Debugger agent is not enabled"; |
| 60 static const char kDebuggerNotPaused[] = | 60 static const char kDebuggerNotPaused[] = |
| 61 "Can only perform operation while paused."; | 61 "Can only perform operation while paused."; |
| 62 | 62 |
| 63 namespace { | 63 namespace { |
| 64 | 64 |
| 65 void TranslateWasmStackTraceLocations(Array<CallFrame>* stackTrace, | 65 void TranslateWasmStackTraceLocations(Array<CallFrame>* stackTrace, |
| 66 WasmTranslation* wasmTranslation, | 66 WasmTranslation* wasmTranslation) { |
| 67 int context_group_id) { | |
| 68 for (size_t i = 0, e = stackTrace->length(); i != e; ++i) { | 67 for (size_t i = 0, e = stackTrace->length(); i != e; ++i) { |
| 69 protocol::Debugger::Location* location = stackTrace->get(i)->getLocation(); | 68 protocol::Debugger::Location* location = stackTrace->get(i)->getLocation(); |
| 70 String16 scriptId = location->getScriptId(); | 69 String16 scriptId = location->getScriptId(); |
| 71 int lineNumber = location->getLineNumber(); | 70 int lineNumber = location->getLineNumber(); |
| 72 int columnNumber = location->getColumnNumber(-1); | 71 int columnNumber = location->getColumnNumber(-1); |
| 73 | 72 |
| 74 if (!wasmTranslation->TranslateWasmScriptLocationToProtocolLocation( | 73 if (!wasmTranslation->TranslateWasmScriptLocationToProtocolLocation( |
| 75 &scriptId, &lineNumber, &columnNumber, context_group_id)) { | 74 &scriptId, &lineNumber, &columnNumber)) { |
| 76 continue; | 75 continue; |
| 77 } | 76 } |
| 78 | 77 |
| 79 location->setScriptId(std::move(scriptId)); | 78 location->setScriptId(std::move(scriptId)); |
| 80 location->setLineNumber(lineNumber); | 79 location->setLineNumber(lineNumber); |
| 81 location->setColumnNumber(columnNumber); | 80 location->setColumnNumber(columnNumber); |
| 82 } | 81 } |
| 83 } | 82 } |
| 84 | 83 |
| 85 String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) { | 84 String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) { |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 // FIXME: remove these checks once crbug.com/520702 is resolved. | 518 // FIXME: remove these checks once crbug.com/520702 is resolved. |
| 520 CHECK(!breakpointId.isEmpty()); | 519 CHECK(!breakpointId.isEmpty()); |
| 521 CHECK(!breakpoint.script_id.isEmpty()); | 520 CHECK(!breakpoint.script_id.isEmpty()); |
| 522 ScriptsMap::iterator scriptIterator = m_scripts.find(breakpoint.script_id); | 521 ScriptsMap::iterator scriptIterator = m_scripts.find(breakpoint.script_id); |
| 523 if (scriptIterator == m_scripts.end()) return nullptr; | 522 if (scriptIterator == m_scripts.end()) return nullptr; |
| 524 if (breakpoint.line_number < scriptIterator->second->startLine() || | 523 if (breakpoint.line_number < scriptIterator->second->startLine() || |
| 525 scriptIterator->second->endLine() < breakpoint.line_number) | 524 scriptIterator->second->endLine() < breakpoint.line_number) |
| 526 return nullptr; | 525 return nullptr; |
| 527 | 526 |
| 528 ScriptBreakpoint translatedBreakpoint = breakpoint; | 527 ScriptBreakpoint translatedBreakpoint = breakpoint; |
| 529 if (m_scripts.count(breakpoint.script_id) == 0) { | 528 if (m_scripts.count(breakpoint.script_id) == 0) { |
|
dgozman
2016/12/02 00:52:01
Do we need this now?
Clemens Hammacher
2016/12/02 09:23:47
No, this check is wrong now. I removed it.
| |
| 530 m_debugger->wasmTranslation() | 529 m_debugger->wasmTranslation() |
| 531 ->TranslateProtocolLocationToWasmScriptLocation( | 530 ->TranslateProtocolLocationToWasmScriptLocation( |
| 532 &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, | 531 &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, |
| 533 &translatedBreakpoint.column_number); | 532 &translatedBreakpoint.column_number); |
| 534 } | 533 } |
| 535 | 534 |
| 536 int actualLineNumber; | 535 int actualLineNumber; |
| 537 int actualColumnNumber; | 536 int actualColumnNumber; |
| 538 String16 debuggerBreakpointId = m_debugger->setBreakpoint( | 537 String16 debuggerBreakpointId = m_debugger->setBreakpoint( |
| 539 translatedBreakpoint, &actualLineNumber, &actualColumnNumber); | 538 translatedBreakpoint, &actualLineNumber, &actualColumnNumber); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 return Response::InternalError(); | 1025 return Response::InternalError(); |
| 1027 } | 1026 } |
| 1028 } | 1027 } |
| 1029 | 1028 |
| 1030 std::unique_ptr<protocol::Value> protocolValue; | 1029 std::unique_ptr<protocol::Value> protocolValue; |
| 1031 Response response = toProtocolValue(debuggerContext, objects, &protocolValue); | 1030 Response response = toProtocolValue(debuggerContext, objects, &protocolValue); |
| 1032 if (!response.isSuccess()) return response; | 1031 if (!response.isSuccess()) return response; |
| 1033 protocol::ErrorSupport errorSupport; | 1032 protocol::ErrorSupport errorSupport; |
| 1034 *result = Array<CallFrame>::fromValue(protocolValue.get(), &errorSupport); | 1033 *result = Array<CallFrame>::fromValue(protocolValue.get(), &errorSupport); |
| 1035 if (!*result) return Response::Error(errorSupport.errors()); | 1034 if (!*result) return Response::Error(errorSupport.errors()); |
| 1036 TranslateWasmStackTraceLocations(result->get(), m_debugger->wasmTranslation(), | 1035 TranslateWasmStackTraceLocations(result->get(), |
| 1037 m_session->contextGroupId()); | 1036 m_debugger->wasmTranslation()); |
| 1038 return Response::OK(); | 1037 return Response::OK(); |
| 1039 } | 1038 } |
| 1040 | 1039 |
| 1041 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() { | 1040 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() { |
| 1042 if (m_pausedContext.IsEmpty()) return nullptr; | 1041 if (m_pausedContext.IsEmpty()) return nullptr; |
| 1043 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); | 1042 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); |
| 1044 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) | 1043 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) |
| 1045 : nullptr; | 1044 : nullptr; |
| 1046 } | 1045 } |
| 1047 | 1046 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 | 1265 |
| 1267 void V8DebuggerAgentImpl::reset() { | 1266 void V8DebuggerAgentImpl::reset() { |
| 1268 if (!enabled()) return; | 1267 if (!enabled()) return; |
| 1269 m_scheduledDebuggerStep = NoStep; | 1268 m_scheduledDebuggerStep = NoStep; |
| 1270 m_scripts.clear(); | 1269 m_scripts.clear(); |
| 1271 m_blackboxedPositions.clear(); | 1270 m_blackboxedPositions.clear(); |
| 1272 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1271 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1273 } | 1272 } |
| 1274 | 1273 |
| 1275 } // namespace v8_inspector | 1274 } // namespace v8_inspector |
| OLD | NEW |