From 0d22bd32b2a09fb75c4a2fc8840108bce2586fea Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Fri, 17 Jun 2022 07:10:12 -0700 Subject: [PATCH] Clean up whitespace --- elftools/common/construct_utils.py | 4 ++-- elftools/common/utils.py | 2 +- elftools/dwarf/dwarf_expr.py | 8 ++++---- elftools/dwarf/enums.py | 2 +- elftools/dwarf/locationlists.py | 14 +++++++------- elftools/elf/descriptions.py | 2 +- scripts/readelf.py | 14 +++++++------- test/run_readelf_tests.py | 8 ++++---- test/test_dwarf_expr.py | 4 ++-- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/elftools/common/construct_utils.py b/elftools/common/construct_utils.py index 64f1f9e..6ef7f46 100644 --- a/elftools/common/construct_utils.py +++ b/elftools/common/construct_utils.py @@ -92,7 +92,7 @@ def SLEB128(name): class StreamOffset(Construct): """ - Captures the current stream offset + Captures the current stream offset Parameters: * name - the name of the value @@ -109,4 +109,4 @@ class StreamOffset(Construct): def _build(self, obj, stream, context): context[self.name] = stream.tell() def _sizeof(self, context): - return 0 + return 0 diff --git a/elftools/common/utils.py b/elftools/common/utils.py index 0ea417c..eb51d95 100644 --- a/elftools/common/utils.py +++ b/elftools/common/utils.py @@ -119,7 +119,7 @@ def save_dwarf_section(section, filename): with open(filename, 'wb') as file: data = stream.read(section.size) file.write(data) - stream.seek(pos, os.SEEK_SET) + stream.seek(pos, os.SEEK_SET) #------------------------- PRIVATE ------------------------- diff --git a/elftools/dwarf/dwarf_expr.py b/elftools/dwarf/dwarf_expr.py index 1e4f658..714ef4e 100644 --- a/elftools/dwarf/dwarf_expr.py +++ b/elftools/dwarf/dwarf_expr.py @@ -247,12 +247,12 @@ def _init_dispatch_table(structs): add('DW_OP_entry_value', parse_nestedexpr()) add('DW_OP_const_type', parse_typedblob()) add('DW_OP_regval_type', parse_arg_struct2(structs.Dwarf_uleb128(''), - structs.Dwarf_uleb128(''))) + structs.Dwarf_uleb128(''))) add('DW_OP_deref_type', parse_arg_struct2(structs.Dwarf_uint8(''), - structs.Dwarf_uleb128(''))) + structs.Dwarf_uleb128(''))) add('DW_OP_implicit_pointer', parse_arg_struct2(structs.Dwarf_offset(''), - structs.Dwarf_sleb128(''))) - add('DW_OP_convert', parse_arg_struct(structs.Dwarf_uleb128(''))) + structs.Dwarf_sleb128(''))) + add('DW_OP_convert', parse_arg_struct(structs.Dwarf_uleb128(''))) add('DW_OP_GNU_entry_value', parse_nestedexpr()) add('DW_OP_GNU_const_type', parse_typedblob()) add('DW_OP_GNU_regval_type', parse_arg_struct2(structs.Dwarf_uleb128(''), diff --git a/elftools/dwarf/enums.py b/elftools/dwarf/enums.py index c0ae429..97630f7 100644 --- a/elftools/dwarf/enums.py +++ b/elftools/dwarf/enums.py @@ -427,7 +427,7 @@ ENUM_DW_LLE = dict( DW_LLE_default_location = 0x05, DW_LLE_base_address = 0x06, DW_LLE_start_end = 0x07, - DW_LLE_start_length = 0x08 + DW_LLE_start_length = 0x08 ) ENUM_DW_RLE = dict( diff --git a/elftools/dwarf/locationlists.py b/elftools/dwarf/locationlists.py index e674d67..c23cee9 100644 --- a/elftools/dwarf/locationlists.py +++ b/elftools/dwarf/locationlists.py @@ -23,7 +23,7 @@ class LocationLists(object): Starting with DWARF5, it may also contain LocationViewPair, but only if scanning the section, never when requested for a DIE attribute. - The default location entries are returned as LocationEntry with + The default location entries are returned as LocationEntry with begin_offset == end_offset == -1 Version determines whether the executable contains a debug_loc @@ -55,11 +55,11 @@ class LocationLists(object): """ # The location lists section was never meant for sequential access. # Location lists are referenced by DIE attributes by offset or by index. - + # As of DWARFv5, it may contain, in addition to proper location lists, #location list view pairs, which are referenced by the nonstandard DW_AT_GNU_locviews # attribute. A set of locview pairs (which is a couple of ULEB128 values) may preceed - # a location list; the former is referenced by the DW_AT_GNU_locviews attribute, the + # a location list; the former is referenced by the DW_AT_GNU_locviews attribute, the # latter - by DW_AT_location (in the same DIE). Binutils' readelf dumps those. # There is a view pair for each location-type entry in the list. # @@ -71,7 +71,7 @@ class LocationLists(object): stream.seek(0, os.SEEK_END) endpos = stream.tell() - stream.seek(0, os.SEEK_SET) + stream.seek(0, os.SEEK_SET) if self.version >= 5: # Need to provide support for DW_AT_GNU_locviews. They are interspersed in @@ -121,7 +121,7 @@ class LocationLists(object): cu_end_offset = offset_past_len + unit_length # Unit_length includes the header but doesn't include the length - + while stream.tell() < cu_end_offset: # Skip the gap to the next object next_offset = all_offsets[offset_index] @@ -198,7 +198,7 @@ class LocationLists(object): return LocationEntry(off, len, entry.start_address, entry.end_address, entry.loc_expr, True) elif type == 'DW_LLE_default_location': # No test for this either, and this is new in the API return LocationEntry(off, len, -1, -1, entry.loc_expr, True) - elif type in ('DW_LLE_base_addressx', 'DW_LLE_startx_endx', 'DW_LLE_startx_length'): + elif type in ('DW_LLE_base_addressx', 'DW_LLE_startx_endx', 'DW_LLE_startx_length'): # We don't have sample binaries for those LLEs. Their proper parsing would # require knowing the CU context (so that indices can be resolved to code offsets) raise NotImplementedError("Location list entry type %s is not supported yet" % (type,)) @@ -246,7 +246,7 @@ class LocationParser(object): return self.location_lists.get_location_list_at_offset( attr.value, die) # We don't yet know if the DIE context will be needed. - # We might get it without a full tree traversal using + # We might get it without a full tree traversal using # attr.offset as a key, but we assume a good DWARF5 # aware consumer would pass a DIE along. else: diff --git a/elftools/elf/descriptions.py b/elftools/elf/descriptions.py index 9314a62..4ac33c1 100644 --- a/elftools/elf/descriptions.py +++ b/elftools/elf/descriptions.py @@ -264,7 +264,7 @@ def describe_note_gnu_property_x86_isa_1(value): for mask, desc in _DESCR_NOTE_GNU_PROPERTY_X86_ISA_1_FLAGS: if value & mask: descs.append(desc) - return 'x86 ISA needed: ' + ', '.join(descs) + return 'x86 ISA needed: ' + ', '.join(descs) def describe_note_gnu_properties(properties): descriptions = [] diff --git a/scripts/readelf.py b/scripts/readelf.py index 7b2bb55..3895226 100755 --- a/scripts/readelf.py +++ b/scripts/readelf.py @@ -1146,7 +1146,7 @@ class ReadElf(object): self._emitline('%s:' % cu_filename) else: self._emitline('CU: %s:' % cu_filename) - + self._emitline('File name Line number Starting address Stmt') # GNU readelf has a View column that we don't try to replicate # The autotest has logic in place to ignore that @@ -1482,19 +1482,19 @@ class ReadElf(object): self._emitline(" %08x v%015x v%015x location view pair" % (entry.entry_offset, entry.begin, entry.end)) else: if in_views: - in_views = False + in_views = False self._emitline("") - + # Need the CU for this loclist, but the map is keyed by the offset # of the first entry in the loclist. Got to skip the views first. if cu is None: cu = cu_map.get(entry.entry_offset, False) if not cu: - raise ValueError("Location list can't be tracked to a CU") + raise ValueError("Location list can't be tracked to a CU") if isinstance(entry, LocationEntry): if base_ip is None and not entry.is_absolute: - base_ip = _get_cu_base(cu) + base_ip = _get_cu_base(cu) begin_offset = (0 if entry.is_absolute else base_ip) + entry.begin_offset end_offset = (0 if entry.is_absolute else base_ip) + entry.end_offset @@ -1558,7 +1558,7 @@ class ReadElf(object): self._emitline('Contents of the %s section:\n' % (di.debug_rnglists_sec or di.debug_ranges_sec).name) self._emitline(' Offset Begin End') - + for range_list in range_lists: # Weird discrepancy in binutils: for DWARFv5 it outputs entry offset, # for DWARF<=4 list offset. @@ -1580,7 +1580,7 @@ class ReadElf(object): else: raise NotImplementedError("Unknown object in a range list") last = range_list[-1] - self._emitline(' %08x ' % (last.entry_offset + last.entry_length if ver5 else first.entry_offset)) + self._emitline(' %08x ' % (last.entry_offset + last.entry_length if ver5 else first.entry_offset)) def _display_arch_specific_arm(self): """ Display the ARM architecture-specific info contained in the file. diff --git a/test/run_readelf_tests.py b/test/run_readelf_tests.py index 03fc5a9..4c3df98 100755 --- a/test/run_readelf_tests.py +++ b/test/run_readelf_tests.py @@ -149,7 +149,7 @@ def compare_output(s1, s2): # Position of the View column in the output file, if parsing readelf..decodedline # output, and the GNU readelf output contains the View column. Otherwise stays -1. - view_col_position = -1 + view_col_position = -1 for i in range(len(lines1)): if lines1[i].endswith('debug_line section:'): # .debug_line or .zdebug_line @@ -157,11 +157,11 @@ def compare_output(s1, s2): # readelf spelling error for GNU property notes lines1[i] = lines1[i].replace('procesor-specific type', 'processor-specific type') - + # The view column position may change from CU to CU: if view_col_position >= 0 and lines1[i].startswith('cu:'): - view_col_position = -1 - + view_col_position = -1 + # Check if readelf..decodedline output line contains the view column if flag_in_debug_line_section and lines1[i].startswith('file name') and view_col_position < 0: view_col_position = lines1[i].find("view") diff --git a/test/test_dwarf_expr.py b/test/test_dwarf_expr.py index 4e5dfc4..98d8bf5 100644 --- a/test/test_dwarf_expr.py +++ b/test/test_dwarf_expr.py @@ -93,8 +93,8 @@ class TestParseExpr(unittest.TestCase): # lit0 # skip 3 # lit4 - # minus - # deref + # minus + # deref lst = p.parse_expr([0x97,0x6,0x12,0x28,0x4,0x0,0x30,0x2F,0x3,0x0,0x34,0x1C,0x6]) self.assertEqual(len(lst), 9) self.assertEqual(lst, [ -- 2.30.2