@@ -20,6 +20,7 @@ use rustc_span::{SourceFileHash, StableSourceFileId};
2020
2121pub ( crate ) use self :: emit:: { DebugReloc , DebugRelocName } ;
2222pub ( crate ) use self :: unwind:: UnwindContext ;
23+ use crate :: debuginfo:: emit:: address_for_func;
2324use crate :: prelude:: * ;
2425
2526pub ( crate ) fn producer ( sess : & Session ) -> String {
@@ -174,7 +175,6 @@ impl DebugContext {
174175 ) -> FunctionDebugContext {
175176 let ( file_id, line, column) = self . get_span_loc ( tcx, function_span, function_span) ;
176177
177- // FIXME: add to appropriate scope instead of root
178178 let scope = self . item_namespace ( tcx, tcx. parent ( instance. def_id ( ) ) ) ;
179179
180180 let mut name = String :: new ( ) ;
@@ -240,21 +240,16 @@ impl FunctionDebugContext {
240240 func_id : FuncId ,
241241 context : & Context ,
242242 ) {
243- let symbol = func_id . as_u32 ( ) as usize ;
243+ let end = self . create_debug_lines ( debug_context , func_id , context ) ;
244244
245- let end = self . create_debug_lines ( debug_context, symbol, context) ;
246-
247- debug_context. unit_range_list . 0 . push ( Range :: StartLength {
248- begin : Address :: Symbol { symbol, addend : 0 } ,
249- length : u64:: from ( end) ,
250- } ) ;
245+ debug_context
246+ . unit_range_list
247+ . 0
248+ . push ( Range :: StartLength { begin : address_for_func ( func_id) , length : u64:: from ( end) } ) ;
251249
252250 let func_entry = debug_context. dwarf . unit . get_mut ( self . entry_id ) ;
253251 // Gdb requires both DW_AT_low_pc and DW_AT_high_pc. Otherwise the DW_TAG_subprogram is skipped.
254- func_entry. set (
255- gimli:: DW_AT_low_pc ,
256- AttributeValue :: Address ( Address :: Symbol { symbol, addend : 0 } ) ,
257- ) ;
252+ func_entry. set ( gimli:: DW_AT_low_pc , AttributeValue :: Address ( address_for_func ( func_id) ) ) ;
258253 // Using Udata for DW_AT_high_pc requires at least DWARF4
259254 func_entry. set ( gimli:: DW_AT_high_pc , AttributeValue :: Udata ( u64:: from ( end) ) ) ;
260255 }
0 commit comments