This reverts commit ab9895b78e.
From Greg's reversion:
"Looks like some of the Android build systems do NOT have /usr/bin/env so
revert this change until that happens.
Specifically the following builds fail without this change reverted:
kernel_kasan_aarch64 on aosp_kernel-common-android-mainline
kernel_virt_kasan_aarch64 on aosp_kernel-common-android-mainline
kernel_virt_kasan_x86_64 on aosp_kernel-common-android-mainline
kernel_kasan_x86_64 on aosp_kernel-common-android-mainline"
'env' should not fail. Let's have another go at applying this.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Change-Id: I8f56ed40e8bb24474d6c454ff6d1982c86d9adc3
38 lines
843 B
Python
38 lines
843 B
Python
#!/usr/bin/env python
|
|
# add symbolic names to read_msr / write_msr in trace
|
|
# decode_msr msr-index.h < trace
|
|
import sys
|
|
import re
|
|
|
|
msrs = dict()
|
|
|
|
with open(sys.argv[1] if len(sys.argv) > 1 else "msr-index.h", "r") as f:
|
|
for j in f:
|
|
m = re.match(r'#define (MSR_\w+)\s+(0x[0-9a-fA-F]+)', j)
|
|
if m:
|
|
msrs[int(m.group(2), 16)] = m.group(1)
|
|
|
|
extra_ranges = (
|
|
( "MSR_LASTBRANCH_%d_FROM_IP", 0x680, 0x69F ),
|
|
( "MSR_LASTBRANCH_%d_TO_IP", 0x6C0, 0x6DF ),
|
|
( "LBR_INFO_%d", 0xdc0, 0xddf ),
|
|
)
|
|
|
|
for j in sys.stdin:
|
|
m = re.search(r'(read|write)_msr:\s+([0-9a-f]+)', j)
|
|
if m:
|
|
r = None
|
|
num = int(m.group(2), 16)
|
|
if num in msrs:
|
|
r = msrs[num]
|
|
else:
|
|
for er in extra_ranges:
|
|
if er[1] <= num <= er[2]:
|
|
r = er[0] % (num - er[1],)
|
|
break
|
|
if r:
|
|
j = j.replace(" " + m.group(2), " " + r + "(" + m.group(2) + ")")
|
|
print j,
|
|
|
|
|