Skip to content

Commit 3f247cc

Browse files
committed
Generate lineinfo for default srcloc
1 parent c7ede5b commit 3f247cc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/debuginfo.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ pub struct FunctionDebugContext<'a, 'tcx> {
337337
debug_context: &'a mut DebugContext<'tcx>,
338338
entry_id: UnitEntryId,
339339
symbol: usize,
340+
mir_span: Span,
340341
}
341342

342343
impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> {
@@ -373,6 +374,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> {
373374
debug_context,
374375
entry_id,
375376
symbol,
377+
mir_span: mir.span,
376378
}
377379
}
378380

@@ -419,9 +421,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> {
419421
ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase
420422
for ebb in ebbs {
421423
for (offset, inst, _size) in func.inst_offsets(ebb, &encinfo) {
422-
let srcloc = func.srclocs[inst];
423-
if !srcloc.is_default() {
424-
let span = spans[srcloc.bits() as usize];
424+
fn create_row_for_span(tcx: TyCtxt, line_program: &mut LineProgram, offset: u64, span: Span) {
425425
let loc = tcx.sess.source_map().lookup_char_pos(span.lo());
426426
let file = loc.file.name.to_string();
427427
let file = ::std::path::Path::new(&file);
@@ -435,10 +435,18 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> {
435435
line_program.row().file = file_id;
436436
//tcx.sess
437437
// .warn(&format!("srcloc {} {}:{}:{}", offset, file, loc.line, loc.col.to_usize()));
438-
line_program.row().address_offset = offset as u64;
438+
line_program.row().address_offset = offset;
439439
line_program.row().line = loc.line as u64;
440440
line_program.generate_row();
441441
}
442+
443+
let srcloc = func.srclocs[inst];
444+
if !srcloc.is_default() {
445+
let span = spans[srcloc.bits() as usize];
446+
create_row_for_span(tcx, line_program, offset as u64, span);
447+
} else {
448+
create_row_for_span(tcx, line_program, offset as u64, self.mir_span);
449+
}
442450
}
443451
}
444452

0 commit comments

Comments
 (0)