perf scripts python arm-cs-trace-disasm.py: Do not ignore disam first sample
authorRuidong Tian <tianruidong@linux.alibaba.com>
Thu, 14 Dec 2023 12:33:04 +0000 (20:33 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 20 Dec 2023 17:31:59 +0000 (14:31 -0300)
arm-cs-trace-disasm ignore disam the first branch sample, For example as
follow, the instructions beteween 0x0000ffffae878750 and
0x0000ffffae878754 is lose:

  ARM CoreSight Trace Data Assembler Dump
  Event type: branches:uH
  Sample = { cpu: 0000 addr: 0x0000ffffae878750 phys_addr: 0x0000000000000000 ip: 0x0000000000000000 pid: 4003489 tid: 4003489 period: 1 time: 26765151766034 }
  Event type: branches:uH
  Sample = { cpu: 0000 addr: 0x0000000000000000 phys_addr: 0x0000000000000000 ip: 0x0000ffffae878754 pid: 4003489 tid: 4003489 period: 1 time: 26765151766034 }

Initialize cpu_data earlier to fix it:

  ARM CoreSight Trace Data Assembler Dump
  Event type: branches:uH
  Sample = { cpu: 0000 addr: 0x0000000000000000 phys_addr: 0x0000000000000000 ip: 0x0000ffffae878754 pid: 4003489 tid: 4003489 period: 1 time: 26765151766034 }
        0000000000028740 <ioctl>: (base address is 0x0000ffffae850000)
           28750: b13ffc1f      cmn     x0, #4095
           28754: 54000042      b.hs    0x2875c <ioctl+0x1c>
            test 4003489/4003489 [0000]     26765.151766034  __GI___ioctl+0x14                        /usr/lib64/libc-2.32.so
  Event type: branches:uH
  Sample = { cpu: 0000 addr: 0x0000ffffa67535ac phys_addr: 0x0000000000000000 ip: 0x0000000000000000 pid: 4003489 tid: 4003489 period: 1 time: 26765151766034 }

Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Al Grant <al.grant@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Tor Jeremiassen <tor@ti.com>
Link: https://lore.kernel.org/r/20231214123304.34087-4-tianruidong@linux.alibaba.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/scripts/python/arm-cs-trace-disasm.py

index e33aee5c78d72c1c59109c3325bb41b5ad35f0ad..d973c2baed1c8559d2c769516a07542ecc993dc5 100755 (executable)
@@ -188,6 +188,17 @@ def process_event(param_dict):
        dso_end = get_optional(param_dict, "dso_map_end")
        symbol = get_optional(param_dict, "symbol")
 
+       cpu = sample["cpu"]
+       ip = sample["ip"]
+       addr = sample["addr"]
+
+       # Initialize CPU data if it's empty, and directly return back
+       # if this is the first tracing event for this CPU.
+       if (cpu_data.get(str(cpu) + 'addr') == None):
+               cpu_data[str(cpu) + 'addr'] = addr
+               return
+
+
        if (options.verbose == True):
                print("Event type: %s" % name)
                print_sample(sample)
@@ -209,16 +220,6 @@ def process_event(param_dict):
        if (name[0:8] != "branches"):
                return
 
-       cpu = sample["cpu"]
-       ip = sample["ip"]
-       addr = sample["addr"]
-
-       # Initialize CPU data if it's empty, and directly return back
-       # if this is the first tracing event for this CPU.
-       if (cpu_data.get(str(cpu) + 'addr') == None):
-               cpu_data[str(cpu) + 'addr'] = addr
-               return
-
        # The format for packet is:
        #
        #                 +------------+------------+------------+