src/developer/debug/zxdb/client/substatement.cc
// Checks all addresses in the given address range and adds the ranges that map to the given
// file_line to the output. This will also check for ranges that begin in the range but end outside
// of it.
//
// If expand_after_line_0 is set, if a query returns "line 0" from the line table (compiler
// generated code), it will consider the code immediately following it, even if that code is outside
// of the input range. This is used when the range being queried is open-ended and you just want
// all contiguous matching lines starting at a given address without being tripped up by a "line 0"
// entry at the beginning.
//
// This just does many individual queries. This could be done faster using the line table directly
// since then we can go through it linearly for the range we care about. But that approach makes the
// querying more complex and so far this has not shown to be too slow.
Checks all addresses in the given address range and adds the ranges that map to the given
file_line to the output. This will also check for ranges that begin in the range but end outside
of it.

If expand_after_line_0 is set, if a query returns "line 0" from the line table (compiler
generated code), it will consider the code immediately following it, even if that code is outside
of the input range. This is used when the range being queried is open-ended and you just want
all contiguous matching lines starting at a given address without being tripped up by a "line 0"
entry at the beginning.

This just does many individual queries. This could be done faster using the line table directly
since then we can go through it linearly for the range we care about. But that approach makes the
querying more complex and so far this has not shown to be too slow.
Checks all addresses in the given address range and adds the ranges that map to the given file_line to the output . This will also check for ranges that begin in the range but end outside of it . If expand_after_line_0 is set if a query returns " line 0 " from the line table ( compiler generated code ) it will consider the code immediately following it even if that code is outside of the input range . This is used when the range being queried is open - ended and you just want all contiguous matching lines starting at a given address without being tripped up by a " line 0 " entry at the beginning . This just does many individual queries . This could be done faster using the line table directly since then we can go through it linearly for the range we care about . But that approach makes the querying more complex and so far this has not shown to be too slow .
void AppendAddressRangesForLineInRange(Process* process, const FileLine& file_line,
                                       const AddressRange& range, bool expand_after_line_0,
                                       AddressRanges::RangeVector* out) {
  constexpr uint64_t kMaxRangeSize = 1024;
  bool allow_next_query_out_of_range = false;  
  TargetPointer cur = range.begin();
  while (allow_next_query_out_of_range ||
         (cur < range.end() && cur - range.begin() < kMaxRangeSize)) {
    LineDetails line_details = process->GetSymbols()->LineDetailsForAddress(cur);
    if (!line_details.is_valid())
      return;
    AddressRange extent = line_details.GetExtent();
    if (extent.empty())
      return;
    if (line_details.file_line() == file_line)
      out->push_back(extent);
    allow_next_query_out_of_range = line_details.file_line().line() == 0 && expand_after_line_0;
    cur = extent.end();
  }
}
void AppendAddressRangesForLineInRange ( Process * process , const FileLine & file_line , const AddressRange & range , bool expand_after_line_0 , AddressRanges :: RangeVector * out ) { constexpr uint64_t kMaxRangeSize = 1024 ; bool allow_next_query_out_of_range = false ; TargetPointer cur = range . begin ( ) ; while ( allow_next_query_out_of_range || ( cur < range . end ( ) && cur - range . begin ( ) < kMaxRangeSize ) ) { LineDetails line_details = process -> GetSymbols ( ) -> LineDetailsForAddress ( cur ) ; if ( ! line_details . is_valid ( ) ) return ; AddressRange extent = line_details . GetExtent ( ) ; if ( extent . empty ( ) ) return ; if ( line_details . file_line ( ) == file_line ) out -> push_back ( extent ) ; allow_next_query_out_of_range = line_details . file_line ( ) . line ( ) == 0 && expand_after_line_0 ; cur = extent . end ( ) ; } }
Checks all addresses in the given address range and adds the ranges that map to the given
file_line to the output.
Checks all addresses in the given address range and adds the ranges that map to the given file_line to the output .
// Sanity threshold to avoid doing too many queries if the symbols are corrupt or very different // than we expect. // Used to implement expand_after_line_0. See above.