src/developer/debug/zxdb/console/format_context.cc
// Generates the source listing for source intersperced with assembly code for the source between
// the given two lines. The prev_line is the last one outputted.
//
// This re-opens and line splits the file for each block of source shown. This is very inefficient
// but normally disassembly is not performance sensitive. If needed this could be cached.
//
// The module_for_time_warning is an optional pointer to the module corresponding to this source
// file so we can show warnings if the build is out-of-date.
Generates the source listing for source intersperced with assembly code for the source between
the given two lines. The prev_line is the last one outputted.

This re-opens and line splits the file for each block of source shown. This is very inefficient
but normally disassembly is not performance sensitive. If needed this could be cached.

The module_for_time_warning is an optional pointer to the module corresponding to this source
file so we can show warnings if the build is out-of-date.
Generates the source listing for source intersperced with assembly code for the source between the given two lines . The prev_line is the last one outputted . This re - opens and line splits the file for each block of source shown . This is very inefficient but normally disassembly is not performance sensitive . If needed this could be cached . The module_for_time_warning is an optional pointer to the module corresponding to this source file so we can show warnings if the build is out - of - date .
OutputBuffer FormatAsmSourceForRange(Process* process,
                                     fxl::WeakPtr<ModuleSymbols> module_for_time_warning,
                                     const SourceFileProvider& file_provider,
                                     const FileLine& prev_line, const FileLine& line) {
  constexpr int kMaxContext = 4;
  int first_num = line.line() - kMaxContext + 1;  
  if (prev_line.file() == line.file())            
    first_num = std::max(prev_line.line() + 1, first_num);
  first_num = std::max(1, first_num);  
  FormatSourceOpts opts;
  opts.first_line = first_num;
  opts.last_line = line.line();
  opts.left_indent = 2;
  opts.dim_others = true;  
  opts.module_for_time_warning = std::move(module_for_time_warning);
  FileLine start_line(line.file(), first_num);
  OutputBuffer out;
  if (FormatSourceFileContext(start_line, file_provider, opts, &out).ok()) {
    out.TrimTrailingNewlines();
    return out;
  }
  return OutputBuffer(Syntax::kComment,
                      DescribeFileLine(process->GetSymbols()->target_symbols(), start_line));
}
OutputBuffer FormatAsmSourceForRange ( Process * process , fxl :: WeakPtr < ModuleSymbols > module_for_time_warning , const SourceFileProvider & file_provider , const FileLine & prev_line , const FileLine & line ) { constexpr int kMaxContext = 4 ; int first_num = line . line ( ) - kMaxContext + 1 ; if ( prev_line . file ( ) == line . file ( ) ) first_num = std :: max ( prev_line . line ( ) + 1 , first_num ) ; first_num = std :: max ( 1 , first_num ) ; FormatSourceOpts opts ; opts . first_line = first_num ; opts . last_line = line . line ( ) ; opts . left_indent = 2 ; opts . dim_others = true ; opts . module_for_time_warning = std :: move ( module_for_time_warning ) ; FileLine start_line ( line . file ( ) , first_num ) ; OutputBuffer out ; if ( FormatSourceFileContext ( start_line , file_provider , opts , & out ) . ok ( ) ) { out . TrimTrailingNewlines ( ) ; return out ; } return OutputBuffer ( Syntax :: kComment , DescribeFileLine ( process -> GetSymbols ( ) -> target_symbols ( ) , start_line ) ) ; }
Generates the source listing for source intersperced with assembly code for the source between
the given two lines.
Generates the source listing for source intersperced with assembly code for the source between the given two lines .
// Maximum number of lines of source we'll include. // Most context we'll show. // Same file, try to include since the last line. // Clamp to beginning of file. // Dim everything (we didn't specify an active line). // The formatted table will end in a newline which will combine with our table's newline and // insert a blank below the source code. Trim the embedded newline so we only get one. // Some error getting the source code, show the location file/line number instead.