Skip to content

Commit cf22d74

Browse files
committed
Add debug info for bare_fn type
1 parent 917d5ab commit cf22d74

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/librustc/middle/trans/debuginfo.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ fn create_pointer_type(cx: @CrateContext, t: ty::t, span: span,
420420
let fname = filename_from_span(cx, span);
421421
let file_node = create_file(cx, fname);
422422
//let cu_node = create_compile_unit(cx, fname);
423-
let llnode = create_derived_type(tg, file_node.node, ~"", 0, size * 8,
423+
let name = ty_to_str(cx.tcx, t);
424+
let llnode = create_derived_type(tg, file_node.node, name, 0, size * 8,
424425
align * 8, 0, pointee.node);
425426
let mdval = @Metadata {
426427
node: llnode,
@@ -714,6 +715,26 @@ fn create_vec_slice(cx: @CrateContext, vec_t: ty::t, elem_t: ty::t, span: span)
714715
return mdval;
715716
}
716717

718+
fn create_fn_ty(cx: @CrateContext, fn_ty: ty::t, inputs: ~[ty::t], output: ty::t,
719+
span: span) -> @Metadata<TyDescMetadata> {
720+
let fname = filename_from_span(cx, span);
721+
let file_node = create_file(cx, fname);
722+
let (vp, _, _) = voidptr();
723+
let output_md = create_ty(cx, output, span);
724+
let output_ptr_md = create_pointer_type(cx, output, span, output_md);
725+
let inputs_vals = do inputs.map |arg| { create_ty(cx, *arg, span).node };
726+
let members = ~[output_ptr_md.node, vp] + inputs_vals;
727+
let llnode = create_composite_type(SubroutineTag, ~"", file_node.node,
728+
0, 0, 0, 0, None, Some(members));
729+
let mdval = @Metadata {
730+
node: llnode,
731+
data: TyDescMetadata {
732+
hash: ty::type_id(fn_ty)
733+
}
734+
};
735+
return mdval;
736+
}
737+
717738
fn create_ty(cx: @CrateContext, t: ty::t, span: span)
718739
-> @Metadata<TyDescMetadata> {
719740
debug!("create_ty: %?", ty::get(t));
@@ -772,8 +793,10 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
772793
ty::ty_rptr(ref _region, ref _mt) => {
773794
cx.sess.span_bug(span, ~"debuginfo for rptr NYI")
774795
},
775-
ty::ty_bare_fn(ref _barefnty) => {
776-
cx.sess.span_bug(span, ~"debuginfo for bare_fn NYI")
796+
ty::ty_bare_fn(ref barefnty) => {
797+
let inputs = do barefnty.sig.inputs.map |a| { a.ty };
798+
let output = barefnty.sig.output;
799+
create_fn_ty(cx, t, inputs, output, span)
777800
},
778801
ty::ty_closure(ref _closurety) => {
779802
cx.sess.span_bug(span, ~"debuginfo for closure NYI")

0 commit comments

Comments
 (0)