@@ -213,69 +213,17 @@ bool LineTable::FindLineEntryByAddress(const Address &so_addr,
213
213
if (index_ptr != nullptr )
214
214
*index_ptr = UINT32_MAX;
215
215
216
- bool success = false ;
217
-
218
- if (so_addr.GetModule ().get () == m_comp_unit->GetModule ().get ()) {
219
- Entry search_entry;
220
- search_entry.file_addr = so_addr.GetFileAddress ();
221
- if (search_entry.file_addr != LLDB_INVALID_ADDRESS) {
222
- entry_collection::const_iterator begin_pos = m_entries.begin ();
223
- entry_collection::const_iterator end_pos = m_entries.end ();
224
- entry_collection::const_iterator pos = std::lower_bound (
225
- begin_pos, end_pos, search_entry, Entry::EntryAddressLessThan);
226
- if (pos != end_pos) {
227
- if (pos != begin_pos) {
228
- if (pos->file_addr != search_entry.file_addr )
229
- --pos;
230
- else if (pos->file_addr == search_entry.file_addr ) {
231
- // If this is a termination entry, it shouldn't match since entries
232
- // with the "is_terminal_entry" member set to true are termination
233
- // entries that define the range for the previous entry.
234
- if (pos->is_terminal_entry ) {
235
- // The matching entry is a terminal entry, so we skip ahead to
236
- // the next entry to see if there is another entry following this
237
- // one whose section/offset matches.
238
- ++pos;
239
- if (pos != end_pos) {
240
- if (pos->file_addr != search_entry.file_addr )
241
- pos = end_pos;
242
- }
243
- }
244
-
245
- if (pos != end_pos) {
246
- // While in the same section/offset backup to find the first line
247
- // entry that matches the address in case there are multiple
248
- while (pos != begin_pos) {
249
- entry_collection::const_iterator prev_pos = pos - 1 ;
250
- if (prev_pos->file_addr == search_entry.file_addr &&
251
- prev_pos->is_terminal_entry == false )
252
- --pos;
253
- else
254
- break ;
255
- }
256
- }
257
- }
258
- }
259
- else
260
- {
261
- // There might be code in the containing objfile before the first
262
- // line table entry. Make sure that does not get considered part of
263
- // the first line table entry.
264
- if (pos->file_addr > so_addr.GetFileAddress ())
265
- return false ;
266
- }
216
+ uint32_t idx = lower_bound (so_addr);
217
+ if (idx >= GetSize ())
218
+ return false ;
267
219
268
- // Make sure we have a valid match and that the match isn't a
269
- // terminating entry for a previous line...
270
- if (pos != end_pos && pos->is_terminal_entry == false ) {
271
- uint32_t match_idx = std::distance (begin_pos, pos);
272
- success = ConvertEntryAtIndexToLineEntry (match_idx, line_entry);
273
- if (index_ptr != nullptr && success)
274
- *index_ptr = match_idx;
275
- }
276
- }
277
- }
278
- }
220
+ addr_t file_addr = so_addr.GetFileAddress ();
221
+ if (m_entries[idx].file_addr > file_addr)
222
+ return false ;
223
+
224
+ bool success = ConvertEntryAtIndexToLineEntry (idx, line_entry);
225
+ if (index_ptr != nullptr && success)
226
+ *index_ptr = idx;
279
227
return success;
280
228
}
281
229
0 commit comments