Chromium Code Reviews| Index: src/inspector/v8-debugger-script.cc |
| diff --git a/src/inspector/v8-debugger-script.cc b/src/inspector/v8-debugger-script.cc |
| index d4f94dd15a238ce5ea4140f4c0e5490315d4804c..693271f8d3456f6abd17c034ef0418a5a4274f25 100644 |
| --- a/src/inspector/v8-debugger-script.cc |
| +++ b/src/inspector/v8-debugger-script.cc |
| @@ -155,11 +155,38 @@ class ActualScript : public V8DebuggerScript { |
| bool getPossibleBreakpoints( |
| const v8::debug::Location& start, const v8::debug::Location& end, |
| bool restrictToFunction, |
| - std::vector<v8::debug::Location>* locations) override { |
| + std::vector<v8::debug::BreakLocation>* locations) override { |
| v8::HandleScope scope(m_isolate); |
| v8::Local<v8::debug::Script> script = m_script.Get(m_isolate); |
| - return script->GetPossibleBreakpoints(start, end, restrictToFunction, |
| - locations); |
| + std::vector<v8::debug::BreakLocation> allLocations; |
| + if (!script->GetPossibleBreakpoints(start, end, restrictToFunction, |
| + &allLocations)) { |
| + return false; |
| + } |
| + if (!allLocations.size()) return true; |
| + v8::debug::BreakLocation current = allLocations[0]; |
| + for (size_t i = 1; i < allLocations.size(); ++i) { |
| + if (allLocations[i].GetLineNumber() == current.GetLineNumber() && |
| + allLocations[i].GetColumnNumber() == current.GetColumnNumber()) { |
| + if (allLocations[i].type() != v8::debug::kCommonBreakLocation) { |
| + // debugger can returns more then one break location at the same |
| + // source location, e.g. foo() - in this case there are two break |
| + // locations before foo: for statement and for function call, we can |
| + // merge them for inspector and report only one with call type. |
| + current = allLocations[i]; |
|
Yang
2017/03/06 14:41:11
Can we DCHECK that we only overwrite a common brea
kozy
2017/03/06 18:25:25
I added DCHECK and it was failed on generator func
|
| + } |
| + } else { |
| + // we assume that returned break locations are sorted. |
| + DCHECK( |
| + allLocations[i].GetLineNumber() > current.GetLineNumber() || |
| + (allLocations[i].GetColumnNumber() >= current.GetColumnNumber() && |
| + allLocations[i].GetLineNumber() == current.GetLineNumber())); |
| + locations->push_back(current); |
| + current = allLocations[i]; |
| + } |
| + } |
| + locations->push_back(current); |
| + return true; |
| } |
| void resetBlackboxedStateCache() override { |
| @@ -223,7 +250,7 @@ class WasmVirtualScript : public V8DebuggerScript { |
| bool getPossibleBreakpoints( |
| const v8::debug::Location& start, const v8::debug::Location& end, |
| bool restrictToFunction, |
| - std::vector<v8::debug::Location>* locations) override { |
| + std::vector<v8::debug::BreakLocation>* locations) override { |
| v8::HandleScope scope(m_isolate); |
| v8::Local<v8::debug::Script> script = m_script.Get(m_isolate); |
| String16 v8ScriptId = String16::fromInteger(script->Id()); |
| @@ -244,7 +271,7 @@ class WasmVirtualScript : public V8DebuggerScript { |
| bool success = script->GetPossibleBreakpoints( |
| translatedStart, translatedEnd, restrictToFunction, locations); |
| - for (v8::debug::Location& loc : *locations) { |
| + for (v8::debug::BreakLocation& loc : *locations) { |
| TranslateV8LocationToProtocolLocation(m_wasmTranslation, &loc, v8ScriptId, |
| scriptId()); |
| } |