Skip to content

Commit

Permalink
Generate lineinfo for default srcloc
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Jan 19, 2019
1 parent c7ede5b commit 3f247cc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ pub struct FunctionDebugContext<'a, 'tcx> {
debug_context: &'a mut DebugContext<'tcx>,
entry_id: UnitEntryId,
symbol: usize,
mir_span: Span,
}

impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> {
Expand Down Expand Up @@ -373,6 +374,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> {
debug_context,
entry_id,
symbol,
mir_span: mir.span,
}
}

Expand Down Expand Up @@ -419,9 +421,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> {
ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase
for ebb in ebbs {
for (offset, inst, _size) in func.inst_offsets(ebb, &encinfo) {
let srcloc = func.srclocs[inst];
if !srcloc.is_default() {
let span = spans[srcloc.bits() as usize];
fn create_row_for_span(tcx: TyCtxt, line_program: &mut LineProgram, offset: u64, span: Span) {
let loc = tcx.sess.source_map().lookup_char_pos(span.lo());
let file = loc.file.name.to_string();
let file = ::std::path::Path::new(&file);
Expand All @@ -435,10 +435,18 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> {
line_program.row().file = file_id;
//tcx.sess
// .warn(&format!("srcloc {} {}:{}:{}", offset, file, loc.line, loc.col.to_usize()));
line_program.row().address_offset = offset as u64;
line_program.row().address_offset = offset;
line_program.row().line = loc.line as u64;
line_program.generate_row();
}

let srcloc = func.srclocs[inst];
if !srcloc.is_default() {
let span = spans[srcloc.bits() as usize];
create_row_for_span(tcx, line_program, offset as u64, span);
} else {
create_row_for_span(tcx, line_program, offset as u64, self.mir_span);
}
}
}

Expand Down

0 comments on commit 3f247cc

Please sign in to comment.