Skip to content

Commit

Permalink
Generate proper debug info for function pointers
Browse files Browse the repository at this point in the history
Instead of generating pointer debug info, we're currently generating
subroutine debug info.
  • Loading branch information
dotdash committed Jul 18, 2015
1 parent 47128b8 commit 9175a16
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/librustc_trans/trans/debuginfo/metadata.rs
Expand Up @@ -796,7 +796,20 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
}
ty::TyBareFn(_, ref barefnty) => {
subroutine_type_metadata(cx, unique_type_id, &barefnty.sig, usage_site_span)
let fn_metadata = subroutine_type_metadata(cx,
unique_type_id,
&barefnty.sig,
usage_site_span).metadata;
match debug_context(cx).type_map
.borrow()
.find_metadata_for_unique_id(unique_type_id) {
Some(metadata) => return metadata,
None => { /* proceed normally */ }
};

// This is actually a function pointer, so wrap it in pointer DI
MetadataCreationResult::new(pointer_type_metadata(cx, t, fn_metadata), false)

}
ty::TyClosure(def_id, substs) => {
let infcx = infer::normalizing_infer_ctxt(cx.tcx(), &cx.tcx().tables);
Expand Down
3 changes: 3 additions & 0 deletions src/test/debuginfo/basic-types-metadata.rs
Expand Up @@ -42,6 +42,8 @@
// gdb-check:type = f32
// gdb-command:whatis f64
// gdb-check:type = f64
// gdb-command:whatis fnptr
// gdb-check:type = void (*)(void)
// gdb-command:info functions _yyy
// gdb-check:[...]![...]_yyy([...]);
// gdb-command:continue
Expand All @@ -65,6 +67,7 @@ fn main() {
let u64: u64 = 64;
let f32: f32 = 2.5;
let f64: f64 = 3.5;
let fnptr : fn() = _zzz;
_zzz(); // #break
if 1 == 1 { _yyy(); }
}
Expand Down

0 comments on commit 9175a16

Please sign in to comment.