History

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.

Steve Clevenger committed 2 years ago

Commit e8328bf1 parent 26ec3d71 file · +11 −5Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/arm-cs-trace-disasm.py+11−5
@@ -251,6 +251,10 @@ def process_event(param_dict): · 250 unmodified lines
251251 dso_start = get_optional(param_dict, "dso_map_start")
252252 dso_end = get_optional(param_dict, "dso_map_end")
253253 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
254258
255259 cpu = sample["cpu"]
256260 ip = sample["ip"]
@@ -318,9 +322,10 @@ def process_event(param_dict): · 61 unmodified lines
318322 # Record for previous sample packet
319323 cpu_data[str(cpu) + 'addr'] = addr
320324
321− # Handle CS_ETM_TRACE_ON packet if start_addr=0 and stop_addr=4
322− if (start_addr == 0 and stop_addr == 4):
323− print("CPU%d: CS_ETM_TRACE_ON packet is inserted" % cpu)
325+ # Filter out zero start_address. Optionally identify CS_ETM_TRACE_ON packet
326+ if (start_addr == 0):
327+ if ((stop_addr == 4) and (options.verbose == True)):
328+ print("CPU%d: CS_ETM_TRACE_ON packet is inserted" % cpu)
324329 return
325330
326331 if (start_addr < int(dso_start) or start_addr > int(dso_end)):
@@ -337,13 +342,14 @@ def process_event(param_dict): · 10 unmodified lines
337342 # vm_start to zero.
338343 if (dso == "[kernel.kallsyms]" or dso_start == 0x400000):
339344 dso_vm_start = 0
345+ map_pgoff = 0
340346 else:
341347 dso_vm_start = int(dso_start)
342348
343349 dso_fname = get_dso_file_path(dso, dso_bid)
344350 if path.exists(dso_fname):
345− print_disam(dso_fname, dso_vm_start, start_addr, stop_addr)
351+ print_disam(dso_fname, dso_vm_start, start_addr + map_pgoff, stop_addr + map_pgoff)
346352 else:
347− print("Failed to find dso %s for address range [ 0x%x .. 0x%x ]" % (dso, start_addr, stop_addr))
353+ print("Failed to find dso %s for address range [ 0x%x .. 0x%x ]" % (dso, start_addr + map_pgoff, stop_addr + map_pgoff))
348354
349355 print_srccode(comm, param_dict, sample, symbol, dso)