summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/wall2/t112c-gdbstub.py
blob: 27d0b9d4efde09ba2ec847b022c53a0de50f477b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import gdb

gr = gdb.execute

def u32(a):
    return int(gdb.parse_and_eval("*(unsigned int*)0x%x" % a))
def u64(a):
    return int(gdb.parse_and_eval("*(unsigned long*)0x%x" % a))

state = {"hits": {}}

class HB(gdb.Breakpoint):
    def __init__(self, pa, tag, quiet_after=8):
        super().__init__("*0x%x" % pa, type=gdb.BP_BREAKPOINT, internal=False)
        self.tag = tag
        self.quiet_after = quiet_after
        self.silent = True
    def stop(self):
        n = state["hits"].get(self.tag, 0) + 1
        state["hits"][self.tag] = n
        try:
            rdi = int(gdb.parse_and_eval("$rdi"))
            rsi = int(gdb.parse_and_eval("$rsi"))
            rdx = int(gdb.parse_and_eval("$rdx"))
            rcx = int(gdb.parse_and_eval("$rcx"))
            r8 = int(gdb.parse_and_eval("$r8"))
            r9 = int(gdb.parse_and_eval("$r9"))
            if n <= self.quiet_after or self.tag in ("PRED", "COMPR"):
                print("HIT %s #%d rdi=0x%x rsi=0x%x rdx=0x%x rcx=0x%x r8=0x%x r9=0x%x" %
                      (self.tag, n, rdi, rsi, rdx, rcx, r8, r9), flush=True)
        except Exception as e:
            print("err", e, flush=True)
        return False

HB(0xffffffffc0c403b0, "VIDH")
HB(0xffffffffc0d667a0, "PMA", 4)
HB(0xffffffffc0d6ae30, "PRED")
HB(0xffffffffc0d57d60, "COMPR", 16)
HB(0xffffffffc0d607f0, "SCRUB", 4)
print("HB-SET", flush=True)
gr("continue")
print("T112B-DONE %s" % state["hits"], flush=True)