|
Lines 33-75
namespace JSC {
a/Source/JavaScriptCore/debugger/DebuggerParseData.cpp_sec1
|
| 33 |
|
33 |
|
| 34 |
Optional<JSTextPosition> DebuggerPausePositions::breakpointLocationForLineColumn(int line, int column) |
34 |
Optional<JSTextPosition> DebuggerPausePositions::breakpointLocationForLineColumn(int line, int column) |
| 35 |
{ |
35 |
{ |
| 36 |
unsigned start = 0; |
36 |
DebuggerPausePosition position; |
| 37 |
unsigned end = m_positions.size(); |
37 |
position.position.line = line; |
| 38 |
while (start != end) { |
38 |
position.position.offset = column; |
| 39 |
unsigned middle = start + ((end - start) / 2); |
39 |
position.position.lineStartOffset = 0; |
| 40 |
DebuggerPausePosition& pausePosition = m_positions[middle]; |
40 |
auto it = std::lower_bound(m_positions.begin(), m_positions.end(), position, [] (const DebuggerPausePosition& a, const DebuggerPausePosition& b) { |
| 41 |
int pauseLine = pausePosition.position.line; |
41 |
if (a.position.line == b.position.line) |
| 42 |
int pauseColumn = pausePosition.position.offset - pausePosition.position.lineStartOffset; |
42 |
return a.position.column() < b.position.column(); |
| 43 |
|
43 |
return a.position.line < b.position.line; |
| 44 |
if (line < pauseLine) { |
44 |
}); |
| 45 |
end = middle; |
45 |
if (it == m_positions.end()) |
| 46 |
continue; |
46 |
return WTF::nullopt; |
| 47 |
} |
|
|
| 48 |
if (line > pauseLine) { |
| 49 |
start = middle + 1; |
| 50 |
continue; |
| 51 |
} |
| 52 |
|
| 53 |
if (column == pauseColumn) { |
| 54 |
// Found an exact position match. Roll forward if this was a function Entry. |
| 55 |
// We are guarenteed to have a Leave for an Entry so we don't need to bounds check. |
| 56 |
while (true) { |
| 57 |
if (pausePosition.type != DebuggerPausePositionType::Enter) |
| 58 |
return Optional<JSTextPosition>(pausePosition.position); |
| 59 |
pausePosition = m_positions[middle++]; |
| 60 |
} |
| 61 |
} |
| 62 |
|
47 |
|
| 63 |
if (column < pauseColumn) |
48 |
if (line == it->position.line && column == it->position.column()) { |
| 64 |
end = middle; |
49 |
// Found an exact position match. Roll forward if this was a function Entry. |
| 65 |
else |
50 |
// We are guaranteed to have a Leave for an Entry so we don't need to bounds check. |
| 66 |
start = middle + 1; |
51 |
while (it->type == DebuggerPausePositionType::Enter) |
|
|
52 |
++it; |
| 53 |
return Optional<JSTextPosition>(it->position); |
| 67 |
} |
54 |
} |
| 68 |
|
55 |
|
| 69 |
// Past the end, no possible pause locations. |
|
|
| 70 |
if (start >= m_positions.size()) |
| 71 |
return WTF::nullopt; |
| 72 |
|
| 73 |
// If the next location is a function Entry we will need to decide if we should go into |
56 |
// If the next location is a function Entry we will need to decide if we should go into |
| 74 |
// the function or go past the function. We decide to go into the function if the |
57 |
// the function or go past the function. We decide to go into the function if the |
| 75 |
// input is on the same line as the function entry. For example: |
58 |
// input is on the same line as the function entry. For example: |
|
Lines 86-92
Optional<JSTextPosition> DebuggerPausePositions::breakpointLocationForLineColumn
a/Source/JavaScriptCore/debugger/DebuggerParseData.cpp_sec2
|
| 86 |
// If the input was line 3, go into the function to pause on line 4. |
69 |
// If the input was line 3, go into the function to pause on line 4. |
| 87 |
|
70 |
|
| 88 |
// Valid pause location. Use it. |
71 |
// Valid pause location. Use it. |
| 89 |
DebuggerPausePosition& firstSlidePosition = m_positions[start]; |
72 |
DebuggerPausePosition& firstSlidePosition = *it++; |
| 90 |
if (firstSlidePosition.type != DebuggerPausePositionType::Enter) |
73 |
if (firstSlidePosition.type != DebuggerPausePositionType::Enter) |
| 91 |
return Optional<JSTextPosition>(firstSlidePosition.position); |
74 |
return Optional<JSTextPosition>(firstSlidePosition.position); |
| 92 |
|
75 |
|
|
Lines 94-101
Optional<JSTextPosition> DebuggerPausePositions::breakpointLocationForLineColumn
a/Source/JavaScriptCore/debugger/DebuggerParseData.cpp_sec3
|
| 94 |
// If entryStackSize is > 0 we are skipping functions. |
77 |
// If entryStackSize is > 0 we are skipping functions. |
| 95 |
bool shouldEnterFunction = firstSlidePosition.position.line == line; |
78 |
bool shouldEnterFunction = firstSlidePosition.position.line == line; |
| 96 |
int entryStackSize = shouldEnterFunction ? 0 : 1; |
79 |
int entryStackSize = shouldEnterFunction ? 0 : 1; |
| 97 |
for (unsigned i = start + 1; i < m_positions.size(); ++i) { |
80 |
for (; it != m_positions.end(); ++it) { |
| 98 |
DebuggerPausePosition& slidePosition = m_positions[i]; |
81 |
auto& slidePosition = *it; |
| 99 |
ASSERT(entryStackSize >= 0); |
82 |
ASSERT(entryStackSize >= 0); |
| 100 |
|
83 |
|
| 101 |
// Already skipping functions. |
84 |
// Already skipping functions. |
|
Lines 124-129
Optional<JSTextPosition> DebuggerPausePositions::breakpointLocationForLineColumn
a/Source/JavaScriptCore/debugger/DebuggerParseData.cpp_sec4
|
| 124 |
void DebuggerPausePositions::sort() |
107 |
void DebuggerPausePositions::sort() |
| 125 |
{ |
108 |
{ |
| 126 |
std::sort(m_positions.begin(), m_positions.end(), [] (const DebuggerPausePosition& a, const DebuggerPausePosition& b) { |
109 |
std::sort(m_positions.begin(), m_positions.end(), [] (const DebuggerPausePosition& a, const DebuggerPausePosition& b) { |
|
|
110 |
if (a.position.offset == b.position.offset) |
| 111 |
return a.type < b.type; |
| 127 |
return a.position.offset < b.position.offset; |
112 |
return a.position.offset < b.position.offset; |
| 128 |
}); |
113 |
}); |
| 129 |
} |
114 |
} |