Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf script python: Adjust objdump start/end per map pgoff parameter

Extract map_pgoff parameter from the dictionary, and adjust start/end
range passed to objdump based on the value.

A zero start_addr is filtered to prevent output of dso address range
check failures. This script repeatedly sees a zero value passed
in for
      start_addr = cpu_data[str(cpu) + 'addr']

These zero values are not a new problem. The start_addr/stop_addr warning
clutters the instruction trace output, hence this change.

Signed-off-by: Steve Clevenger <scclevenger@os.amperecomputing.com>
Reviewed-by: Leo Yan <leo.yan@arm.com>
Cc: suzuki.poulose@arm.com
Cc: james.clark@linaro.org
Cc: mike.leach@linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: coresight@lists.linaro.org
Cc: ilkka@os.amperecomputing.com
Link: https://lore.kernel.org/r/21ccdd22e664bdeccb878672d4b2c0518873c1e5.1731027120.git.scclevenger@os.amperecomputing.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Steve Clevenger and committed by
Namhyung Kim
e8328bf3 26ec3d7c

+11 -5
+11 -5
tools/perf/scripts/python/arm-cs-trace-disasm.py
··· 251 251 dso_start = get_optional(param_dict, "dso_map_start") 252 252 dso_end = get_optional(param_dict, "dso_map_end") 253 253 symbol = get_optional(param_dict, "symbol") 254 + map_pgoff = get_optional(param_dict, "map_pgoff") 255 + # check for valid map offset 256 + if (str(map_pgoff) == '[unknown]'): 257 + map_pgoff = 0 254 258 255 259 cpu = sample["cpu"] 256 260 ip = sample["ip"] ··· 322 318 # Record for previous sample packet 323 319 cpu_data[str(cpu) + 'addr'] = addr 324 320 325 - # Handle CS_ETM_TRACE_ON packet if start_addr=0 and stop_addr=4 326 - if (start_addr == 0 and stop_addr == 4): 327 - print("CPU%d: CS_ETM_TRACE_ON packet is inserted" % cpu) 321 + # Filter out zero start_address. Optionally identify CS_ETM_TRACE_ON packet 322 + if (start_addr == 0): 323 + if ((stop_addr == 4) and (options.verbose == True)): 324 + print("CPU%d: CS_ETM_TRACE_ON packet is inserted" % cpu) 328 325 return 329 326 330 327 if (start_addr < int(dso_start) or start_addr > int(dso_end)): ··· 342 337 # vm_start to zero. 343 338 if (dso == "[kernel.kallsyms]" or dso_start == 0x400000): 344 339 dso_vm_start = 0 340 + map_pgoff = 0 345 341 else: 346 342 dso_vm_start = int(dso_start) 347 343 348 344 dso_fname = get_dso_file_path(dso, dso_bid) 349 345 if path.exists(dso_fname): 350 - print_disam(dso_fname, dso_vm_start, start_addr, stop_addr) 346 + print_disam(dso_fname, dso_vm_start, start_addr + map_pgoff, stop_addr + map_pgoff) 351 347 else: 352 - print("Failed to find dso %s for address range [ 0x%x .. 0x%x ]" % (dso, start_addr, stop_addr)) 348 + print("Failed to find dso %s for address range [ 0x%x .. 0x%x ]" % (dso, start_addr + map_pgoff, stop_addr + map_pgoff)) 353 349 354 350 print_srccode(comm, param_dict, sample, symbol, dso)