DebugFrame represents a frame in the stack trace. It has the following fields: * ``index``: the index of the frame * ``pc``: the program counter of the frame * ``sp``: the stack pointer of the frame * ``fp``: the frame pointer of the frame * ``func_name``: the function name
| 305 | |
| 306 | |
| 307 | class DebugFrame: |
| 308 | """ |
| 309 | DebugFrame represents a frame in the stack trace. It has the following fields: |
| 310 | |
| 311 | * ``index``: the index of the frame |
| 312 | * ``pc``: the program counter of the frame |
| 313 | * ``sp``: the stack pointer of the frame |
| 314 | * ``fp``: the frame pointer of the frame |
| 315 | * ``func_name``: the function name which the pc is in |
| 316 | * ``func_start``: the start of the function |
| 317 | * ``module``: the module of the pc |
| 318 | |
| 319 | """ |
| 320 | def __init__(self, index, pc, sp, fp, func_name, func_start, module): |
| 321 | self.index = index |
| 322 | self.pc = pc |
| 323 | self.sp = sp |
| 324 | self.fp = fp |
| 325 | self.func_name = func_name |
| 326 | self.func_start = func_start |
| 327 | self.module = module |
| 328 | |
| 329 | def __eq__(self, other): |
| 330 | if not isinstance(other, self.__class__): |
| 331 | return NotImplemented |
| 332 | return self.index == other.index and self.pc == other.pc and self.sp == other.sp \ |
| 333 | and self.fp == other.fp and self.func_name == other.func_name and self.func_start == other.func_start \ |
| 334 | and self.module == other.module |
| 335 | |
| 336 | def __ne__(self, other): |
| 337 | if not isinstance(other, self.__class__): |
| 338 | return NotImplemented |
| 339 | return not (self == other) |
| 340 | |
| 341 | def __hash__(self): |
| 342 | return hash((self.index, self.pc, self.sp, self.fp, self.func_name, self.func_start, self.module)) |
| 343 | |
| 344 | def __setattr__(self, name, value): |
| 345 | try: |
| 346 | object.__setattr__(self, name, value) |
| 347 | except AttributeError: |
| 348 | raise AttributeError(f"attribute '{name}' is read only") |
| 349 | |
| 350 | def __repr__(self): |
| 351 | offset = self.pc - self.func_start |
| 352 | return f"<DebugFrame: {self.module}`{self.func_name} + {offset:#x}, sp: {self.sp:#x}, fp: {self.fp:#x}>" |
| 353 | |
| 354 | |
| 355 | class TargetStoppedEventData: |