@@ -79,6 +79,21 @@ fn get_entry_name(
7979 }
8080}
8181
82+ /// Gets the string value from the `DW_AT_linkage_name` attribute of the given entry if it's present
83+ fn get_entry_linkage_name (
84+ dwarf : & Dwarf < DefaultReader > ,
85+ unit : & Unit < DefaultReader , usize > ,
86+ entry : & DebuggingInformationEntry < DefaultReader , usize > ,
87+ ) -> Result < Option < String > , TraceError > {
88+ // Find the attribute
89+ let Some ( linkage_name_attr) = entry. attr ( gimli:: constants:: DW_AT_linkage_name ) ? else {
90+ return Ok ( None ) ;
91+ } ;
92+
93+ let attr_string = dwarf. attr_string ( unit, linkage_name_attr. value ( ) ) ?;
94+ Ok ( Some ( attr_string. to_string ( ) ?. into ( ) ) )
95+ }
96+
8297/// If available, get the EntriesTree of the `DW_AT_abstract_origin` attribute of the given entry
8398fn get_entry_abstract_origin_reference_tree < ' abbrev , ' unit > (
8499 dwarf : & Dwarf < DefaultReader > ,
@@ -270,7 +285,7 @@ where
270285 let frame_base_data = get_variable_data (
271286 device_memory,
272287 core:: mem:: size_of :: < W > ( ) as u64 * 8 ,
273- frame_base_location,
288+ & frame_base_location,
274289 ) ;
275290
276291 Ok ( frame_base_data. ok ( ) . map ( |data| data. load_le ( ) ) )
@@ -599,7 +614,7 @@ where
599614 let entry_data = get_variable_data (
600615 device_memory,
601616 W :: BITS as u64 ,
602- VariableLocationResult :: LocationsFound ( entry_pieces) ,
617+ & VariableLocationResult :: LocationsFound ( entry_pieces) ,
603618 ) ?;
604619
605620 result = evaluation. resume_with_entry_value ( gimli:: Value :: Generic (
@@ -720,7 +735,7 @@ where
720735fn get_variable_data < W : funty:: Integral > (
721736 device_memory : & DeviceMemory < W > ,
722737 variable_size : u64 ,
723- variable_location : VariableLocationResult ,
738+ variable_location : & VariableLocationResult ,
724739) -> Result < BitVec < u8 , Lsb0 > , VariableDataError >
725740where
726741 <W as funty:: Numeric >:: Bytes : bitvec:: view:: BitView < Store = u8 > ,
@@ -759,6 +774,22 @@ where
759774 }
760775}
761776
777+ /// Returns the first found address in the location (if any)
778+ fn get_variable_address ( variable_location : & VariableLocationResult ) -> Option < u64 > {
779+ match variable_location {
780+ VariableLocationResult :: LocationsFound ( pieces) => {
781+ for piece in pieces {
782+ match piece. location {
783+ gimli:: Location :: Address { address } => return Some ( address) ,
784+ _ => { }
785+ }
786+ }
787+ None
788+ }
789+ _ => None ,
790+ }
791+ }
792+
762793fn read_base_type < W : funty:: Integral > (
763794 encoding : gimli:: DwAte ,
764795 data : & BitSlice < u8 , Lsb0 > ,
@@ -1098,6 +1129,9 @@ where
10981129 variable_name = Ok ( "param" . into ( ) ) ;
10991130 }
11001131
1132+ // Get the name of the variable
1133+ let variable_linkage_name = get_entry_linkage_name ( dwarf, unit, entry) ?;
1134+
11011135 // Get the type of the variable or its abstract origin
11021136 get_entry_type_reference_tree_recursive ! (
11031137 variable_type_tree = ( dwarf, unit, abbreviations, entry)
@@ -1138,7 +1172,7 @@ where
11381172 parameter : entry. tag ( ) == gimli:: constants:: DW_TAG_formal_parameter ,
11391173 } ;
11401174
1141- // Get the location of the variable
1175+ // Get the (file) location of the variable
11421176 let mut variable_file_location = find_entry_location ( dwarf, unit, entry) ?;
11431177 if let ( None , Some ( abstract_origin_entry) ) =
11441178 ( & variable_file_location. file , abstract_origin_entry)
@@ -1153,6 +1187,8 @@ where
11531187 kind : variable_kind,
11541188 type_value : variable_type_value_tree,
11551189 location : variable_file_location,
1190+ linkage_name : variable_linkage_name,
1191+ address : None , // We don't care about the address of a ZST
11561192 } ) )
11571193 }
11581194 ( Ok ( variable_name) , Ok ( mut variable_type_value_tree) ) => {
@@ -1174,7 +1210,7 @@ where
11741210 let variable_data = get_variable_data (
11751211 device_memory,
11761212 variable_type_value_tree. data ( ) . bit_length ( ) ,
1177- variable_location,
1213+ & variable_location,
11781214 ) ;
11791215
11801216 match variable_data {
@@ -1199,6 +1235,8 @@ where
11991235 kind : variable_kind,
12001236 type_value : variable_type_value_tree,
12011237 location : variable_file_location,
1238+ linkage_name : variable_linkage_name,
1239+ address : get_variable_address ( & variable_location) ,
12021240 } ) )
12031241 }
12041242 ( Ok ( variable_name) , Err ( type_error) ) => {
0 commit comments