MCPcopy Create free account
hub / github.com/qilingframework/qiling / field_description

Method field_description

qiling/hw/peripheral.py:182–229  ·  view source on GitHub ↗

Return field description in interval [offset: offset + size], the function is designed for logging and debugging. Returns: str: Field description

(self, offset: int, size: int)

Source from the content-addressed store, hash-verified

180 return field.offset <= offset and offset + size <= field.offset + field.size
181
182 def field_description(self, offset: int, size: int) -> str:
183 """ Return field description in interval [offset: offset + size],
184 the function is designed for logging and debugging.
185
186 Returns:
187 str: Field description
188 """
189
190 result = []
191
192 def parse_array(struct, left, right, prefix):
193 inner_struct = struct._type_
194 inner_struct_size = ctypes.sizeof(inner_struct)
195
196 for i in range(struct._length_):
197 offset = inner_struct_size * i
198
199 lower = max(0, left - offset)
200 upper = min(right - offset, inner_struct_size)
201
202 if lower < upper:
203 parse_struct(inner_struct, lower, upper, f'{prefix}[{i}]')
204
205 def parse_struct(struct, left, right, prefix=''):
206 if hasattr(struct, '_length_'):
207 parse_array(struct, left, right, prefix)
208
209 elif hasattr(struct, '_fields_'):
210 if prefix.endswith(']'):
211 prefix += '.'
212
213 for name, vtype in struct._fields_:
214 field = getattr(struct, name)
215
216 lower = max(0, left - field.offset)
217 upper = min(right - field.offset, field.size)
218
219 if lower < upper:
220 parse_struct(vtype, lower, upper, prefix + name)
221
222 else:
223 if left == 0 and right == ctypes.sizeof(struct):
224 result.append(prefix)
225 else:
226 result.append(f'{prefix}[{left}:{right}]')
227
228 parse_struct(self.struct, offset, offset + size)
229 return ','.join(result)
230
231 @property
232 def region(self) -> List[Tuple]:

Callers 2

readMethod · 0.80
writeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected