]> git.lizzy.rs Git - rust.git/commitdiff
Generate proper debug info for function pointers
authorBjörn Steinbrink <bsteinbr@gmail.com>
Mon, 13 Jul 2015 19:50:21 +0000 (21:50 +0200)
committerBjörn Steinbrink <bsteinbr@gmail.com>
Sat, 18 Jul 2015 15:31:48 +0000 (17:31 +0200)
Instead of generating pointer debug info, we're currently generating
subroutine debug info.

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

index d1f524038961316a66a69c4a5fe654a538c705fd..33f60d7e78d968502ebc69f348165a246667b820 100644 (file)
@@ -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);
index 57dabadfbd546c9e17ce491a4dd7b817b83c2a6e..1bc2ddef51e05031f88bb6d2078d11785ecbfad4 100644 (file)
@@ -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(); }
 }