forked from andikleen/simple-pt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spttrace
executable file
·56 lines (52 loc) · 1.51 KB
/
spttrace
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python
# add symbol msr names to msr trace (generated by sptcmd -t)
# spttrace < ptout.trace
import re
import sys
msrmap = {
560: "RTIT_OUTPUT_BASE",
561: "RTIT_OUTPUT_MASK_PTRS",
570: "RTIT_CTL",
571: "RTIT_STATUS",
572: "CR3_MATCH",
580: "ADDR0_START",
581: "ADDR0_END",
582: "ADDR1_START",
583: "ADDR1_END",
}
msrbits = {
570: { 0: "TraceEN", 1: "CYCEn", 2: "OS", 3: "User", 6: "FabricEn",
7: "CR3Filter", 8: "ToPA", 9: "MTCEn", 10: "TSCEn",
11: "DisRetC", 13: "BranchEn" },
571: { 0: "FilterEn", 1: "ContextEn", 2: "TriggerEn", 4: "Error",
5: "Stopped", },
}
msrfields = {
570: ((14, 17, "MTCFreq"), (19,22, "CYCThresh"), (24, 27, "PSBFreq"),
(32, 35, "Addr0"), (36, 39, "Addr1"), (40, 43, "Addr2"),
(44, 47, "Addr3")),
571: ((32, 48, "PacketByteCnt"), )
}
for l in sys.stdin:
m = re.search(r"msr=(\d+) .. ([a-f0-9]+)", l)
if m:
mnum = int(m.group(1))
mval = int(m.group(2), 16)
if mnum in msrmap:
print l.replace("msr=" + m.group(1) + " ", "msr=%s " % msrmap[mnum]).rstrip(),
if mnum in msrbits:
for j in msrbits[mnum].keys():
if mval & (1 << j):
print msrbits[mnum][j],
mval = mval & ~(1<<j)
if mnum in msrfields:
for j in msrfields[mnum]:
mask = ((1 << (j[1] - j[0]))-1) << j[0]
if mval & mask:
print (mval & mask) >> j[0],
mval = mval & ~mask
if mval and (mnum in msrfields or mnum in msrbits):
print "not decoded: %x" % mval,
print
else:
print l,