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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; | 43 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; |
44 static const char blackboxPattern[] = "blackboxPattern"; | 44 static const char blackboxPattern[] = "blackboxPattern"; |
45 static const char debuggerEnabled[] = "debuggerEnabled"; | 45 static const char debuggerEnabled[] = "debuggerEnabled"; |
46 | 46 |
47 // Breakpoint properties. | 47 // Breakpoint properties. |
48 static const char url[] = "url"; | 48 static const char url[] = "url"; |
49 static const char isRegex[] = "isRegex"; | 49 static const char isRegex[] = "isRegex"; |
50 static const char lineNumber[] = "lineNumber"; | 50 static const char lineNumber[] = "lineNumber"; |
51 static const char columnNumber[] = "columnNumber"; | 51 static const char columnNumber[] = "columnNumber"; |
52 static const char condition[] = "condition"; | 52 static const char condition[] = "condition"; |
53 static const char sourceLineHint[] = "sourceLineHint"; | |
54 | |
53 static const char skipAllPauses[] = "skipAllPauses"; | 55 static const char skipAllPauses[] = "skipAllPauses"; |
54 | 56 |
55 } // namespace DebuggerAgentState | 57 } // namespace DebuggerAgentState |
56 | 58 |
57 static const char kBacktraceObjectGroup[] = "backtrace"; | 59 static const char kBacktraceObjectGroup[] = "backtrace"; |
58 static const char kDebuggerNotEnabled[] = "Debugger agent is not enabled"; | 60 static const char kDebuggerNotEnabled[] = "Debugger agent is not enabled"; |
59 static const char kDebuggerNotPaused[] = | 61 static const char kDebuggerNotPaused[] = |
60 "Can only perform operation while paused."; | 62 "Can only perform operation while paused."; |
63 static const int kSourceLineHintToCheckOffsets[] = { | |
pfeldman
2017/02/07 19:13:05
:) I'm sure alph@ would suggest to iterate to 16 a
alph
2017/02/07 22:22:30
The problem is that you'd then double check the ze
| |
64 0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, | |
65 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16}; | |
66 static const int kSourceLineHintMaxLength = 128; | |
61 | 67 |
62 namespace { | 68 namespace { |
63 | 69 |
64 void TranslateWasmStackTraceLocations(Array<CallFrame>* stackTrace, | 70 void TranslateWasmStackTraceLocations(Array<CallFrame>* stackTrace, |
65 WasmTranslation* wasmTranslation) { | 71 WasmTranslation* wasmTranslation) { |
66 for (size_t i = 0, e = stackTrace->length(); i != e; ++i) { | 72 for (size_t i = 0, e = stackTrace->length(); i != e; ++i) { |
67 protocol::Debugger::Location* location = stackTrace->get(i)->getLocation(); | 73 protocol::Debugger::Location* location = stackTrace->get(i)->getLocation(); |
68 String16 scriptId = location->getScriptId(); | 74 String16 scriptId = location->getScriptId(); |
69 int lineNumber = location->getLineNumber(); | 75 int lineNumber = location->getLineNumber(); |
70 int columnNumber = location->getColumnNumber(-1); | 76 int columnNumber = location->getColumnNumber(-1); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 | 240 |
235 Response V8DebuggerAgentImpl::setSkipAllPauses(bool skip) { | 241 Response V8DebuggerAgentImpl::setSkipAllPauses(bool skip) { |
236 m_state->setBoolean(DebuggerAgentState::skipAllPauses, skip); | 242 m_state->setBoolean(DebuggerAgentState::skipAllPauses, skip); |
237 m_skipAllPauses = skip; | 243 m_skipAllPauses = skip; |
238 return Response::OK(); | 244 return Response::OK(); |
239 } | 245 } |
240 | 246 |
241 static std::unique_ptr<protocol::DictionaryValue> | 247 static std::unique_ptr<protocol::DictionaryValue> |
242 buildObjectForBreakpointCookie(const String16& url, int lineNumber, | 248 buildObjectForBreakpointCookie(const String16& url, int lineNumber, |
243 int columnNumber, const String16& condition, | 249 int columnNumber, const String16& condition, |
244 bool isRegex) { | 250 bool isRegex, const String16& sourceLineHint) { |
245 std::unique_ptr<protocol::DictionaryValue> breakpointObject = | 251 std::unique_ptr<protocol::DictionaryValue> breakpointObject = |
246 protocol::DictionaryValue::create(); | 252 protocol::DictionaryValue::create(); |
247 breakpointObject->setString(DebuggerAgentState::url, url); | 253 breakpointObject->setString(DebuggerAgentState::url, url); |
248 breakpointObject->setInteger(DebuggerAgentState::lineNumber, lineNumber); | 254 breakpointObject->setInteger(DebuggerAgentState::lineNumber, lineNumber); |
249 breakpointObject->setInteger(DebuggerAgentState::columnNumber, columnNumber); | 255 breakpointObject->setInteger(DebuggerAgentState::columnNumber, columnNumber); |
250 breakpointObject->setString(DebuggerAgentState::condition, condition); | 256 breakpointObject->setString(DebuggerAgentState::condition, condition); |
257 breakpointObject->setString(DebuggerAgentState::sourceLineHint, | |
258 sourceLineHint); | |
251 breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex); | 259 breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex); |
252 return breakpointObject; | 260 return breakpointObject; |
253 } | 261 } |
254 | 262 |
255 static bool matches(V8InspectorImpl* inspector, const String16& url, | 263 static bool matches(V8InspectorImpl* inspector, const String16& url, |
256 const String16& pattern, bool isRegex) { | 264 const String16& pattern, bool isRegex) { |
257 if (isRegex) { | 265 if (isRegex) { |
258 V8Regex regex(inspector, pattern, true); | 266 V8Regex regex(inspector, pattern, true); |
259 return regex.match(url) != -1; | 267 return regex.match(url) != -1; |
260 } | 268 } |
(...skipping 27 matching lines...) Expand all Loading... | |
288 if (!breakpointsCookie) { | 296 if (!breakpointsCookie) { |
289 std::unique_ptr<protocol::DictionaryValue> newValue = | 297 std::unique_ptr<protocol::DictionaryValue> newValue = |
290 protocol::DictionaryValue::create(); | 298 protocol::DictionaryValue::create(); |
291 breakpointsCookie = newValue.get(); | 299 breakpointsCookie = newValue.get(); |
292 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, | 300 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, |
293 std::move(newValue)); | 301 std::move(newValue)); |
294 } | 302 } |
295 if (breakpointsCookie->get(breakpointId)) | 303 if (breakpointsCookie->get(breakpointId)) |
296 return Response::Error("Breakpoint at specified location already exists."); | 304 return Response::Error("Breakpoint at specified location already exists."); |
297 | 305 |
298 breakpointsCookie->setObject( | |
299 breakpointId, buildObjectForBreakpointCookie( | |
300 url, lineNumber, columnNumber, condition, isRegex)); | |
301 | |
302 ScriptBreakpoint breakpoint(String16(), lineNumber, columnNumber, condition); | 306 ScriptBreakpoint breakpoint(String16(), lineNumber, columnNumber, condition); |
307 String16 sourceLineHint; | |
303 for (const auto& script : m_scripts) { | 308 for (const auto& script : m_scripts) { |
304 if (!matches(m_inspector, script.second->sourceURL(), url, isRegex)) | 309 if (!matches(m_inspector, script.second->sourceURL(), url, isRegex)) |
305 continue; | 310 continue; |
306 breakpoint.script_id = script.first; | 311 breakpoint.script_id = script.first; |
307 std::unique_ptr<protocol::Debugger::Location> location = | 312 sourceLineHint = |
308 resolveBreakpoint(breakpointId, breakpoint, UserBreakpointSource); | 313 script.second->lineAt(lineNumber, kSourceLineHintMaxLength); |
314 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoint( | |
315 breakpointId, breakpoint, UserBreakpointSource, String16()); | |
309 if (location) (*locations)->addItem(std::move(location)); | 316 if (location) (*locations)->addItem(std::move(location)); |
310 } | 317 } |
311 | 318 |
319 breakpointsCookie->setObject( | |
320 breakpointId, | |
321 buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition, | |
322 isRegex, sourceLineHint)); | |
323 | |
312 *outBreakpointId = breakpointId; | 324 *outBreakpointId = breakpointId; |
313 return Response::OK(); | 325 return Response::OK(); |
314 } | 326 } |
315 | 327 |
316 Response V8DebuggerAgentImpl::setBreakpoint( | 328 Response V8DebuggerAgentImpl::setBreakpoint( |
317 std::unique_ptr<protocol::Debugger::Location> location, | 329 std::unique_ptr<protocol::Debugger::Location> location, |
318 Maybe<String16> optionalCondition, String16* outBreakpointId, | 330 Maybe<String16> optionalCondition, String16* outBreakpointId, |
319 std::unique_ptr<protocol::Debugger::Location>* actualLocation) { | 331 std::unique_ptr<protocol::Debugger::Location>* actualLocation) { |
320 ScriptBreakpoint breakpoint( | 332 ScriptBreakpoint breakpoint( |
321 location->getScriptId(), location->getLineNumber(), | 333 location->getScriptId(), location->getLineNumber(), |
322 location->getColumnNumber(0), optionalCondition.fromMaybe(String16())); | 334 location->getColumnNumber(0), optionalCondition.fromMaybe(String16())); |
323 | 335 |
324 String16 breakpointId = | 336 String16 breakpointId = |
325 generateBreakpointId(breakpoint, UserBreakpointSource); | 337 generateBreakpointId(breakpoint, UserBreakpointSource); |
326 if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) != | 338 if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) != |
327 m_breakpointIdToDebuggerBreakpointIds.end()) { | 339 m_breakpointIdToDebuggerBreakpointIds.end()) { |
328 return Response::Error("Breakpoint at specified location already exists."); | 340 return Response::Error("Breakpoint at specified location already exists."); |
329 } | 341 } |
330 *actualLocation = | 342 *actualLocation = resolveBreakpoint(breakpointId, breakpoint, |
331 resolveBreakpoint(breakpointId, breakpoint, UserBreakpointSource); | 343 UserBreakpointSource, String16()); |
332 if (!*actualLocation) return Response::Error("Could not resolve breakpoint"); | 344 if (!*actualLocation) return Response::Error("Could not resolve breakpoint"); |
333 *outBreakpointId = breakpointId; | 345 *outBreakpointId = breakpointId; |
334 return Response::OK(); | 346 return Response::OK(); |
335 } | 347 } |
336 | 348 |
337 Response V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) { | 349 Response V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) { |
338 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 350 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
339 protocol::DictionaryValue* breakpointsCookie = | 351 protocol::DictionaryValue* breakpointsCookie = |
340 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); | 352 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); |
341 if (breakpointsCookie) breakpointsCookie->remove(breakpointId); | 353 if (breakpointsCookie) breakpointsCookie->remove(breakpointId); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 // Ranges array contains positions in script where blackbox state is changed. | 463 // Ranges array contains positions in script where blackbox state is changed. |
452 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is | 464 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is |
453 // blackboxed... | 465 // blackboxed... |
454 return itStartRange == itEndRange && | 466 return itStartRange == itEndRange && |
455 std::distance(ranges.begin(), itStartRange) % 2; | 467 std::distance(ranges.begin(), itStartRange) % 2; |
456 } | 468 } |
457 | 469 |
458 std::unique_ptr<protocol::Debugger::Location> | 470 std::unique_ptr<protocol::Debugger::Location> |
459 V8DebuggerAgentImpl::resolveBreakpoint(const String16& breakpointId, | 471 V8DebuggerAgentImpl::resolveBreakpoint(const String16& breakpointId, |
460 const ScriptBreakpoint& breakpoint, | 472 const ScriptBreakpoint& breakpoint, |
461 BreakpointSource source) { | 473 BreakpointSource source, |
474 const String16& sourceLineHint) { | |
462 v8::HandleScope handles(m_isolate); | 475 v8::HandleScope handles(m_isolate); |
463 DCHECK(enabled()); | 476 DCHECK(enabled()); |
464 // FIXME: remove these checks once crbug.com/520702 is resolved. | 477 // FIXME: remove these checks once crbug.com/520702 is resolved. |
465 CHECK(!breakpointId.isEmpty()); | 478 CHECK(!breakpointId.isEmpty()); |
466 CHECK(!breakpoint.script_id.isEmpty()); | 479 CHECK(!breakpoint.script_id.isEmpty()); |
467 ScriptsMap::iterator scriptIterator = m_scripts.find(breakpoint.script_id); | 480 ScriptsMap::iterator scriptIterator = m_scripts.find(breakpoint.script_id); |
468 if (scriptIterator == m_scripts.end()) return nullptr; | 481 if (scriptIterator == m_scripts.end()) return nullptr; |
469 if (breakpoint.line_number < scriptIterator->second->startLine() || | 482 |
470 scriptIterator->second->endLine() < breakpoint.line_number) | 483 V8DebuggerScript* script = scriptIterator->second.get(); |
484 ScriptBreakpoint translatedBreakpoint = breakpoint; | |
485 if (!sourceLineHint.isEmpty()) { | |
pfeldman
2017/02/07 19:13:05
Extract into the method that adjusts ScriptBreakpo
kozy
2017/02/08 01:32:56
I'm not sure. User puts breakpoint at line and if
| |
486 for (size_t i = 0; i < arraysize(kSourceLineHintToCheckOffsets); ++i) { | |
pfeldman
2017/02/07 19:13:05
Yeah...
| |
487 int lineNumber = | |
488 translatedBreakpoint.line_number + kSourceLineHintToCheckOffsets[i]; | |
489 if (lineNumber < script->startLine() || lineNumber > script->endLine()) { | |
alph
2017/02/07 22:22:30
no {}
kozy
2017/02/08 01:32:56
yes {}, it's V8 code style.
| |
490 continue; | |
491 } | |
492 if (script->lineAt(lineNumber, kSourceLineHintMaxLength) == | |
493 sourceLineHint) { | |
494 translatedBreakpoint.line_number = lineNumber; | |
495 break; | |
496 } | |
497 } | |
498 } | |
499 | |
500 if (breakpoint.line_number < script->startLine() || | |
501 script->endLine() < breakpoint.line_number) { | |
471 return nullptr; | 502 return nullptr; |
503 } | |
472 | 504 |
473 // Translate from protocol location to v8 location for the debugger. | 505 // Translate from protocol location to v8 location for the debugger. |
474 ScriptBreakpoint translatedBreakpoint = breakpoint; | |
475 m_debugger->wasmTranslation()->TranslateProtocolLocationToWasmScriptLocation( | 506 m_debugger->wasmTranslation()->TranslateProtocolLocationToWasmScriptLocation( |
476 &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, | 507 &translatedBreakpoint.script_id, &translatedBreakpoint.line_number, |
477 &translatedBreakpoint.column_number); | 508 &translatedBreakpoint.column_number); |
478 | 509 |
479 int actualLineNumber; | 510 int actualLineNumber; |
480 int actualColumnNumber; | 511 int actualColumnNumber; |
481 String16 debuggerBreakpointId = m_debugger->setBreakpoint( | 512 String16 debuggerBreakpointId = m_debugger->setBreakpoint( |
482 translatedBreakpoint, &actualLineNumber, &actualColumnNumber); | 513 translatedBreakpoint, &actualLineNumber, &actualColumnNumber); |
483 if (debuggerBreakpointId.isEmpty()) return nullptr; | 514 if (debuggerBreakpointId.isEmpty()) return nullptr; |
484 | 515 |
(...skipping 14 matching lines...) Expand all Loading... | |
499 Response V8DebuggerAgentImpl::searchInContent( | 530 Response V8DebuggerAgentImpl::searchInContent( |
500 const String16& scriptId, const String16& query, | 531 const String16& scriptId, const String16& query, |
501 Maybe<bool> optionalCaseSensitive, Maybe<bool> optionalIsRegex, | 532 Maybe<bool> optionalCaseSensitive, Maybe<bool> optionalIsRegex, |
502 std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results) { | 533 std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results) { |
503 v8::HandleScope handles(m_isolate); | 534 v8::HandleScope handles(m_isolate); |
504 ScriptsMap::iterator it = m_scripts.find(scriptId); | 535 ScriptsMap::iterator it = m_scripts.find(scriptId); |
505 if (it == m_scripts.end()) | 536 if (it == m_scripts.end()) |
506 return Response::Error("No script for id: " + scriptId); | 537 return Response::Error("No script for id: " + scriptId); |
507 | 538 |
508 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = | 539 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = |
509 searchInTextByLinesImpl(m_session, it->second->source(m_isolate), query, | 540 searchInTextByLinesImpl(m_session, it->second->source(), query, |
510 optionalCaseSensitive.fromMaybe(false), | 541 optionalCaseSensitive.fromMaybe(false), |
511 optionalIsRegex.fromMaybe(false)); | 542 optionalIsRegex.fromMaybe(false)); |
512 *results = protocol::Array<protocol::Debugger::SearchMatch>::create(); | 543 *results = protocol::Array<protocol::Debugger::SearchMatch>::create(); |
513 for (size_t i = 0; i < matches.size(); ++i) | 544 for (size_t i = 0; i < matches.size(); ++i) |
514 (*results)->addItem(std::move(matches[i])); | 545 (*results)->addItem(std::move(matches[i])); |
515 return Response::OK(); | 546 return Response::OK(); |
516 } | 547 } |
517 | 548 |
518 Response V8DebuggerAgentImpl::setScriptSource( | 549 Response V8DebuggerAgentImpl::setScriptSource( |
519 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun, | 550 const String16& scriptId, const String16& newContent, Maybe<bool> dryRun, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 return Response::OK(); | 609 return Response::OK(); |
579 } | 610 } |
580 | 611 |
581 Response V8DebuggerAgentImpl::getScriptSource(const String16& scriptId, | 612 Response V8DebuggerAgentImpl::getScriptSource(const String16& scriptId, |
582 String16* scriptSource) { | 613 String16* scriptSource) { |
583 if (!enabled()) return Response::Error(kDebuggerNotEnabled); | 614 if (!enabled()) return Response::Error(kDebuggerNotEnabled); |
584 ScriptsMap::iterator it = m_scripts.find(scriptId); | 615 ScriptsMap::iterator it = m_scripts.find(scriptId); |
585 if (it == m_scripts.end()) | 616 if (it == m_scripts.end()) |
586 return Response::Error("No script for id: " + scriptId); | 617 return Response::Error("No script for id: " + scriptId); |
587 v8::HandleScope handles(m_isolate); | 618 v8::HandleScope handles(m_isolate); |
588 *scriptSource = it->second->source(m_isolate); | 619 *scriptSource = it->second->source(); |
589 return Response::OK(); | 620 return Response::OK(); |
590 } | 621 } |
591 | 622 |
592 void V8DebuggerAgentImpl::schedulePauseOnNextStatement( | 623 void V8DebuggerAgentImpl::schedulePauseOnNextStatement( |
593 const String16& breakReason, | 624 const String16& breakReason, |
594 std::unique_ptr<protocol::DictionaryValue> data) { | 625 std::unique_ptr<protocol::DictionaryValue> data) { |
595 if (!enabled() || m_scheduledDebuggerStep == StepInto || | 626 if (!enabled() || m_scheduledDebuggerStep == StepInto || |
596 m_javaScriptPauseScheduled || isPaused() || | 627 m_javaScriptPauseScheduled || isPaused() || |
597 !m_debugger->breakpointsActivated()) | 628 !m_debugger->breakpointsActivated()) |
598 return; | 629 return; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
972 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); | 1003 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); |
973 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) | 1004 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) |
974 : nullptr; | 1005 : nullptr; |
975 } | 1006 } |
976 | 1007 |
977 bool V8DebuggerAgentImpl::isPaused() const { return m_debugger->isPaused(); } | 1008 bool V8DebuggerAgentImpl::isPaused() const { return m_debugger->isPaused(); } |
978 | 1009 |
979 void V8DebuggerAgentImpl::didParseSource( | 1010 void V8DebuggerAgentImpl::didParseSource( |
980 std::unique_ptr<V8DebuggerScript> script, bool success) { | 1011 std::unique_ptr<V8DebuggerScript> script, bool success) { |
981 v8::HandleScope handles(m_isolate); | 1012 v8::HandleScope handles(m_isolate); |
982 String16 scriptSource = script->source(m_isolate); | 1013 String16 scriptSource = script->source(); |
983 if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); | 1014 if (!success) script->setSourceURL(findSourceURL(scriptSource, false)); |
984 if (!success) | 1015 if (!success) |
985 script->setSourceMappingURL(findSourceMapURL(scriptSource, false)); | 1016 script->setSourceMappingURL(findSourceMapURL(scriptSource, false)); |
986 | 1017 |
987 int contextId = script->executionContextId(); | 1018 int contextId = script->executionContextId(); |
988 int contextGroupId = m_inspector->contextGroupId(contextId); | 1019 int contextGroupId = m_inspector->contextGroupId(contextId); |
989 InspectedContext* inspected = | 1020 InspectedContext* inspected = |
990 m_inspector->getContext(contextGroupId, contextId); | 1021 m_inspector->getContext(contextGroupId, contextId); |
991 std::unique_ptr<protocol::DictionaryValue> executionContextAuxData; | 1022 std::unique_ptr<protocol::DictionaryValue> executionContextAuxData; |
992 if (inspected) { | 1023 if (inspected) { |
(...skipping 22 matching lines...) Expand all Loading... | |
1015 Maybe<String16> sourceMapURLParam = scriptRef->sourceMappingURL(); | 1046 Maybe<String16> sourceMapURLParam = scriptRef->sourceMappingURL(); |
1016 Maybe<protocol::DictionaryValue> executionContextAuxDataParam( | 1047 Maybe<protocol::DictionaryValue> executionContextAuxDataParam( |
1017 std::move(executionContextAuxData)); | 1048 std::move(executionContextAuxData)); |
1018 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; | 1049 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; |
1019 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; | 1050 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; |
1020 const bool* isModuleParam = isModule ? &isModule : nullptr; | 1051 const bool* isModuleParam = isModule ? &isModule : nullptr; |
1021 if (success) | 1052 if (success) |
1022 m_frontend.scriptParsed( | 1053 m_frontend.scriptParsed( |
1023 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), | 1054 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), |
1024 scriptRef->endLine(), scriptRef->endColumn(), contextId, | 1055 scriptRef->endLine(), scriptRef->endColumn(), contextId, |
1025 scriptRef->hash(m_isolate), std::move(executionContextAuxDataParam), | 1056 scriptRef->hash(), std::move(executionContextAuxDataParam), |
1026 isLiveEditParam, std::move(sourceMapURLParam), hasSourceURLParam, | 1057 isLiveEditParam, std::move(sourceMapURLParam), hasSourceURLParam, |
1027 isModuleParam); | 1058 isModuleParam); |
1028 else | 1059 else |
1029 m_frontend.scriptFailedToParse( | 1060 m_frontend.scriptFailedToParse( |
1030 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), | 1061 scriptId, scriptURL, scriptRef->startLine(), scriptRef->startColumn(), |
1031 scriptRef->endLine(), scriptRef->endColumn(), contextId, | 1062 scriptRef->endLine(), scriptRef->endColumn(), contextId, |
1032 scriptRef->hash(m_isolate), std::move(executionContextAuxDataParam), | 1063 scriptRef->hash(), std::move(executionContextAuxDataParam), |
1033 std::move(sourceMapURLParam), hasSourceURLParam, isModuleParam); | 1064 std::move(sourceMapURLParam), hasSourceURLParam, isModuleParam); |
1034 | 1065 |
1035 if (scriptURL.isEmpty() || !success) return; | 1066 if (scriptURL.isEmpty() || !success) return; |
1036 | 1067 |
1037 protocol::DictionaryValue* breakpointsCookie = | 1068 protocol::DictionaryValue* breakpointsCookie = |
1038 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); | 1069 m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); |
1039 if (!breakpointsCookie) return; | 1070 if (!breakpointsCookie) return; |
1040 | 1071 |
1041 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { | 1072 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { |
1042 auto cookie = breakpointsCookie->at(i); | 1073 auto cookie = breakpointsCookie->at(i); |
1043 protocol::DictionaryValue* breakpointObject = | 1074 protocol::DictionaryValue* breakpointObject = |
1044 protocol::DictionaryValue::cast(cookie.second); | 1075 protocol::DictionaryValue::cast(cookie.second); |
1045 bool isRegex; | 1076 bool isRegex; |
1046 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); | 1077 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); |
1047 String16 url; | 1078 String16 url; |
1079 String16 sourceLineHint; | |
1048 breakpointObject->getString(DebuggerAgentState::url, &url); | 1080 breakpointObject->getString(DebuggerAgentState::url, &url); |
1049 if (!matches(m_inspector, scriptURL, url, isRegex)) continue; | 1081 if (!matches(m_inspector, scriptURL, url, isRegex)) continue; |
1050 ScriptBreakpoint breakpoint; | 1082 ScriptBreakpoint breakpoint; |
1051 breakpoint.script_id = scriptId; | 1083 breakpoint.script_id = scriptId; |
1052 breakpointObject->getInteger(DebuggerAgentState::lineNumber, | 1084 breakpointObject->getInteger(DebuggerAgentState::lineNumber, |
1053 &breakpoint.line_number); | 1085 &breakpoint.line_number); |
1054 breakpointObject->getInteger(DebuggerAgentState::columnNumber, | 1086 breakpointObject->getInteger(DebuggerAgentState::columnNumber, |
1055 &breakpoint.column_number); | 1087 &breakpoint.column_number); |
1056 breakpointObject->getString(DebuggerAgentState::condition, | 1088 breakpointObject->getString(DebuggerAgentState::condition, |
1057 &breakpoint.condition); | 1089 &breakpoint.condition); |
1058 std::unique_ptr<protocol::Debugger::Location> location = | 1090 breakpointObject->getString(DebuggerAgentState::sourceLineHint, |
1059 resolveBreakpoint(cookie.first, breakpoint, UserBreakpointSource); | 1091 &sourceLineHint); |
1092 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoint( | |
1093 cookie.first, breakpoint, UserBreakpointSource, sourceLineHint); | |
1060 if (location) | 1094 if (location) |
1061 m_frontend.breakpointResolved(cookie.first, std::move(location)); | 1095 m_frontend.breakpointResolved(cookie.first, std::move(location)); |
1062 } | 1096 } |
1063 } | 1097 } |
1064 | 1098 |
1065 void V8DebuggerAgentImpl::didPause(int contextId, | 1099 void V8DebuggerAgentImpl::didPause(int contextId, |
1066 v8::Local<v8::Value> exception, | 1100 v8::Local<v8::Value> exception, |
1067 const std::vector<String16>& hitBreakpoints, | 1101 const std::vector<String16>& hitBreakpoints, |
1068 bool isPromiseRejection, bool isUncaught, | 1102 bool isPromiseRejection, bool isUncaught, |
1069 bool isOOMBreak) { | 1103 bool isOOMBreak) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1156 m_breakReason = protocol::Debugger::Paused::ReasonEnum::Other; | 1190 m_breakReason = protocol::Debugger::Paused::ReasonEnum::Other; |
1157 m_breakAuxData = nullptr; | 1191 m_breakAuxData = nullptr; |
1158 } | 1192 } |
1159 | 1193 |
1160 void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId, | 1194 void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId, |
1161 int lineNumber, int columnNumber, | 1195 int lineNumber, int columnNumber, |
1162 BreakpointSource source, | 1196 BreakpointSource source, |
1163 const String16& condition) { | 1197 const String16& condition) { |
1164 ScriptBreakpoint breakpoint(scriptId, lineNumber, columnNumber, condition); | 1198 ScriptBreakpoint breakpoint(scriptId, lineNumber, columnNumber, condition); |
1165 String16 breakpointId = generateBreakpointId(breakpoint, source); | 1199 String16 breakpointId = generateBreakpointId(breakpoint, source); |
1166 resolveBreakpoint(breakpointId, breakpoint, source); | 1200 resolveBreakpoint(breakpointId, breakpoint, source, String16()); |
1167 } | 1201 } |
1168 | 1202 |
1169 void V8DebuggerAgentImpl::removeBreakpointAt(const String16& scriptId, | 1203 void V8DebuggerAgentImpl::removeBreakpointAt(const String16& scriptId, |
1170 int lineNumber, int columnNumber, | 1204 int lineNumber, int columnNumber, |
1171 BreakpointSource source) { | 1205 BreakpointSource source) { |
1172 removeBreakpointImpl(generateBreakpointId( | 1206 removeBreakpointImpl(generateBreakpointId( |
1173 ScriptBreakpoint(scriptId, lineNumber, columnNumber, String16()), | 1207 ScriptBreakpoint(scriptId, lineNumber, columnNumber, String16()), |
1174 source)); | 1208 source)); |
1175 } | 1209 } |
1176 | 1210 |
1177 void V8DebuggerAgentImpl::reset() { | 1211 void V8DebuggerAgentImpl::reset() { |
1178 if (!enabled()) return; | 1212 if (!enabled()) return; |
1179 m_scheduledDebuggerStep = NoStep; | 1213 m_scheduledDebuggerStep = NoStep; |
1180 m_blackboxedPositions.clear(); | 1214 m_blackboxedPositions.clear(); |
1181 resetBlackboxedStateCache(); | 1215 resetBlackboxedStateCache(); |
1182 m_scripts.clear(); | 1216 m_scripts.clear(); |
1183 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1217 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1184 } | 1218 } |
1185 | 1219 |
1186 } // namespace v8_inspector | 1220 } // namespace v8_inspector |
OLD | NEW |