11mod emit;
22mod line_info;
3+ mod unwind;
34
45use crate :: prelude:: * ;
56
@@ -10,8 +11,8 @@ use cranelift_codegen::isa::TargetIsa;
1011use cranelift_codegen:: ValueLocRange ;
1112
1213use gimli:: write:: {
13- self , Address , AttributeValue , DwarfUnit , Expression , LineProgram , LineString , Location ,
14- LocationList , Range , RangeList , UnitEntryId , Writer ,
14+ self , Address , AttributeValue , CieId , DwarfUnit , Expression , FrameTable , LineProgram ,
15+ LineString , Location , LocationList , Range , RangeList , UnitEntryId , Writer ,
1516} ;
1617use gimli:: { Encoding , Format , LineEncoding , RunTimeEndian , X86_64 } ;
1718
@@ -34,13 +35,15 @@ pub(crate) struct DebugContext<'tcx> {
3435
3536 dwarf : DwarfUnit ,
3637 unit_range_list : RangeList ,
38+ frame_table : FrameTable ,
3739
40+ cie : CieId ,
3841 clif_types : FxHashMap < Type , UnitEntryId > ,
3942 types : FxHashMap < Ty < ' tcx > , UnitEntryId > ,
4043}
4144
4245impl < ' tcx > DebugContext < ' tcx > {
43- pub ( crate ) fn new ( tcx : TyCtxt < ' tcx > , address_size : u8 ) -> Self {
46+ pub ( crate ) fn new ( tcx : TyCtxt < ' tcx > , isa : & dyn TargetIsa ) -> Self {
4447 let encoding = Encoding {
4548 format : Format :: Dwarf32 ,
4649 // TODO: this should be configurable
@@ -53,7 +56,7 @@ impl<'tcx> DebugContext<'tcx> {
5356 // support it.
5457 4
5558 } ,
56- address_size,
59+ address_size : isa . frontend_config ( ) . pointer_bytes ( ) ,
5760 } ;
5861
5962 let mut dwarf = DwarfUnit :: new ( encoding) ;
@@ -108,6 +111,9 @@ impl<'tcx> DebugContext<'tcx> {
108111 ) ;
109112 }
110113
114+ let mut frame_table = FrameTable :: default ( ) ;
115+ let cie = frame_table. add_cie ( isa. create_systemv_cie ( ) . expect ( "SystemV unwind info CIE" ) ) ;
116+
111117 DebugContext {
112118 tcx,
113119
@@ -116,7 +122,9 @@ impl<'tcx> DebugContext<'tcx> {
116122
117123 dwarf,
118124 unit_range_list : RangeList ( Vec :: new ( ) ) ,
125+ frame_table,
119126
127+ cie,
120128 clif_types : FxHashMap :: default ( ) ,
121129 types : FxHashMap :: default ( ) ,
122130 }
@@ -312,6 +320,8 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
312320 source_info_set : & indexmap:: IndexSet < SourceInfo > ,
313321 local_map : FxHashMap < mir:: Local , CPlace < ' tcx > > ,
314322 ) {
323+ self . create_unwind_info ( context, isa) ;
324+
315325 let end = self . create_debug_lines ( context, isa, source_info_set) ;
316326
317327 self . debug_context
0 commit comments