Skip to content

Commit 9175a16

Browse files
committed
Generate proper debug info for function pointers
Instead of generating pointer debug info, we're currently generating subroutine debug info.
1 parent 47128b8 commit 9175a16

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/librustc_trans/trans/debuginfo/metadata.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,20 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
796796
}
797797
}
798798
ty::TyBareFn(_, ref barefnty) => {
799-
subroutine_type_metadata(cx, unique_type_id, &barefnty.sig, usage_site_span)
799+
let fn_metadata = subroutine_type_metadata(cx,
800+
unique_type_id,
801+
&barefnty.sig,
802+
usage_site_span).metadata;
803+
match debug_context(cx).type_map
804+
.borrow()
805+
.find_metadata_for_unique_id(unique_type_id) {
806+
Some(metadata) => return metadata,
807+
None => { /* proceed normally */ }
808+
};
809+
810+
// This is actually a function pointer, so wrap it in pointer DI
811+
MetadataCreationResult::new(pointer_type_metadata(cx, t, fn_metadata), false)
812+
800813
}
801814
ty::TyClosure(def_id, substs) => {
802815
let infcx = infer::normalizing_infer_ctxt(cx.tcx(), &cx.tcx().tables);

src/test/debuginfo/basic-types-metadata.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
// gdb-check:type = f32
4343
// gdb-command:whatis f64
4444
// gdb-check:type = f64
45+
// gdb-command:whatis fnptr
46+
// gdb-check:type = void (*)(void)
4547
// gdb-command:info functions _yyy
4648
// gdb-check:[...]![...]_yyy([...]);
4749
// gdb-command:continue
@@ -65,6 +67,7 @@ fn main() {
6567
let u64: u64 = 64;
6668
let f32: f32 = 2.5;
6769
let f64: f64 = 3.5;
70+
let fnptr : fn() = _zzz;
6871
_zzz(); // #break
6972
if 1 == 1 { _yyy(); }
7073
}

0 commit comments

Comments
 (0)