|
31 | 31 |
|
32 | 32 | class module(generic.GenericIntelProcess): |
33 | 33 |
|
34 | | - def __init__(self, *args, **kwargs): |
35 | | - super().__init__(*args, **kwargs) |
36 | | - self._mod_mem_type = None # Initialize _mod_mem_type to None for memoization |
37 | | - |
38 | | - @property |
39 | | - def mod_mem_type(self): |
| 34 | + @functools.cached_property |
| 35 | + def mod_mem_type(self) -> Dict: |
40 | 36 | """Return the mod_mem_type enum choices if available or an empty dict if not""" |
41 | 37 | # mod_mem_type and module_memory were added in kernel 6.4 which replaces |
42 | 38 | # module_layout for storing the information around core_layout etc. |
43 | 39 | # see commit ac3b43283923440900b4f36ca5f9f0b1ca43b70e for more information |
| 40 | + symbol_table_name = self.get_symbol_table_name() |
| 41 | + mod_mem_type_symname = symbol_table_name + constants.BANG + "mod_mem_type" |
| 42 | + symbol_space = self._context.symbol_space |
| 43 | + try: |
| 44 | + mod_mem_type = symbol_space.get_enumeration(mod_mem_type_symname).choices |
| 45 | + except exceptions.SymbolError: |
| 46 | + mod_mem_type = {} |
| 47 | + vollog.debug( |
| 48 | + "Unable to find mod_mem_type enum. This message can be ignored for kernels < 6.4" |
| 49 | + ) |
44 | 50 |
|
45 | | - if self._mod_mem_type is None: |
46 | | - try: |
47 | | - self._mod_mem_type = self._context.symbol_space.get_enumeration( |
48 | | - self.get_symbol_table_name() + constants.BANG + "mod_mem_type" |
49 | | - ).choices |
50 | | - except exceptions.SymbolError: |
51 | | - vollog.debug( |
52 | | - "Unable to find mod_mem_type enum. This message can be ignored for kernels < 6.4" |
53 | | - ) |
54 | | - # set to empty dict to show that the enum was not found, and so shouldn't be searched for again |
55 | | - self._mod_mem_type = {} |
56 | | - return self._mod_mem_type |
| 51 | + return mod_mem_type |
57 | 52 |
|
58 | 53 | def get_module_base(self): |
59 | 54 | if self.has_member("mem"): # kernels 6.4+ |
|
0 commit comments