diff options
| author | Björn Steinbrink <bsteinbr@gmail.com> | 2015-07-13 21:50:21 +0200 |
|---|---|---|
| committer | Björn Steinbrink <bsteinbr@gmail.com> | 2015-07-18 17:31:48 +0200 |
| commit | 9175a16bd8c5b37c485dfe36fea8f9df96e02bf0 (patch) | |
| tree | 6c3bb63127fb341875fd7fa9fd183f585e7c6a15 | |
| parent | 47128b8c7ed38b28e1e7788bc9d5197959d450e8 (diff) | |
| download | rust-9175a16bd8c5b37c485dfe36fea8f9df96e02bf0.tar.gz rust-9175a16bd8c5b37c485dfe36fea8f9df96e02bf0.zip | |
Generate proper debug info for function pointers
Instead of generating pointer debug info, we're currently generating subroutine debug info.
| -rw-r--r-- | src/librustc_trans/trans/debuginfo/metadata.rs | 15 | ||||
| -rw-r--r-- | src/test/debuginfo/basic-types-metadata.rs | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index d1f52403896..33f60d7e78d 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -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); diff --git a/src/test/debuginfo/basic-types-metadata.rs b/src/test/debuginfo/basic-types-metadata.rs index 57dabadfbd5..1bc2ddef51e 100644 --- a/src/test/debuginfo/basic-types-metadata.rs +++ b/src/test/debuginfo/basic-types-metadata.rs @@ -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 @@ -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(); } } |
