MCPcopy
hub / github.com/AsahiLinux/m1n1 / print_context

Method print_context

proxyclient/m1n1/proxyutils.py:306–361  ·  view source on GitHub ↗
(self, ctx, is_fault=True, addr=lambda a: f"0x{a:x}", sym=None, num_ctx=9)

Source from the content-addressed store, hash-verified

304 self.msr(DAIF, self.mrs(DAIF) | 0x100) # Re-enable SError exceptions
305
306 def print_context(self, ctx, is_fault=True, addr=lambda a: f"0x{a:x}", sym=None, num_ctx=9):
307 print(f" == Exception taken from {ctx.spsr.M.name} ==")
308 el = ctx.spsr.M >> 2
309 print(f" SPSR = {ctx.spsr}")
310 print(f" ELR = {addr(ctx.elr)}" + (f" (0x{ctx.elr_phys:x})" if ctx.elr_phys else ""))
311 print(f" SP_EL{el} = 0x{ctx.sp[el]:x}" + (f" (0x{ctx.sp_phys:x})" if ctx.sp_phys else ""))
312 if is_fault:
313 print(f" ESR = {ctx.esr}")
314 print(f" FAR = {addr(ctx.far)}" + (f" (0x{ctx.far_phys:x})" if ctx.far_phys else ""))
315
316 for i in range(0, 31, 4):
317 j = min(30, i + 3)
318 print(f" {f'x{i}-x{j}':>7} = {' '.join(f'{r:016x}' for r in ctx.regs[i:j + 1])}")
319
320 if ctx.elr_phys:
321 print()
322 print(" == Code context ==")
323
324 off = -(num_ctx // 2)
325
326 self.disassemble_at(ctx.elr_phys + 4 * off, num_ctx * 4, ctx.elr, ctx.elr + 4 * off, sym=sym)
327
328 if is_fault:
329 if ctx.esr.EC == ESR_EC.MSR or ctx.esr.EC == ESR_EC.IMPDEF and ctx.esr.ISS == 0x20:
330 print()
331 print(" == MRS/MSR fault decoding ==")
332 if ctx.esr.EC == ESR_EC.MSR:
333 iss = ESR_ISS_MSR(ctx.esr.ISS)
334 else:
335 iss = ESR_ISS_MSR(self.mrs(AFSR1_EL2))
336 enc = iss.Op0, iss.Op1, iss.CRn, iss.CRm, iss.Op2
337 if enc in sysreg_rev:
338 name = sysreg_rev[enc]
339 else:
340 name = f"s{iss.Op0}_{iss.Op1}_c{iss.CRn}_c{iss.CRm}_{iss.Op2}"
341 if iss.DIR == MSR_DIR.READ:
342 print(f" Instruction: mrs x{iss.Rt}, {name}")
343 else:
344 print(f" Instruction: msr {name}, x{iss.Rt}")
345
346 if ctx.esr.EC in (ESR_EC.DABORT, ESR_EC.DABORT_LOWER):
347 print()
348 print(" == Data abort decoding ==")
349 iss = ESR_ISS_DABORT(ctx.esr.ISS)
350 if iss.ISV:
351 print(f" ISS: {iss!s}")
352 else:
353 print(" No instruction syndrome available")
354
355 if iss.DFSC == DABORT_DFSC.ECC_ERROR:
356 self.print_l2c_regs()
357
358 if ctx.esr.EC == ESR_EC.SERROR and ctx.esr.ISS == 0:
359 self.print_l2c_regs()
360
361 print()
362
363 @contextmanager

Callers 2

handle_exceptionMethod · 0.80
contextMethod · 0.80

Calls 5

disassemble_atMethod · 0.95
mrsMethod · 0.95
print_l2c_regsMethod · 0.95
ESR_ISS_MSRClass · 0.85
ESR_ISS_DABORTClass · 0.85

Tested by

no test coverage detected