Skip to content

Commit aa74ea7

Browse files
author
Edras Pacola
committed
replace deprecated function
1 parent d095b81 commit aa74ea7

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

pyx2cscope/parser/elf16_parser.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, elf_path):
5858
os.path.dirname(os.path.abspath(__file__)), "xc16-readelf"
5959
)
6060

61-
logging.warn("Do not use this class for new development, it will be discontinued.")
61+
logging.warning("Do not use this class for new development, it will be discontinued.")
6262

6363
# Checking if the xc16-readelf executable exists in the same directory as the script or executable
6464
if os.path.exists(local_readelf):
@@ -377,13 +377,15 @@ def _check_for_pointer_tag(self, die, end_die, address):
377377
"""
378378
if end_die["tag"] != "DW_TAG_pointer_type":
379379
return False
380-
_variabledata = VariableInfo(
380+
variable_data = VariableInfo(
381381
name=die["DW_AT_name"],
382-
byte_size=end_die["DW_AT_byte_size"],
383382
type="pointer",
383+
byte_size=end_die["DW_AT_byte_size"],
384384
address=address,
385+
array_size=0,
386+
valid_values = {}
385387
)
386-
self.variable_map[die["DW_AT_name"]] = _variabledata
388+
self.variable_map[die["DW_AT_name"]] = variable_data
387389
return True
388390

389391
def _check_for_structure_tag(self, die, end_die, address):
@@ -404,9 +406,11 @@ def _check_for_structure_tag(self, die, end_die, address):
404406
# Return the entire structure as a single variable
405407
variable_data = VariableInfo(
406408
name=die["DW_AT_name"],
407-
byte_size=end_die["DW_AT_byte_size"],
408409
type=end_die["DW_AT_name"],
410+
byte_size=end_die["DW_AT_byte_size"],
409411
address=address,
412+
array_size=0,
413+
valid_values={}
410414
)
411415
self.variable_map[die["DW_AT_name"]] = variable_data
412416
if members:
@@ -418,6 +422,7 @@ def _check_for_structure_tag(self, die, end_die, address):
418422
type=member_info.get("type"),
419423
address=address + (member_info.get("address_offset")),
420424
array_size=member_info.get("array_size"),
425+
valid_values={}
421426
)
422427
self.variable_map[member_name] = variable_data
423428
# Reset array attributes for each variable
@@ -531,14 +536,15 @@ def _map_variables(self) -> dict[str, VariableInfo]:
531536
type=end_die["DW_AT_name"],
532537
address=address,
533538
array_size=self.calculate_array_size(die),
539+
valid_values={}
534540
)
535541
self.variable_map[die["DW_AT_name"]] = variable_data
536542
return self.variable_map
537543

538544

539545
if __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"
546+
elf_file = r"..\..\tests\data\MCAF_ZSMT_dsPIC33CK.elf"
547+
# elf_file = r"..\..\tests\data\mc_foc_sl_fip_dspic33ck_mclv48v300w.elf"
542548
# logging.basicConfig(level=logging.DEBUG) # Set the desired logging level and stream
543549
elf_reader = Elf16Parser(elf_file)
544550
variable_map = elf_reader.map_variables()

0 commit comments

Comments
 (0)