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
251 dso_start = get_optional(param_dict, "dso_map_start")251 dso_start = get_optional(param_dict, "dso_map_start")
252 dso_end = get_optional(param_dict, "dso_map_end")252 dso_end = get_optional(param_dict, "dso_map_end")
253 symbol = get_optional(param_dict, "symbol")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 cpu = sample["cpu"]259 cpu = sample["cpu"]
256 ip = sample["ip"]260 ip = sample["ip"]
@@ -318,9 +322,10 @@ def process_event(param_dict): · 61 unmodified lines
318 # Record for previous sample packet322 # Record for previous sample packet
319 cpu_data[str(cpu) + 'addr'] = addr323 cpu_data[str(cpu) + 'addr'] = addr
320 324
321 # Handle CS_ETM_TRACE_ON packet if start_addr=0 and stop_addr=4325 # Filter out zero start_address. Optionally identify CS_ETM_TRACE_ON packet
322 if (start_addr == 0 and stop_addr == 4):326 if (start_addr == 0):
323 print("CPU%d: CS_ETM_TRACE_ON packet is inserted" % cpu)327 if ((stop_addr == 4) and (options.verbose == True)):
328 print("CPU%d: CS_ETM_TRACE_ON packet is inserted" % cpu)
324 return329 return
325 330
326 if (start_addr < int(dso_start) or start_addr > int(dso_end)):331 if (start_addr < int(dso_start) or start_addr > int(dso_end)):
@@ -337,13 +342,14 @@ def process_event(param_dict): · 10 unmodified lines
337 # vm_start to zero.342 # vm_start to zero.
338 if (dso == "[kernel.kallsyms]" or dso_start == 0x400000):343 if (dso == "[kernel.kallsyms]" or dso_start == 0x400000):
339 dso_vm_start = 0344 dso_vm_start = 0
345 map_pgoff = 0
340 else:346 else:
341 dso_vm_start = int(dso_start)347 dso_vm_start = int(dso_start)
342 348
343 dso_fname = get_dso_file_path(dso, dso_bid)349 dso_fname = get_dso_file_path(dso, dso_bid)
344 if path.exists(dso_fname):350 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)
346 else:352 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))
348 354
349 print_srccode(comm, param_dict, sample, symbol, dso)355 print_srccode(comm, param_dict, sample, symbol, dso)