| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 Response V8DebuggerAgentImpl::disable() { | 168 Response V8DebuggerAgentImpl::disable() { |
| 169 if (!enabled()) return Response::OK(); | 169 if (!enabled()) return Response::OK(); |
| 170 | 170 |
| 171 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, | 171 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, |
| 172 protocol::DictionaryValue::create()); | 172 protocol::DictionaryValue::create()); |
| 173 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, | 173 m_state->setInteger(DebuggerAgentState::pauseOnExceptionsState, |
| 174 v8::debug::NoBreakOnException); | 174 v8::debug::NoBreakOnException); |
| 175 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); | 175 m_state->setInteger(DebuggerAgentState::asyncCallStackDepth, 0); |
| 176 | 176 |
| 177 if (isPaused()) m_debugger->continueProgram(); | 177 if (isPaused()) m_debugger->continueProgram(); |
| 178 |
| 179 { |
| 180 v8::HandleScope scope(m_isolate); |
| 181 for (const auto& it : m_idToBreakpoints) removeBreakpointImpl(it.first); |
| 182 } |
| 183 |
| 178 m_debugger->disable(); | 184 m_debugger->disable(); |
| 179 JavaScriptCallFrames emptyCallFrames; | 185 JavaScriptCallFrames emptyCallFrames; |
| 180 m_pausedCallFrames.swap(emptyCallFrames); | 186 m_pausedCallFrames.swap(emptyCallFrames); |
| 181 m_blackboxedPositions.clear(); | 187 m_blackboxedPositions.clear(); |
| 182 m_blackboxPattern.reset(); | 188 m_blackboxPattern.reset(); |
| 183 resetBlackboxedStateCache(); | 189 resetBlackboxedStateCache(); |
| 184 m_scripts.clear(); | 190 m_scripts.clear(); |
| 185 m_breakpointIdToDebuggerBreakpointIds.clear(); | 191 m_idToBreakpoints.clear(); |
| 192 m_breakpointIdToSource.clear(); |
| 186 m_debugger->setAsyncCallStackDepth(this, 0); | 193 m_debugger->setAsyncCallStackDepth(this, 0); |
| 187 m_continueToLocationBreakpointId = String16(); | 194 m_continueToLocationBreakpoint.Reset(); |
| 188 clearBreakDetails(); | 195 clearBreakDetails(); |
| 189 m_scheduledDebuggerStep = NoStep; | 196 m_scheduledDebuggerStep = NoStep; |
| 190 m_javaScriptPauseScheduled = false; | 197 m_javaScriptPauseScheduled = false; |
| 191 m_skipAllPauses = false; | 198 m_skipAllPauses = false; |
| 192 m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); | 199 m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); |
| 193 m_state->remove(DebuggerAgentState::blackboxPattern); | 200 m_state->remove(DebuggerAgentState::blackboxPattern); |
| 194 m_enabled = false; | 201 m_enabled = false; |
| 195 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); | 202 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); |
| 196 return Response::OK(); | 203 return Response::OK(); |
| 197 } | 204 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 Response V8DebuggerAgentImpl::setBreakpoint( | 321 Response V8DebuggerAgentImpl::setBreakpoint( |
| 315 std::unique_ptr<protocol::Debugger::Location> location, | 322 std::unique_ptr<protocol::Debugger::Location> location, |
| 316 Maybe<String16> optionalCondition, String16* outBreakpointId, | 323 Maybe<String16> optionalCondition, String16* outBreakpointId, |
| 317 std::unique_ptr<protocol::Debugger::Location>* actualLocation) { | 324 std::unique_ptr<protocol::Debugger::Location>* actualLocation) { |
| 318 ScriptBreakpoint breakpoint( | 325 ScriptBreakpoint breakpoint( |
| 319 location->getScriptId(), location->getLineNumber(), | 326 location->getScriptId(), location->getLineNumber(), |
| 320 location->getColumnNumber(0), optionalCondition.fromMaybe(String16())); | 327 location->getColumnNumber(0), optionalCondition.fromMaybe(String16())); |
| 321 | 328 |
| 322 String16 breakpointId = | 329 String16 breakpointId = |
| 323 generateBreakpointId(breakpoint, UserBreakpointSource); | 330 generateBreakpointId(breakpoint, UserBreakpointSource); |
| 324 if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) != | 331 if (m_idToBreakpoints.find(breakpointId) != m_idToBreakpoints.end()) { |
| 325 m_breakpointIdToDebuggerBreakpointIds.end()) { | |
| 326 return Response::Error("Breakpoint at specified location already exists."); | 332 return Response::Error("Breakpoint at specified location already exists."); |
| 327 } | 333 } |
| 328 *actualLocation = | 334 *actualLocation = |
| 329 resolveBreakpoint(breakpointId, breakpoint, UserBreakpointSource); | 335 resolveBreakpoint(breakpointId, breakpoint, UserBreakpointSource); |
| 330 if (!*actualLocation) return Response::Error("Could not resolve breakpoint"); | 336 if (!*actualLocation) return Response::Error("Could not resolve breakpoint"); |
| 331 *outBreakpointId = breakpointId; | 337 *outBreakpointId = breakpointId; |
| 332 return Response::OK(); | 338 return Response::OK(); |
| 333 } | 339 } |
| 334 | 340 |
| 335 Response V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) { | 341 Response V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) { |
| 336 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 342 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
| 337 protocol::DictionaryValue* breakpointsCookie = | 343 protocol::DictionaryValue* breakpointsCookie = |
| 338 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); | 344 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); |
| 339 if (breakpointsCookie) breakpointsCookie->remove(breakpointId); | 345 if (breakpointsCookie) breakpointsCookie->remove(breakpointId); |
| 340 removeBreakpointImpl(breakpointId); | 346 removeBreakpointImpl(breakpointId); |
| 341 return Response::OK(); | 347 return Response::OK(); |
| 342 } | 348 } |
| 343 | 349 |
| 344 void V8DebuggerAgentImpl::removeBreakpointImpl(const String16& breakpointId) { | 350 void V8DebuggerAgentImpl::removeBreakpointImpl(const String16& breakpointId) { |
| 345 DCHECK(enabled()); | 351 DCHECK(enabled()); |
| 346 BreakpointIdToDebuggerBreakpointIdsMap::iterator | 352 auto it = m_idToBreakpoints.find(breakpointId); |
| 347 debuggerBreakpointIdsIterator = | 353 if (it == m_idToBreakpoints.end()) return; |
| 348 m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); | 354 v8::HandleScope scope(m_isolate); |
| 349 if (debuggerBreakpointIdsIterator == | 355 for (const auto& breakpoint : it->second) { |
| 350 m_breakpointIdToDebuggerBreakpointIds.end()) | 356 v8::debug::ClearBreakPoint(m_isolate, breakpoint.Get(m_isolate)); |
| 351 return; | |
| 352 const std::vector<String16>& ids = debuggerBreakpointIdsIterator->second; | |
| 353 for (size_t i = 0; i < ids.size(); ++i) { | |
| 354 const String16& debuggerBreakpointId = ids[i]; | |
| 355 | |
| 356 m_debugger->removeBreakpoint(debuggerBreakpointId); | |
| 357 m_serverBreakpoints.erase(debuggerBreakpointId); | |
| 358 } | 357 } |
| 359 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); | 358 m_breakpointIdToSource.erase(it->first); |
| 359 m_idToBreakpoints.erase(it); |
| 360 } | 360 } |
| 361 | 361 |
| 362 Response V8DebuggerAgentImpl::getPossibleBreakpoints( | 362 Response V8DebuggerAgentImpl::getPossibleBreakpoints( |
| 363 std::unique_ptr<protocol::Debugger::Location> start, | 363 std::unique_ptr<protocol::Debugger::Location> start, |
| 364 Maybe<protocol::Debugger::Location> end, | 364 Maybe<protocol::Debugger::Location> end, |
| 365 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) { | 365 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) { |
| 366 String16 scriptId = start->getScriptId(); | 366 String16 scriptId = start->getScriptId(); |
| 367 | 367 |
| 368 if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) | 368 if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) |
| 369 return Response::Error( | 369 return Response::Error( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 397 .setLineNumber(v8Locations[i].GetLineNumber()) | 397 .setLineNumber(v8Locations[i].GetLineNumber()) |
| 398 .setColumnNumber(v8Locations[i].GetColumnNumber()) | 398 .setColumnNumber(v8Locations[i].GetColumnNumber()) |
| 399 .build()); | 399 .build()); |
| 400 } | 400 } |
| 401 return Response::OK(); | 401 return Response::OK(); |
| 402 } | 402 } |
| 403 | 403 |
| 404 Response V8DebuggerAgentImpl::continueToLocation( | 404 Response V8DebuggerAgentImpl::continueToLocation( |
| 405 std::unique_ptr<protocol::Debugger::Location> location) { | 405 std::unique_ptr<protocol::Debugger::Location> location) { |
| 406 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 406 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
| 407 if (!m_continueToLocationBreakpointId.isEmpty()) { | 407 ScriptsMap::iterator it = m_scripts.find(location->getScriptId()); |
| 408 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); | 408 if (it == m_scripts.end()) { |
| 409 m_continueToLocationBreakpointId = ""; | 409 return Response::Error("No script with given id found"); |
| 410 } | 410 } |
| 411 | 411 |
| 412 ScriptBreakpoint breakpoint(location->getScriptId(), | 412 v8::HandleScope handle_scope(m_isolate); |
| 413 location->getLineNumber(), | |
| 414 location->getColumnNumber(0), String16()); | |
| 415 | 413 |
| 416 m_continueToLocationBreakpointId = m_debugger->setBreakpoint( | 414 if (!m_continueToLocationBreakpoint.IsEmpty()) { |
| 417 breakpoint, &breakpoint.line_number, &breakpoint.column_number); | 415 v8::debug::ClearBreakPoint(m_isolate, |
| 416 m_continueToLocationBreakpoint.Get(m_isolate)); |
| 417 m_continueToLocationBreakpoint.Reset(); |
| 418 } |
| 419 |
| 420 v8::debug::Location position(location->getLineNumber(), |
| 421 location->getColumnNumber(0)); |
| 422 v8::Local<v8::debug::BreakPoint> breakPoint = v8::debug::BreakPoint::New( |
| 423 m_isolate, v8::String::Empty(m_isolate), v8::Undefined(m_isolate)); |
| 424 |
| 425 v8::debug::Location result = it->second->setBreakpoint(position, breakPoint); |
| 426 if (result.IsEmpty()) return Response::Error("Could not resolve breakpoint"); |
| 427 m_continueToLocationBreakpoint.Reset(m_isolate, breakPoint); |
| 418 // TODO(kozyatinskiy): Return actual line and column number. | 428 // TODO(kozyatinskiy): Return actual line and column number. |
| 419 return resume(); | 429 return resume(); |
| 420 } | 430 } |
| 421 | 431 |
| 422 bool V8DebuggerAgentImpl::isFunctionBlackboxed(const String16& scriptId, | 432 bool V8DebuggerAgentImpl::isFunctionBlackboxed(const String16& scriptId, |
| 423 const v8::debug::Location& start, | 433 const v8::debug::Location& start, |
| 424 const v8::debug::Location& end) { | 434 const v8::debug::Location& end) { |
| 425 ScriptsMap::iterator it = m_scripts.find(scriptId); | 435 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 426 if (it == m_scripts.end()) { | 436 if (it == m_scripts.end()) { |
| 427 // Unknown scripts are blackboxed. | 437 // Unknown scripts are blackboxed. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 if (breakpoint.line_number < scriptIterator->second->startLine() || | 477 if (breakpoint.line_number < scriptIterator->second->startLine() || |
| 468 scriptIterator->second->endLine() < breakpoint.line_number) | 478 scriptIterator->second->endLine() < breakpoint.line_number) |
| 469 return nullptr; | 479 return nullptr; |
| 470 | 480 |
| 471 // Translate from protocol location to v8 location for the debugger. | 481 // Translate from protocol location to v8 location for the debugger. |
| 472 ScriptBreakpoint translatedBreakpoint = breakpoint; | 482 ScriptBreakpoint translatedBreakpoint = breakpoint; |
| 473 m_debugger->wasmTranslation()->TranslateProtocolLocationToWasmScriptLocation( | 483 m_debugger->wasmTranslation()->TranslateProtocolLocationToWasmScriptLocation( |
| 474 &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, | 484 &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, |
| 475 &translatedBreakpoint.column_number); | 485 &translatedBreakpoint.column_number); |
| 476 | 486 |
| 477 int actualLineNumber; | 487 v8::Local<v8::String> condition = toV8String(m_isolate, breakpoint.condition); |
| 478 int actualColumnNumber; | 488 v8::Local<v8::Value> v8BreakpointId = toV8String(m_isolate, breakpointId); |
| 479 String16 debuggerBreakpointId = m_debugger->setBreakpoint( | 489 v8::Local<v8::debug::BreakPoint> breakPoint = |
| 480 translatedBreakpoint, &actualLineNumber, &actualColumnNumber); | 490 v8::debug::BreakPoint::New(m_isolate, condition, v8BreakpointId); |
| 481 if (debuggerBreakpointId.isEmpty()) return nullptr; | 491 v8::debug::Location position(translatedBreakpoint.line_number, |
| 492 translatedBreakpoint.column_number); |
| 493 v8::debug::Location result = |
| 494 scriptIterator->second->setBreakpoint(position, breakPoint); |
| 495 if (result.IsEmpty()) return nullptr; |
| 496 |
| 497 int actualLineNumber = result.GetLineNumber(); |
| 498 int actualColumnNumber = result.GetColumnNumber(); |
| 482 | 499 |
| 483 // Translate back from v8 location to protocol location for the return value. | 500 // Translate back from v8 location to protocol location for the return value. |
| 484 m_debugger->wasmTranslation()->TranslateWasmScriptLocationToProtocolLocation( | 501 m_debugger->wasmTranslation()->TranslateWasmScriptLocationToProtocolLocation( |
| 485 &translatedBreakpoint.script_id, &actualLineNumber, &actualColumnNumber); | 502 &translatedBreakpoint.script_id, &actualLineNumber, &actualColumnNumber); |
| 486 | 503 |
| 487 m_serverBreakpoints[debuggerBreakpointId] = | |
| 488 std::make_pair(breakpointId, source); | |
| 489 CHECK(!breakpointId.isEmpty()); | 504 CHECK(!breakpointId.isEmpty()); |
| 490 | 505 m_idToBreakpoints[breakpointId].emplace_back(m_isolate, breakPoint); |
| 491 m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back( | 506 m_breakpointIdToSource[breakpointId] = source; |
| 492 debuggerBreakpointId); | |
| 493 return buildProtocolLocation(translatedBreakpoint.script_id, actualLineNumber, | 507 return buildProtocolLocation(translatedBreakpoint.script_id, actualLineNumber, |
| 494 actualColumnNumber); | 508 actualColumnNumber); |
| 495 } | 509 } |
| 496 | 510 |
| 497 Response V8DebuggerAgentImpl::searchInContent( | 511 Response V8DebuggerAgentImpl::searchInContent( |
| 498 const String16& scriptId, const String16& query, | 512 const String16& scriptId, const String16& query, |
| 499 Maybe<bool> optionalCaseSensitive, Maybe<bool> optionalIsRegex, | 513 Maybe<bool> optionalCaseSensitive, Maybe<bool> optionalIsRegex, |
| 500 std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results) { | 514 std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results) { |
| 501 v8::HandleScope handles(m_isolate); | 515 v8::HandleScope handles(m_isolate); |
| 502 ScriptsMap::iterator it = m_scripts.find(scriptId); | 516 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 &breakpoint.column_number); | 1082 &breakpoint.column_number); |
| 1069 breakpointObject->getString(DebuggerAgentState::condition, | 1083 breakpointObject->getString(DebuggerAgentState::condition, |
| 1070 &breakpoint.condition); | 1084 &breakpoint.condition); |
| 1071 std::unique_ptr<protocol::Debugger::Location> location = | 1085 std::unique_ptr<protocol::Debugger::Location> location = |
| 1072 resolveBreakpoint(cookie.first, breakpoint, UserBreakpointSource); | 1086 resolveBreakpoint(cookie.first, breakpoint, UserBreakpointSource); |
| 1073 if (location) | 1087 if (location) |
| 1074 m_frontend.breakpointResolved(cookie.first, std::move(location)); | 1088 m_frontend.breakpointResolved(cookie.first, std::move(location)); |
| 1075 } | 1089 } |
| 1076 } | 1090 } |
| 1077 | 1091 |
| 1078 void V8DebuggerAgentImpl::didPause(int contextId, | 1092 void V8DebuggerAgentImpl::didPause( |
| 1079 v8::Local<v8::Value> exception, | 1093 int contextId, v8::Local<v8::Value> exception, |
| 1080 const std::vector<String16>& hitBreakpoints, | 1094 const v8::PersistentValueVector<v8::debug::BreakPoint>& hitBreakpoints, |
| 1081 bool isPromiseRejection, bool isUncaught, | 1095 bool isPromiseRejection, bool isUncaught, bool isOOMBreak) { |
| 1082 bool isOOMBreak) { | |
| 1083 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); | 1096 JavaScriptCallFrames frames = m_debugger->currentCallFrames(); |
| 1084 m_pausedCallFrames.swap(frames); | 1097 m_pausedCallFrames.swap(frames); |
| 1085 v8::HandleScope handles(m_isolate); | 1098 v8::HandleScope handles(m_isolate); |
| 1086 | 1099 |
| 1087 std::vector<BreakReason> hitReasons; | 1100 std::vector<BreakReason> hitReasons; |
| 1088 | 1101 |
| 1089 if (isOOMBreak) { | 1102 if (isOOMBreak) { |
| 1090 hitReasons.push_back( | 1103 hitReasons.push_back( |
| 1091 std::make_pair(protocol::Debugger::Paused::ReasonEnum::OOM, nullptr)); | 1104 std::make_pair(protocol::Debugger::Paused::ReasonEnum::OOM, nullptr)); |
| 1092 } else if (!exception.IsEmpty()) { | 1105 } else if (!exception.IsEmpty()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1108 breakAuxData = nullptr; | 1121 breakAuxData = nullptr; |
| 1109 } | 1122 } |
| 1110 hitReasons.push_back( | 1123 hitReasons.push_back( |
| 1111 std::make_pair(breakReason, std::move(breakAuxData))); | 1124 std::make_pair(breakReason, std::move(breakAuxData))); |
| 1112 } | 1125 } |
| 1113 } | 1126 } |
| 1114 | 1127 |
| 1115 std::unique_ptr<Array<String16>> hitBreakpointIds = Array<String16>::create(); | 1128 std::unique_ptr<Array<String16>> hitBreakpointIds = Array<String16>::create(); |
| 1116 | 1129 |
| 1117 bool hasDebugCommandBreakpointReason = false; | 1130 bool hasDebugCommandBreakpointReason = false; |
| 1118 for (const auto& point : hitBreakpoints) { | 1131 for (size_t i = 0; i < hitBreakpoints.Size(); ++i) { |
| 1119 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator | 1132 String16 id = toProtocolStringWithTypeCheck(hitBreakpoints.Get(i)->Data()); |
| 1120 breakpointIterator = m_serverBreakpoints.find(point); | 1133 if (id.isEmpty()) continue; |
| 1121 if (breakpointIterator != m_serverBreakpoints.end()) { | 1134 auto it = m_breakpointIdToSource.find(id); |
| 1122 const String16& localId = breakpointIterator->second.first; | 1135 if (it == m_breakpointIdToSource.end()) continue; |
| 1123 hitBreakpointIds->addItem(localId); | 1136 hitBreakpointIds->addItem(it->first); |
| 1124 | 1137 if (!hasDebugCommandBreakpointReason && |
| 1125 BreakpointSource source = breakpointIterator->second.second; | 1138 it->second == DebugCommandBreakpointSource) { |
| 1126 if (!hasDebugCommandBreakpointReason && | 1139 hasDebugCommandBreakpointReason = true; |
| 1127 source == DebugCommandBreakpointSource) { | 1140 hitReasons.push_back(std::make_pair( |
| 1128 hasDebugCommandBreakpointReason = true; | 1141 protocol::Debugger::Paused::ReasonEnum::DebugCommand, nullptr)); |
| 1129 hitReasons.push_back(std::make_pair( | |
| 1130 protocol::Debugger::Paused::ReasonEnum::DebugCommand, nullptr)); | |
| 1131 } | |
| 1132 } | 1142 } |
| 1133 } | 1143 } |
| 1134 | 1144 |
| 1135 for (size_t i = 0; i < m_breakReason.size(); ++i) { | 1145 for (size_t i = 0; i < m_breakReason.size(); ++i) { |
| 1136 hitReasons.push_back(std::move(m_breakReason[i])); | 1146 hitReasons.push_back(std::move(m_breakReason[i])); |
| 1137 } | 1147 } |
| 1138 clearBreakDetails(); | 1148 clearBreakDetails(); |
| 1139 | 1149 |
| 1140 String16 breakReason = protocol::Debugger::Paused::ReasonEnum::Other; | 1150 String16 breakReason = protocol::Debugger::Paused::ReasonEnum::Other; |
| 1141 std::unique_ptr<protocol::DictionaryValue> breakAuxData; | 1151 std::unique_ptr<protocol::DictionaryValue> breakAuxData; |
| 1142 if (hitReasons.size() == 1) { | 1152 if (hitReasons.size() == 1) { |
| 1143 breakReason = hitReasons[0].first; | 1153 breakReason = hitReasons[0].first; |
| 1144 breakAuxData = std::move(hitReasons[0].second); | 1154 breakAuxData = std::move(hitReasons[0].second); |
| 1145 } else if (hitReasons.size() > 1) { | 1155 } else if (hitReasons.size() > 1) { |
| 1146 breakReason = protocol::Debugger::Paused::ReasonEnum::Ambiguous; | 1156 breakReason = protocol::Debugger::Paused::ReasonEnum::Ambiguous; |
| 1147 std::unique_ptr<protocol::ListValue> reasons = | 1157 std::unique_ptr<protocol::ListValue> reasons = |
| 1148 protocol::ListValue::create(); | 1158 protocol::ListValue::create(); |
| 1149 for (size_t i = 0; i < hitReasons.size(); ++i) { | 1159 for (size_t i = 0; i < hitReasons.size(); ++i) { |
| 1150 std::unique_ptr<protocol::DictionaryValue> reason = | 1160 std::unique_ptr<protocol::DictionaryValue> reason = |
| 1151 protocol::DictionaryValue::create(); | 1161 protocol::DictionaryValue::create(); |
| 1152 reason->setString("reason", hitReasons[i].first); | 1162 reason->setString("reason", hitReasons[i].first); |
| 1153 if (hitReasons[i].second) | 1163 if (hitReasons[i].second) { |
| 1154 reason->setObject("auxData", std::move(hitReasons[i].second)); | 1164 reason->setObject("auxData", std::move(hitReasons[i].second)); |
| 1165 } |
| 1155 reasons->pushValue(std::move(reason)); | 1166 reasons->pushValue(std::move(reason)); |
| 1156 } | 1167 } |
| 1157 breakAuxData = protocol::DictionaryValue::create(); | 1168 breakAuxData = protocol::DictionaryValue::create(); |
| 1158 breakAuxData->setArray("reasons", std::move(reasons)); | 1169 breakAuxData->setArray("reasons", std::move(reasons)); |
| 1159 } | 1170 } |
| 1160 | 1171 |
| 1161 std::unique_ptr<Array<CallFrame>> protocolCallFrames; | 1172 std::unique_ptr<Array<CallFrame>> protocolCallFrames; |
| 1162 Response response = currentCallFrames(&protocolCallFrames); | 1173 Response response = currentCallFrames(&protocolCallFrames); |
| 1163 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create(); | 1174 if (!response.isSuccess()) protocolCallFrames = Array<CallFrame>::create(); |
| 1164 m_frontend.paused(std::move(protocolCallFrames), breakReason, | 1175 m_frontend.paused(std::move(protocolCallFrames), breakReason, |
| 1165 std::move(breakAuxData), std::move(hitBreakpointIds), | 1176 std::move(breakAuxData), std::move(hitBreakpointIds), |
| 1166 currentAsyncStackTrace()); | 1177 currentAsyncStackTrace()); |
| 1167 m_scheduledDebuggerStep = NoStep; | 1178 m_scheduledDebuggerStep = NoStep; |
| 1168 m_javaScriptPauseScheduled = false; | 1179 m_javaScriptPauseScheduled = false; |
| 1169 | 1180 |
| 1170 if (!m_continueToLocationBreakpointId.isEmpty()) { | 1181 if (!m_continueToLocationBreakpoint.IsEmpty()) { |
| 1171 m_debugger->removeBreakpoint(m_continueToLocationBreakpointId); | 1182 v8::debug::ClearBreakPoint(m_isolate, |
| 1172 m_continueToLocationBreakpointId = ""; | 1183 m_continueToLocationBreakpoint.Get(m_isolate)); |
| 1184 m_continueToLocationBreakpoint.Reset(); |
| 1173 } | 1185 } |
| 1174 } | 1186 } |
| 1175 | 1187 |
| 1176 void V8DebuggerAgentImpl::didContinue() { | 1188 void V8DebuggerAgentImpl::didContinue() { |
| 1177 JavaScriptCallFrames emptyCallFrames; | 1189 JavaScriptCallFrames emptyCallFrames; |
| 1178 m_pausedCallFrames.swap(emptyCallFrames); | 1190 m_pausedCallFrames.swap(emptyCallFrames); |
| 1179 clearBreakDetails(); | 1191 clearBreakDetails(); |
| 1180 m_frontend.resumed(); | 1192 m_frontend.resumed(); |
| 1181 } | 1193 } |
| 1182 | 1194 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 ScriptBreakpoint(scriptId, lineNumber, columnNumber, String16()), | 1230 ScriptBreakpoint(scriptId, lineNumber, columnNumber, String16()), |
| 1219 source)); | 1231 source)); |
| 1220 } | 1232 } |
| 1221 | 1233 |
| 1222 void V8DebuggerAgentImpl::reset() { | 1234 void V8DebuggerAgentImpl::reset() { |
| 1223 if (!enabled()) return; | 1235 if (!enabled()) return; |
| 1224 m_scheduledDebuggerStep = NoStep; | 1236 m_scheduledDebuggerStep = NoStep; |
| 1225 m_blackboxedPositions.clear(); | 1237 m_blackboxedPositions.clear(); |
| 1226 resetBlackboxedStateCache(); | 1238 resetBlackboxedStateCache(); |
| 1227 m_scripts.clear(); | 1239 m_scripts.clear(); |
| 1228 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1240 m_idToBreakpoints.clear(); |
| 1241 m_breakpointIdToSource.clear(); |
| 1229 } | 1242 } |
| 1230 | 1243 |
| 1231 } // namespace v8_inspector | 1244 } // namespace v8_inspector |
| OLD | NEW |