DebugRegister represents a register in the target. It has the following fields: * ``name``: the name of the register * ``value``: the value of the register * ``width``: the width of the register, in bits. E.g., ``rax`` register is 64-bits wide * ``index``: the index of the regi
| 144 | |
| 145 | |
| 146 | class DebugRegister: |
| 147 | """ |
| 148 | DebugRegister represents a register in the target. It has the following fields: |
| 149 | |
| 150 | * ``name``: the name of the register |
| 151 | * ``value``: the value of the register |
| 152 | * ``width``: the width of the register, in bits. E.g., ``rax`` register is 64-bits wide |
| 153 | * ``index``: the index of the register. This is reported by the DebugAdapter and should remain unchanged |
| 154 | * ``hint``: a string that shows the content of the memory pointed to by the register. It is empty if the register\ |
| 155 | value do not point to a valid (mapped) memory region |
| 156 | |
| 157 | """ |
| 158 | def __init__(self, name, value, width, index, hint): |
| 159 | self.name = name |
| 160 | self.value = value |
| 161 | self.width = width |
| 162 | self.index = index |
| 163 | self.hint = hint |
| 164 | |
| 165 | def __eq__(self, other): |
| 166 | if not isinstance(other, self.__class__): |
| 167 | return NotImplemented |
| 168 | return self.name == other.name and self.value == other.value and self.width == other.width \ |
| 169 | and self.index == other.index and self.hint == other.hint |
| 170 | |
| 171 | def __ne__(self, other): |
| 172 | if not isinstance(other, self.__class__): |
| 173 | return NotImplemented |
| 174 | return not (self == other) |
| 175 | |
| 176 | def __hash__(self): |
| 177 | return hash((self.name, self.value, self.width. self.index, self.hint)) |
| 178 | |
| 179 | def __setattr__(self, name, value): |
| 180 | try: |
| 181 | object.__setattr__(self, name, value) |
| 182 | except AttributeError: |
| 183 | raise AttributeError(f"attribute '{name}' is read only") |
| 184 | |
| 185 | def __repr__(self): |
| 186 | hint_str = f", {self.hint}" if self.hint != '' else '' |
| 187 | return f"<DebugRegister: {self.name}, {self.value:#x}{hint_str}>" |
| 188 | |
| 189 | |
| 190 | class DebugRegisters: |