@@ -35,13 +35,6 @@ class Elf16Parser(ElfParser):
3535 xc16_read_elf_path (str): Path to the XC16 `readelf` executable.
3636 """
3737
38- def _load_symbol_table (self ):
39- """Load symbol tables.
40-
41- This method exists at this class only for compatibility.
42- This class is deprecated and not maintained on current version.
43- """
44- pass
4538
4639 def __init__ (self , elf_path ):
4740 """Initialize the Elf16Parser instance.
@@ -58,7 +51,7 @@ def __init__(self, elf_path):
5851 os .path .dirname (os .path .abspath (__file__ )), "xc16-readelf"
5952 )
6053
61- logging .warn ("Do not use this class for new development, it will be discontinued." )
54+ logging .warning ("Do not use this class for new development, it will be discontinued." )
6255
6356 # Checking if the xc16-readelf executable exists in the same directory as the script or executable
6457 if os .path .exists (local_readelf ):
@@ -77,6 +70,17 @@ def __init__(self, elf_path):
7770 self .tree_string = None
7871 self .next_line = None
7972
73+ def _load_symbol_table (self ):
74+ """Load symbol tables.
75+
76+ This method exists at this class only for compatibility.
77+ This class is deprecated and not maintained on current version.
78+ """
79+ pass
80+
81+ def _close_elf_file (self ):
82+ pass
83+
8084 def _parse_cu_attributes (self ):
8185 """Parse the attributes of a compilation unit from the ELF file.
8286
@@ -377,13 +381,15 @@ def _check_for_pointer_tag(self, die, end_die, address):
377381 """
378382 if end_die ["tag" ] != "DW_TAG_pointer_type" :
379383 return False
380- _variabledata = VariableInfo (
384+ variable_data = VariableInfo (
381385 name = die ["DW_AT_name" ],
382- byte_size = end_die ["DW_AT_byte_size" ],
383386 type = "pointer" ,
387+ byte_size = end_die ["DW_AT_byte_size" ],
384388 address = address ,
389+ array_size = 0 ,
390+ valid_values = {}
385391 )
386- self .variable_map [die ["DW_AT_name" ]] = _variabledata
392+ self .variable_map [die ["DW_AT_name" ]] = variable_data
387393 return True
388394
389395 def _check_for_structure_tag (self , die , end_die , address ):
@@ -404,9 +410,11 @@ def _check_for_structure_tag(self, die, end_die, address):
404410 # Return the entire structure as a single variable
405411 variable_data = VariableInfo (
406412 name = die ["DW_AT_name" ],
407- byte_size = end_die ["DW_AT_byte_size" ],
408413 type = end_die ["DW_AT_name" ],
414+ byte_size = end_die ["DW_AT_byte_size" ],
409415 address = address ,
416+ array_size = 0 ,
417+ valid_values = {}
410418 )
411419 self .variable_map [die ["DW_AT_name" ]] = variable_data
412420 if members :
@@ -418,6 +426,7 @@ def _check_for_structure_tag(self, die, end_die, address):
418426 type = member_info .get ("type" ),
419427 address = address + (member_info .get ("address_offset" )),
420428 array_size = member_info .get ("array_size" ),
429+ valid_values = {}
421430 )
422431 self .variable_map [member_name ] = variable_data
423432 # Reset array attributes for each variable
@@ -531,14 +540,15 @@ def _map_variables(self) -> dict[str, VariableInfo]:
531540 type = end_die ["DW_AT_name" ],
532541 address = address ,
533542 array_size = self .calculate_array_size (die ),
543+ valid_values = {}
534544 )
535545 self .variable_map [die ["DW_AT_name" ]] = variable_data
536546 return self .variable_map
537547
538548
539549if __name__ == "__main__" :
540- # elf_file = r"C:\_DESKTOP\_Projects\Motorbench_Projects\ZSMT-42BLF02-MCLV2-33ck256mp508.X\dist\default\production\ZSMT-42BLF02-MCLV2-33ck256mp508.X.production .elf"
541- elf_file = r"C:\_DESKTOP\_Projects\Motorbench_Projects\motorbench_FOC_PLL_PIC33CK256mp508_MCLV2\ZSMT_dsPIC33CK_MCLV_48_300.X\dist\default\production\ZSMT_dsPIC33CK_MCLV_48_300.X.production .elf"
550+ elf_file = r"..\..\tests\data\MCAF_ZSMT_dsPIC33CK .elf"
551+ # elf_file = r"..\..\tests\data\mc_foc_sl_fip_dspic33ck_mclv48v300w .elf"
542552 # logging.basicConfig(level=logging.DEBUG) # Set the desired logging level and stream
543553 elf_reader = Elf16Parser (elf_file )
544554 variable_map = elf_reader .map_variables ()
0 commit comments