See also the documentation of public methods.
"""
- __StructsCache = {}
+ # Cache for structs instances based on creation parameters. Structs
+ # initialization is expensive and we don't won't to repeat it
+ # unnecessarily.
+ _structs_cache = {}
def __new__(cls, little_endian, dwarf_format, address_size, dwarf_version=2):
""" dwarf_version:
"""
key = (little_endian, dwarf_format, address_size, dwarf_version)
- if key in cls.__StructsCache:
- return cls.__StructsCache[key]
+ if key in cls._structs_cache:
+ return cls._structs_cache[key]
self = super().__new__(cls)
assert dwarf_format == 32 or dwarf_format == 64
self.address_size = address_size
self.dwarf_version = dwarf_version
self._create_structs()
- cls.__StructsCache[key] = self
+ cls._structs_cache[key] = self
return self
def initial_length_field_size(self):
# New forms in DWARFv5
DW_FORM_loclistx=self.Dwarf_uleb128(''),
- DW_FORM_rnglistx=self.Dwarf_uleb128('')
+ DW_FORM_rnglistx=self.Dwarf_uleb128('')
)
def _create_aranges_header(self):
"""
if self._section_header_stringtable is None:
raise ELFParseError("String Table not found")
-
+
name_offset = section_header['sh_name']
return self._section_header_stringtable.get_string(name_offset)