Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index f8f0f72c85d4a309ea877a8b1effe5b18667eeef..d144a1e83b61cc934f5ae14057186d16d994eec7 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -9215,7 +9215,8 @@ int GetSmiValue(i::Handle<i::FixedArray> array, int index) { |
bool debug::Script::GetPossibleBreakpoints( |
const debug::Location& start, const debug::Location& end, |
- bool restrict_to_function, std::vector<debug::Location>* locations) const { |
+ bool restrict_to_function, |
+ std::vector<debug::BreakLocation>* locations) const { |
CHECK(!start.IsEmpty()); |
i::Handle<i::Script> script = Utils::OpenHandle(this); |
if (script->type() == i::Script::TYPE_WASM) { |
@@ -9237,15 +9238,31 @@ bool debug::Script::GetPossibleBreakpoints( |
: GetSourceOffset(end); |
if (start_offset >= end_offset) return true; |
- std::set<int> offsets; |
+ std::vector<i::BreakLocation> v8_locations; |
if (!isolate->debug()->GetPossibleBreakpoints( |
- script, start_offset, end_offset, restrict_to_function, &offsets)) { |
+ script, start_offset, end_offset, restrict_to_function, |
+ &v8_locations)) { |
return false; |
} |
+ std::map<int, i::BreakLocation> unique_locations; |
+ for (const auto& location : v8_locations) { |
dgozman
2017/03/03 18:55:56
I agree with Yang that we should move this to insp
kozy
2017/03/03 22:44:14
Done.
|
+ auto it = unique_locations.find(location.position()); |
+ if (it == unique_locations.end()) { |
+ unique_locations.insert(std::make_pair(location.position(), location)); |
+ } else if (it->second.type() == debug::kCommonBreakLocation && |
+ location.type() != 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. |
+ DCHECK(location.IsCall()); |
+ it->second = location; |
+ } |
+ } |
int current_line_end_index = 0; |
- for (const auto& it : offsets) { |
- int offset = it; |
+ for (const auto& it : unique_locations) { |
+ int offset = it.first; |
while (offset > GetSmiValue(line_ends, current_line_end_index)) { |
++current_line_end_index; |
CHECK(current_line_end_index < line_ends->length()); |
@@ -9255,10 +9272,11 @@ bool debug::Script::GetPossibleBreakpoints( |
if (current_line_end_index > 0) { |
line_offset = GetSmiValue(line_ends, current_line_end_index - 1) + 1; |
} |
- locations->push_back(debug::Location( |
+ locations->emplace_back( |
current_line_end_index + script->line_offset(), |
offset - line_offset + |
- (current_line_end_index == 0 ? script->column_offset() : 0))); |
+ (current_line_end_index == 0 ? script->column_offset() : 0), |
+ it.second.type()); |
} |
return true; |
} |