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 m_debugger->wasmTranslation()->TranslateProtocolLocationToWasmScriptLocation( |
530 m_debugger->wasmTranslation() | 529 &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, |
531 ->TranslateProtocolLocationToWasmScriptLocation( | 530 &translatedBreakpoint.column_number); |
532 &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, | |
533 &translatedBreakpoint.column_number); | |
534 } | |
535 | 531 |
536 int actualLineNumber; | 532 int actualLineNumber; |
537 int actualColumnNumber; | 533 int actualColumnNumber; |
538 String16 debuggerBreakpointId = m_debugger->setBreakpoint( | 534 String16 debuggerBreakpointId = m_debugger->setBreakpoint( |
539 translatedBreakpoint, &actualLineNumber, &actualColumnNumber); | 535 translatedBreakpoint, &actualLineNumber, &actualColumnNumber); |
540 if (debuggerBreakpointId.isEmpty()) return nullptr; | 536 if (debuggerBreakpointId.isEmpty()) return nullptr; |
541 | 537 |
542 m_serverBreakpoints[debuggerBreakpointId] = | 538 m_serverBreakpoints[debuggerBreakpointId] = |
543 std::make_pair(breakpointId, source); | 539 std::make_pair(breakpointId, source); |
544 CHECK(!breakpointId.isEmpty()); | 540 CHECK(!breakpointId.isEmpty()); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 return Response::InternalError(); | 1022 return Response::InternalError(); |
1027 } | 1023 } |
1028 } | 1024 } |
1029 | 1025 |
1030 std::unique_ptr<protocol::Value> protocolValue; | 1026 std::unique_ptr<protocol::Value> protocolValue; |
1031 Response response = toProtocolValue(debuggerContext, objects, &protocolValue); | 1027 Response response = toProtocolValue(debuggerContext, objects, &protocolValue); |
1032 if (!response.isSuccess()) return response; | 1028 if (!response.isSuccess()) return response; |
1033 protocol::ErrorSupport errorSupport; | 1029 protocol::ErrorSupport errorSupport; |
1034 *result = Array<CallFrame>::fromValue(protocolValue.get(), &errorSupport); | 1030 *result = Array<CallFrame>::fromValue(protocolValue.get(), &errorSupport); |
1035 if (!*result) return Response::Error(errorSupport.errors()); | 1031 if (!*result) return Response::Error(errorSupport.errors()); |
1036 TranslateWasmStackTraceLocations(result->get(), m_debugger->wasmTranslation(), | 1032 TranslateWasmStackTraceLocations(result->get(), |
1037 m_session->contextGroupId()); | 1033 m_debugger->wasmTranslation()); |
1038 return Response::OK(); | 1034 return Response::OK(); |
1039 } | 1035 } |
1040 | 1036 |
1041 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() { | 1037 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() { |
1042 if (m_pausedContext.IsEmpty()) return nullptr; | 1038 if (m_pausedContext.IsEmpty()) return nullptr; |
1043 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); | 1039 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); |
1044 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) | 1040 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) |
1045 : nullptr; | 1041 : nullptr; |
1046 } | 1042 } |
1047 | 1043 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 | 1262 |
1267 void V8DebuggerAgentImpl::reset() { | 1263 void V8DebuggerAgentImpl::reset() { |
1268 if (!enabled()) return; | 1264 if (!enabled()) return; |
1269 m_scheduledDebuggerStep = NoStep; | 1265 m_scheduledDebuggerStep = NoStep; |
1270 m_scripts.clear(); | 1266 m_scripts.clear(); |
1271 m_blackboxedPositions.clear(); | 1267 m_blackboxedPositions.clear(); |
1272 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1268 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1273 } | 1269 } |
1274 | 1270 |
1275 } // namespace v8_inspector | 1271 } // namespace v8_inspector |
OLD | NEW |