@@ -542,13 +542,23 @@ fn create_tuple(cx: @CrateContext, t: ty::t, elements: &[ty::t], span: span)
542
542
return mdval;
543
543
}
544
544
545
- fn create_boxed_type ( cx : @CrateContext , outer : ty:: t , _inner : ty:: t ,
545
+ // returns (void* type as a ValueRef, size in bytes, align in bytes)
546
+ fn voidptr ( ) -> ( ValueRef , int , int ) {
547
+ let null = ptr:: null ( ) ;
548
+ let size = sys:: size_of :: < ValueRef > ( ) as int ;
549
+ let align = sys:: min_align_of :: < ValueRef > ( ) as int ;
550
+ let vp = create_derived_type ( PointerTypeTag , null, ~"", 0 ,
551
+ size, align, 0 , null) ;
552
+ return ( vp, size, align) ;
553
+ }
554
+
555
+ fn create_boxed_type ( cx : @CrateContext , contents : ty:: t ,
546
556
span : span , boxed : @Metadata < TyDescMetadata > )
547
557
-> @Metadata < TyDescMetadata > {
548
558
//let tg = StructureTypeTag;
549
559
/*let cache = cx.llmetadata;
550
560
match cached_metadata::<@Metadata<TyDescMetadata>>(
551
- cache, tg, {|md| ty::hash_ty(outer ) == ty::hash_ty(md.data.hash)}) {
561
+ cache, tg, {|md| ty::hash_ty(contents ) == ty::hash_ty(md.data.hash)}) {
552
562
option::Some(md) { return md; }
553
563
option::None {}
554
564
}*/
@@ -557,18 +567,23 @@ fn create_boxed_type(cx: @CrateContext, outer: ty::t, _inner: ty::t,
557
567
//let cu_node = create_compile_unit_metadata(cx, fname);
558
568
let uint_t = ty:: mk_uint ( cx. tcx ) ;
559
569
let refcount_type = create_basic_type ( cx, uint_t, span) ;
560
- let scx = create_structure ( file_node ,
561
- @/ * bad * / copy ty_to_str ( cx . tcx , outer ) , 0 ) ;
570
+ let name = ty_to_str ( cx . tcx , contents ) ;
571
+ let scx = create_structure ( file_node , @ fmt ! ( "box<%s>" , name ) , 0 ) ;
562
572
add_member ( scx, ~"refcnt", 0 , sys:: size_of :: < uint > ( ) as int ,
563
573
sys:: min_align_of :: < uint > ( ) as int , refcount_type. node ) ;
564
- add_member ( scx, ~"boxed", 0 , 8 , //XXX member_size_and_align(??)
565
- 8 , //XXX just a guess
566
- boxed. node ) ;
574
+ // the tydesc and other pointers should be irrelevant to the
575
+ // debugger, so treat them as void* types
576
+ let ( vp, vpsize, vpalign) = voidptr ( ) ;
577
+ add_member ( scx, ~"tydesc", 0 , vpsize, vpalign, vp) ;
578
+ add_member ( scx, ~"prev", 0 , vpsize, vpalign, vp) ;
579
+ add_member ( scx, ~"next", 0 , vpsize, vpalign, vp) ;
580
+ let ( size, align) = size_and_align_of ( cx, contents) ;
581
+ add_member ( scx, ~"boxed", 0 , size, align, boxed. node ) ;
567
582
let llnode = finish_structure ( scx) ;
568
583
let mdval = @Metadata {
569
584
node : llnode,
570
585
data : TyDescMetadata {
571
- hash : ty:: type_id ( outer )
586
+ hash : ty:: type_id ( contents )
572
587
}
573
588
} ;
574
589
//update_cache(cache, tg, tydesc_metadata(mdval));
@@ -655,11 +670,10 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
655
670
ty:: ty_enum( _did, ref _substs) => {
656
671
cx. sess . span_bug ( span, ~"debuginfo for enum NYI ")
657
672
}
658
- ty:: ty_box( ref _mt) => {
659
- cx. sess . span_bug ( span, ~"debuginfo for box NYI ")
660
- } ,
661
- ty:: ty_uniq( ref _mt) => {
662
- cx. sess . span_bug ( span, ~"debuginfo for uniq NYI ")
673
+ ty:: ty_box( ref mt) | ty:: ty_uniq( ref mt) => {
674
+ let boxed = create_ty ( cx, mt. ty , span) ;
675
+ let box_md = create_boxed_type ( cx, mt. ty , span, boxed) ;
676
+ create_pointer_type ( cx, t, span, box_md)
663
677
} ,
664
678
ty:: ty_evec ( ref _mt, ref _vstore) => {
665
679
cx. sess . span_bug ( span, ~"debuginfo for evec NYI ")
0 commit comments