Skip to content

Commit 1ebeb75

Browse files
authored
Last typing issues (#610)
* Mark files as (not) executable Mark data- and text files as not executable. Mark scripts as executable. Mark main tests runners as executable. - https://docs.astral.sh/ruff/rules/#flake8-executable-exe Signed-off-by: Philipp Hahn <[email protected]> * Convert DW_OP_opcode2name into a dict-comprehension Signed-off-by: Philipp Hahn <[email protected]> * callframe: Simplify default value Signed-off-by: Philipp Hahn <[email protected]> * elf.descriptions: Simplify range check Signed-off-by: Philipp Hahn <[email protected]> * DWARFInfo: Remove inner self `resolve_strings()` is an internal helper function and does not need `self`. Signed-off-by: Philipp Hahn <[email protected]> * Fix DWARFInfo._parse_line_program_at_offset bytes `replace_value()` works on `bytes`, as such encode the string using the default `utf-8` encoding. Signed-off-by: Philipp Hahn <[email protected]> * Turn TypeDesc.dimensions into a tuple `(… for … in …)` is a generator expression, which only can be walked once compared to a `tuple`. Signed-off-by: Philipp Hahn <[email protected]> * Fix return type of _parse_cie_augmentation() `elftools.dwarf.callframe.CallFrameInfo._parse_cie_augmentation()` returns a `tuple[bytes, …]`. Signed-off-by: Philipp Hahn <[email protected]> --------- Signed-off-by: Philipp Hahn <[email protected]>
1 parent bc8fca4 commit 1ebeb75

22 files changed

+9
-9
lines changed

TODO

100755100644
File mode changed.

elftools/dwarf/callframe.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _parse_cie_augmentation(self, header, entry_structs):
269269
"""
270270
augmentation = header.get('augmentation')
271271
if not augmentation:
272-
return ('', {})
272+
return (b'', {})
273273

274274
# Ignore armcc augmentations.
275275
if augmentation.startswith(b'armcc'):
@@ -489,7 +489,7 @@ def __init__(self, header, structs, instructions, offset,
489489
self.offset = offset
490490
self.cie = cie
491491
self._decoded_table = None
492-
self.augmentation_dict = augmentation_dict if augmentation_dict else {}
492+
self.augmentation_dict = augmentation_dict or {}
493493
self.augmentation_bytes = augmentation_bytes
494494

495495
def get_decoded(self):

elftools/dwarf/datatype_cpp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def parse_cpp_datatype(var_die):
8484
dt.tag = "ptr_to_member_type" # Not a function pointer per se
8585
return dt
8686
elif t.tag == 'array':
87-
t.dimensions = (_array_subtype_size(sub)
87+
t.dimensions = tuple(_array_subtype_size(sub)
8888
for sub
8989
in type_die.iter_children()
9090
if sub.tag == 'DW_TAG_subrange_type')

elftools/dwarf/die.py

100755100644
File mode changed.

elftools/dwarf/dwarf_expr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def _generate_dynamic_values(map, prefix, index_start, index_end, value_start):
112112
_generate_dynamic_values(DW_OP_name2opcode, 'DW_OP_breg', 0, 31, 0x70)
113113

114114
# opcode -> name mapping
115-
DW_OP_opcode2name = dict((v, k) for k, v in DW_OP_name2opcode.items())
115+
DW_OP_opcode2name = {v: k for k, v in DW_OP_name2opcode.items()}
116116

117117

118118
# Each parsed DWARF expression is returned as this type with its numeric opcode,

elftools/dwarf/dwarfinfo.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ def _parse_line_program_at_offset(self, offset, structs):
662662
offset)
663663

664664
# DWARF5: resolve names
665-
def resolve_strings(self, lineprog_header, format_field, data_field):
665+
def resolve_strings(lineprog_header, format_field, data_field) -> None:
666666
if lineprog_header.get(format_field, False):
667667
data = lineprog_header[data_field]
668668
for field in lineprog_header[format_field]:
@@ -678,12 +678,12 @@ def replace_value(data, content_type, replacer):
678678
if self.supplementary_dwarfinfo:
679679
replace_value(data, field.content_type, self.supplementary_dwarfinfo.get_string_from_table)
680680
else:
681-
replace_value(data, field.content_type, lambda x: str(x))
681+
replace_value(data, field.content_type, lambda x: str(x).encode())
682682
elif field.form in ('DW_FORM_strp_sup', 'DW_FORM_strx', 'DW_FORM_strx1', 'DW_FORM_strx2', 'DW_FORM_strx3', 'DW_FORM_strx4'):
683683
raise NotImplementedError()
684684

685-
resolve_strings(self, lineprog_header, 'directory_entry_format', 'directories')
686-
resolve_strings(self, lineprog_header, 'file_name_entry_format', 'file_names')
685+
resolve_strings(lineprog_header, 'directory_entry_format', 'directories')
686+
resolve_strings(lineprog_header, 'file_name_entry_format', 'file_names')
687687

688688
# DWARF5: provide compatible file/directory name arrays for legacy lineprogram consumers
689689
if lineprog_header.get('directories', False):

elftools/dwarf/namelut.py

100755100644
File mode changed.

elftools/elf/descriptions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def describe_symbol_local(x):
130130

131131
def describe_symbol_other(x):
132132
vis = describe_symbol_visibility(x['visibility'])
133-
if x['local'] > 1 and x['local'] < 7:
133+
if 1 < x['local'] < 7:
134134
return vis + ' ' + describe_symbol_local(x['local'])
135135
return vis
136136

test/run_dwarfdump_tests.py

100644100755
File mode changed.

test/run_parser_perf_test.py

100644100755
File mode changed.

test/testfiles_for_location_info/test-dwarf2.o

100755100644
File mode changed.

test/testfiles_for_location_info/test-dwarf4.o

100755100644
File mode changed.

test/testfiles_for_readelf/cuv5_x86-64_gcc.so.elf

100755100644
File mode changed.

test/testfiles_for_readelf/empty-cie.o.elf

100755100644
File mode changed.

test/testfiles_for_readelf/note_gnu_property.elf

100755100644
File mode changed.

test/testfiles_for_readelf/reloc_armsf_gcc.o.elf

100755100644
File mode changed.

test/testfiles_for_readelf/simple_armeb_gcc.o.elf

100755100644
File mode changed.

test/testfiles_for_readelf/tls.elf

100755100644
File mode changed.

test/testfiles_for_readelf/tls64.elf

100755100644
File mode changed.

test/testfiles_for_unittests/debuglink

100755100644
File mode changed.

test/testfiles_for_unittests/debuglink.debug

100755100644
File mode changed.

test/testfiles_for_unittests/simple_clang.elf.riscv

100755100644
File mode changed.

0 commit comments

Comments
 (0)