@@ -959,7 +959,6 @@ class CommandObjectThreadUntil : public CommandObjectParsed {
959959 }
960960
961961 LineEntry function_start;
962- uint32_t index_ptr = 0 , end_ptr = UINT32_MAX;
963962 std::vector<addr_t > address_list;
964963
965964 // Find the beginning & end index of the function, but first make
@@ -970,19 +969,14 @@ class CommandObjectThreadUntil : public CommandObjectParsed {
970969 return ;
971970 }
972971
973- AddressRange fun_addr_range = sc.function ->GetAddressRange ();
974- Address fun_start_addr = fun_addr_range.GetBaseAddress ();
975- line_table->FindLineEntryByAddress (fun_start_addr, function_start,
976- &index_ptr);
977-
978- Address fun_end_addr (fun_start_addr.GetSection (),
979- fun_start_addr.GetOffset () +
980- fun_addr_range.GetByteSize ());
981-
982- bool all_in_function = true ;
972+ RangeVector<uint32_t , uint32_t > line_idx_ranges;
973+ for (const AddressRange &range : sc.function ->GetAddressRanges ()) {
974+ auto [begin, end] = line_table->GetLineEntryIndexRange (range);
975+ line_idx_ranges.Append (begin, end - begin);
976+ }
977+ line_idx_ranges.Sort ();
983978
984- line_table->FindLineEntryByAddress (fun_end_addr, function_start,
985- &end_ptr);
979+ bool found_something = false ;
986980
987981 // Since not all source lines will contribute code, check if we are
988982 // setting the breakpoint on the exact line number or the nearest
@@ -991,45 +985,43 @@ class CommandObjectThreadUntil : public CommandObjectParsed {
991985 for (uint32_t line_number : line_numbers) {
992986 LineEntry line_entry;
993987 bool exact = false ;
994- uint32_t start_idx_ptr = index_ptr;
995- start_idx_ptr = sc.comp_unit ->FindLineEntry (
996- index_ptr, line_number, nullptr , exact, &line_entry);
997- if (start_idx_ptr != UINT32_MAX)
998- line_number = line_entry.line ;
988+ if (sc.comp_unit ->FindLineEntry (0 , line_number, nullptr , exact,
989+ &line_entry) == UINT32_MAX)
990+ continue ;
991+
992+ found_something = true ;
993+ line_number = line_entry.line ;
999994 exact = true ;
1000- start_idx_ptr = index_ptr;
1001- while (start_idx_ptr <= end_ptr) {
1002- start_idx_ptr = sc.comp_unit ->FindLineEntry (
1003- start_idx_ptr, line_number, nullptr , exact, &line_entry);
1004- if (start_idx_ptr == UINT32_MAX)
1005- break ;
1006-
1007- addr_t address =
1008- line_entry.range .GetBaseAddress ().GetLoadAddress (target);
1009- if (address != LLDB_INVALID_ADDRESS) {
1010- if (fun_addr_range.ContainsLoadAddress (address, target))
995+ uint32_t end_func_idx = line_idx_ranges.GetMaxRangeEnd (0 );
996+ uint32_t idx = sc.comp_unit ->FindLineEntry (
997+ line_idx_ranges.GetMinRangeBase (UINT32_MAX), line_number, nullptr ,
998+ exact, &line_entry);
999+ while (idx < end_func_idx) {
1000+ if (line_idx_ranges.FindEntryIndexThatContains (idx) != UINT32_MAX) {
1001+ addr_t address =
1002+ line_entry.range .GetBaseAddress ().GetLoadAddress (target);
1003+ if (address != LLDB_INVALID_ADDRESS)
10111004 address_list.push_back (address);
1012- else
1013- all_in_function = false ;
10141005 }
1015- start_idx_ptr++;
1006+ idx = sc.comp_unit ->FindLineEntry (idx + 1 , line_number, nullptr ,
1007+ exact, &line_entry);
10161008 }
10171009 }
10181010
10191011 for (lldb::addr_t address : m_options.m_until_addrs ) {
1020- if (fun_addr_range.ContainsLoadAddress (address, target))
1012+ AddressRange unused;
1013+ if (sc.function ->GetRangeContainingLoadAddress (address, *target,
1014+ unused))
10211015 address_list.push_back (address);
1022- else
1023- all_in_function = false ;
10241016 }
10251017
10261018 if (address_list.empty ()) {
1027- if (all_in_function )
1019+ if (found_something )
10281020 result.AppendErrorWithFormat (
1029- " No line entries matching until target .\n " );
1021+ " Until target outside of the current function .\n " );
10301022 else
10311023 result.AppendErrorWithFormat (
1032- " Until target outside of the current function .\n " );
1024+ " No line entries matching until target .\n " );
10331025
10341026 return ;
10351027 }
0 commit comments