| 41 | |
| 42 | @dataclasses.dataclass(frozen=True, eq=True) |
| 43 | class VirtualMap: |
| 44 | start: int |
| 45 | end: int |
| 46 | filesize: int |
| 47 | offset: int |
| 48 | device: str |
| 49 | flags: str |
| 50 | inode: int |
| 51 | path: Optional[Path] |
| 52 | |
| 53 | def contains(self, addr: int) -> bool: |
| 54 | return self.start <= addr < self.end |
| 55 | |
| 56 | def is_executable(self) -> bool: |
| 57 | return "x" in self.flags |
| 58 | |
| 59 | def is_readable(self) -> bool: |
| 60 | return "r" in self.flags |
| 61 | |
| 62 | def is_writable(self) -> bool: |
| 63 | return "w" in self.flags |
| 64 | |
| 65 | def is_private(self) -> bool: |
| 66 | return "p" in self.flags |
| 67 | |
| 68 | @property |
| 69 | def size(self) -> int: |
| 70 | return self.end - self.start |
| 71 | |
| 72 | def __repr__(self) -> str: |
| 73 | start = f"0x{self.start:016x}" |
| 74 | end = f"0x{self.end:016x}" |
| 75 | filesize = f"0x{self.filesize:x}" |
| 76 | offset = f"0x{self.offset:x}" |
| 77 | return ( |
| 78 | f"VirtualMap(start={start!s}, end={end!s}," |
| 79 | f" filesize={filesize!s}, offset={offset!s}," |
| 80 | f" device={self.device!r}, flags={self.flags!r}, inode={self.inode!r}," |
| 81 | f" path={str(self.path)!r})" |
| 82 | ) |
| 83 | |
| 84 | |
| 85 | @dataclasses.dataclass |
no outgoing calls