perf scripts python: intel-pt-events.py: Add Event Trace
Add Event Trace to the intel-pt-events.py script. This shows how to unpack the raw data from the new sample events in a Python script. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: https://lore.kernel.org/r/20220124084201.2699795-22-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
2673859865
commit
95f9bfcf84
@@ -76,16 +76,16 @@ def trace_begin():
|
|||||||
glb_args = ap.parse_args()
|
glb_args = ap.parse_args()
|
||||||
if glb_args.insn_trace:
|
if glb_args.insn_trace:
|
||||||
print("Intel PT Instruction Trace")
|
print("Intel PT Instruction Trace")
|
||||||
itrace = "i0nsepwx"
|
itrace = "i0nsepwxI"
|
||||||
glb_insn = True
|
glb_insn = True
|
||||||
elif glb_args.src_trace:
|
elif glb_args.src_trace:
|
||||||
print("Intel PT Source Trace")
|
print("Intel PT Source Trace")
|
||||||
itrace = "i0nsepwx"
|
itrace = "i0nsepwxI"
|
||||||
glb_insn = True
|
glb_insn = True
|
||||||
glb_src = True
|
glb_src = True
|
||||||
else:
|
else:
|
||||||
print("Intel PT Branch Trace, Power Events and PTWRITE")
|
print("Intel PT Branch Trace, Power Events, Event Trace and PTWRITE")
|
||||||
itrace = "bepwx"
|
itrace = "bepwxI"
|
||||||
global glb_disassembler
|
global glb_disassembler
|
||||||
try:
|
try:
|
||||||
glb_disassembler = LibXED()
|
glb_disassembler = LibXED()
|
||||||
@@ -149,6 +149,43 @@ def print_psb(raw_buf):
|
|||||||
offset = data[1]
|
offset = data[1]
|
||||||
print("offset: %#x" % (offset), end=' ')
|
print("offset: %#x" % (offset), end=' ')
|
||||||
|
|
||||||
|
glb_cfe = ["", "INTR", "IRET", "SMI", "RSM", "SIPI", "INIT", "VMENTRY", "VMEXIT",
|
||||||
|
"VMEXIT_INTR", "SHUTDOWN", "", "UINT", "UIRET"] + [""] * 18
|
||||||
|
glb_evd = ["", "PFA", "VMXQ", "VMXR"] + [""] * 60
|
||||||
|
|
||||||
|
def print_evt(raw_buf):
|
||||||
|
data = struct.unpack_from("<BBH", raw_buf)
|
||||||
|
typ = data[0] & 0x1f
|
||||||
|
ip_flag = (data[0] & 0x80) >> 7
|
||||||
|
vector = data[1]
|
||||||
|
evd_cnt = data[2]
|
||||||
|
s = glb_cfe[typ]
|
||||||
|
if s:
|
||||||
|
print(" cfe: %s IP: %u vector: %u" % (s, ip_flag, vector), end=' ')
|
||||||
|
else:
|
||||||
|
print(" cfe: %u IP: %u vector: %u" % (typ, ip_flag, vector), end=' ')
|
||||||
|
pos = 4
|
||||||
|
for i in range(evd_cnt):
|
||||||
|
data = struct.unpack_from("<QQ", raw_buf)
|
||||||
|
et = data[0] & 0x3f
|
||||||
|
s = glb_evd[et]
|
||||||
|
if s:
|
||||||
|
print("%s: %#x" % (s, data[1]), end=' ')
|
||||||
|
else:
|
||||||
|
print("EVD_%u: %#x" % (et, data[1]), end=' ')
|
||||||
|
|
||||||
|
def print_iflag(raw_buf):
|
||||||
|
data = struct.unpack_from("<IQ", raw_buf)
|
||||||
|
iflag = data[0] & 1
|
||||||
|
old_iflag = iflag ^ 1
|
||||||
|
via_branch = data[0] & 2
|
||||||
|
branch_ip = data[1]
|
||||||
|
if via_branch:
|
||||||
|
s = "via"
|
||||||
|
else:
|
||||||
|
s = "non"
|
||||||
|
print("IFLAG: %u->%u %s branch" % (old_iflag, iflag, s), end=' ')
|
||||||
|
|
||||||
def common_start_str(comm, sample):
|
def common_start_str(comm, sample):
|
||||||
ts = sample["time"]
|
ts = sample["time"]
|
||||||
cpu = sample["cpu"]
|
cpu = sample["cpu"]
|
||||||
@@ -164,7 +201,7 @@ def print_common_start(comm, sample, name):
|
|||||||
# weight = sample["weight"]
|
# weight = sample["weight"]
|
||||||
# transaction = sample["transaction"]
|
# transaction = sample["transaction"]
|
||||||
# cpumode = get_optional_zero(sample, "cpumode")
|
# cpumode = get_optional_zero(sample, "cpumode")
|
||||||
print(common_start_str(comm, sample) + "%7s %19s" % (name, flags_disp), end=' ')
|
print(common_start_str(comm, sample) + "%8s %21s" % (name, flags_disp), end=' ')
|
||||||
|
|
||||||
def print_instructions_start(comm, sample):
|
def print_instructions_start(comm, sample):
|
||||||
if "x" in get_optional_null(sample, "flags"):
|
if "x" in get_optional_null(sample, "flags"):
|
||||||
@@ -315,6 +352,14 @@ def do_process_event(param_dict):
|
|||||||
print_common_start(comm, sample, name)
|
print_common_start(comm, sample, name)
|
||||||
print_psb(raw_buf)
|
print_psb(raw_buf)
|
||||||
print_common_ip(param_dict, sample, symbol, dso)
|
print_common_ip(param_dict, sample, symbol, dso)
|
||||||
|
elif name == "evt":
|
||||||
|
print_common_start(comm, sample, name)
|
||||||
|
print_evt(raw_buf)
|
||||||
|
print_common_ip(param_dict, sample, symbol, dso)
|
||||||
|
elif name == "iflag":
|
||||||
|
print_common_start(comm, sample, name)
|
||||||
|
print_iflag(raw_buf)
|
||||||
|
print_common_ip(param_dict, sample, symbol, dso)
|
||||||
else:
|
else:
|
||||||
print_common_start(comm, sample, name)
|
print_common_start(comm, sample, name)
|
||||||
print_common_ip(param_dict, sample, symbol, dso)
|
print_common_ip(param_dict, sample, symbol, dso)
|
||||||
|
|||||||
Reference in New Issue
Block a user