Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: src/inspector/v8-debugger-agent-impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698