use crate::prelude::*;
-use rustc_span::{CachingSourceMapView, FileName};
+use rustc_span::FileName;
use cranelift_codegen::binemit::CodeOffset;
impl<'tcx> DebugContext<'tcx> {
pub(super) fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) {
- let (file, line, col) = self.source_map.byte_pos_to_line_and_col(span.lo()).unwrap();
+ let loc = self.tcx.sess.source_map().lookup_char_pos(span.lo());
let file_id = line_program_add_file(
&mut self.dwarf.unit.line_program,
&mut self.dwarf.line_strings,
- &file.name,
+ &loc.file.name,
);
let entry = self.dwarf.unit.get_mut(entry_id);
);
entry.set(
gimli::DW_AT_decl_line,
- AttributeValue::Udata(line as u64),
+ AttributeValue::Udata(loc.line as u64),
);
// FIXME: probably omit this
entry.set(
gimli::DW_AT_decl_column,
- AttributeValue::Udata(col.to_usize() as u64),
+ AttributeValue::Udata(loc.col.to_usize() as u64),
);
}
}
source_info_set: &indexmap::IndexSet<SourceInfo>,
) -> CodeOffset {
let tcx = self.debug_context.tcx;
- let mut source_map = CachingSourceMapView::new(tcx.sess.source_map());
let line_program = &mut self.debug_context.dwarf.unit.line_program;
let line_strings = &mut self.debug_context.dwarf.line_strings;
let mut last_file = None;
let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| {
- let (file, line, col) = source_map.byte_pos_to_line_and_col(span.lo()).unwrap();
+ let loc = tcx.sess.source_map().lookup_char_pos(span.lo());
// line_program_add_file is very slow.
// Optimize for the common case of the current file not being changed.
let current_file_changed = if let Some(last_file) = &mut last_file {
// If the allocations are not equal, then the files may still be equal, but that
// is not a problem, as this is just an optimization.
- !Lrc::ptr_eq(last_file, &file)
+ !Lrc::ptr_eq(last_file, &loc.file)
} else {
true
};
if current_file_changed {
- let file_id = line_program_add_file(line_program, line_strings, &file.name);
+ let file_id = line_program_add_file(line_program, line_strings, &loc.file.name);
line_program.row().file = file_id;
- last_file = Some(file.clone());
+ last_file = Some(loc.file.clone());
}
- line_program.row().line = line as u64;
- line_program.row().column = col.to_u32() as u64 + 1;
+ line_program.row().line = loc.line as u64;
+ line_program.row().column = loc.col.to_u32() as u64 + 1;
line_program.generate_row();
};
use crate::prelude::*;
-use rustc_span::CachingSourceMapView;
-
use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc};
use cranelift_codegen::isa::RegUnit;
use cranelift_codegen::ValueLocRange;
unit_range_list: RangeList,
types: HashMap<Ty<'tcx>, UnitEntryId>,
-
- source_map: CachingSourceMapView<'tcx>,
}
impl<'tcx> DebugContext<'tcx> {
unit_range_list: RangeList(Vec::new()),
types: HashMap::new(),
-
- source_map: CachingSourceMapView::new(tcx.sess.source_map()),
}
}