|
21 | 21 | "Syscalls" |
22 | 22 | ] |
23 | 23 |
|
| 24 | + |
24 | 25 | class SyscallEvent: |
25 | 26 | __slots__ = ('_sce', 'name') |
26 | 27 |
|
27 | 28 | def __init__(self, sce): |
28 | 29 | self._sce = sce |
29 | | - |
| 30 | + |
30 | 31 | # 1. Fast C-string extraction natively supported by dwarffi. |
31 | | - # Calling bytes() on the array field does a direct buffer slice |
| 32 | + # Calling bytes() on the array field does a direct buffer slice |
32 | 33 | # (equivalent to your old start:start+size math) without the boilerplate. |
33 | 34 | raw_bytes = bytes(sce.syscall_name) |
34 | | - |
| 35 | + |
35 | 36 | # 2. Parse the C-string |
36 | 37 | self.name = raw_bytes.split(b'\x00', 1)[0].decode('utf-8', errors='replace') |
37 | 38 |
|
38 | 39 | def __getattr__(self, attr): |
39 | | - # 3. Transparently pass through any standard field accesses |
| 40 | + # 3. Transparently pass through any standard field accesses |
40 | 41 | # (e.g., event.orig_x0) to the underlying dwarffi instance. |
41 | 42 | return getattr(self._sce, attr) |
42 | | - |
| 43 | + |
43 | 44 | def __setattr__(self, attr, value): |
44 | 45 | # If the attribute belongs to the wrapper, set it locally |
45 | 46 | if attr in self.__slots__: |
46 | 47 | object.__setattr__(self, attr, value) |
47 | 48 | else: |
48 | 49 | # Otherwise, forward the write to the underlying dwarffi instance |
49 | 50 | setattr(self._sce, attr, value) |
50 | | - |
| 51 | + |
51 | 52 | @property |
52 | 53 | def size(self) -> int: |
53 | 54 | # Expose the size from the underlying dwarffi BoundTypeInstance |
@@ -531,17 +532,6 @@ def _syscall_interrupt_handler(self) -> bool: |
531 | 532 | if func_name: |
532 | 533 | self._name_to_hook_ptrs[func_name].append(hook_ptr) |
533 | 534 |
|
534 | | - ''' |
535 | | - On repeated calls to the same syscall in portal we produce new |
536 | | - syscall_event objects. However, it doesn't update the version of the object |
537 | | - that the function has. This means that when it sets values we have a |
538 | | - different object and can fail. |
539 | | -
|
540 | | - So we keep the original syscall_event object in a dictionary and check if the |
541 | | - sequence number is the same. If it is we use the original object. |
542 | | - ''' |
543 | | - |
544 | | - |
545 | 535 | def _get_proto(self, cpu: int, sce: Any, on_all: bool) -> SyscallPrototype: |
546 | 536 | """ |
547 | 537 | Get the syscall prototype for a given event. |
|
0 commit comments