The mainline kernel can be used for relative old distros, e.g. RHEL 7. The distro doesn't upgrade from python2 to python3, this causes the building error that the python script is not python2 compliant. To fix the building failure, this patch changes from the python f-string format to traditional string format.
Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all
Unified · Split
| @@ -61,7 +61,7 @@ def get_optional(perf_dict, field): · 60 unmodified lines | ||
| 61 | 61 | |
| 62 | 62 | def get_offset(perf_dict, field): |
| 63 | 63 | if field in perf_dict: |
| 64 | − return f"+0x{perf_dict[field]:x}" | |
| 64 | + return "+%#x" % perf_dict[field] | |
| 65 | 65 | return "" |
| 66 | 66 | |
| 67 | 67 | def get_dso_file_path(dso_name, dso_build_id): |
| @@ -76,7 +76,7 @@ def get_dso_file_path(dso_name, dso_build_id): · 8 unmodified lines | ||
| 76 | 76 | else: |
| 77 | 77 | append = "/elf" |
| 78 | 78 | |
| 79 | − dso_path = f"{os.environ['PERF_BUILDID_DIR']}/{dso_name}/{dso_build_id}{append}" | |
| 79 | + dso_path = os.environ['PERF_BUILDID_DIR'] + "/" + dso_name + "/" + dso_build_id + append; | |
| 80 | 80 | # Replace duplicate slash chars to single slash char |
| 81 | 81 | dso_path = dso_path.replace('//', '/', 1) |
| 82 | 82 | return dso_path |
| @@ -94,8 +94,8 @@ def read_disam(dso_fname, dso_start, start_addr, stop_addr): · 11 unmodified lines | ||
| 94 | 94 | start_addr = start_addr - dso_start; |
| 95 | 95 | stop_addr = stop_addr - dso_start; |
| 96 | 96 | disasm = [ options.objdump_name, "-d", "-z", |
| 97 | − f"--start-address=0x{start_addr:x}", | |
| 98 | − f"--stop-address=0x{stop_addr:x}" ] | |
| 97 | + "--start-address="+format(start_addr,"#x"), | |
| 98 | + "--stop-address="+format(stop_addr,"#x") ] | |
| 99 | 99 | disasm += [ dso_fname ] |
| 100 | 100 | disasm_output = check_output(disasm).decode('utf-8').split('\n') |
| 101 | 101 | disasm_cache[addr_range] = disasm_output |
| @@ -109,12 +109,14 @@ def print_disam(dso_fname, dso_start, start_addr, stop_addr): · 7 unmodified lines | ||
| 109 | 109 | m = disasm_re.search(line) |
| 110 | 110 | if m is None: |
| 111 | 111 | continue |
| 112 | − print(f"\t{line}") | |
| 112 | + print("\t" + line) | |
| 113 | 113 | |
| 114 | 114 | def print_sample(sample): |
| 115 | − print(f"Sample = {{ cpu: {sample['cpu']:04} addr: 0x{sample['addr']:016x} " \ | |
| 116 | − f"phys_addr: 0x{sample['phys_addr']:016x} ip: 0x{sample['ip']:016x} " \ | |
| 117 | − f"pid: {sample['pid']} tid: {sample['tid']} period: {sample['period']} time: {sample['time']} }}") | |
| 115 | + print("Sample = { cpu: %04d addr: 0x%016x phys_addr: 0x%016x ip: 0x%016x " \ | |
| 116 | + "pid: %d tid: %d period: %d time: %d }" % \ | |
| 117 | + (sample['cpu'], sample['addr'], sample['phys_addr'], \ | |
| 118 | + sample['ip'], sample['pid'], sample['tid'], \ | |
| 119 | + sample['period'], sample['time'])) | |
| 118 | 120 | |
| 119 | 121 | def trace_begin(): |
| 120 | 122 | print('ARM CoreSight Trace Data Assembler Dump') |
| @@ -131,7 +133,7 @@ def common_start_str(comm, sample): · 10 unmodified lines | ||
| 131 | 133 | cpu = sample["cpu"] |
| 132 | 134 | pid = sample["pid"] |
| 133 | 135 | tid = sample["tid"] |
| 134 | − return f"{comm:>16} {pid:>5}/{tid:<5} [{cpu:04}] {sec:9}.{ns:09} " | |
| 136 | + return "%16s %5u/%-5u [%04u] %9u.%09u " % (comm, pid, tid, cpu, sec, ns) | |
| 135 | 137 | |
| 136 | 138 | # This code is copied from intel-pt-events.py for printing source code |
| 137 | 139 | # line and symbols. |
| @@ -171,7 +173,7 @@ def print_srccode(comm, param_dict, sample, symbol, dso): · 33 unmodified lines | ||
| 171 | 173 | glb_line_number = line_number |
| 172 | 174 | glb_source_file_name = source_file_name |
| 173 | 175 | |
| 174 | − print(f"{start_str}{src_str}") | |
| 176 | + print(start_str, src_str) | |
| 175 | 177 | |
| 176 | 178 | def process_event(param_dict): |
| 177 | 179 | global cache_size |
| @@ -188,7 +190,7 @@ def process_event(param_dict): · 10 unmodified lines | ||
| 188 | 190 | symbol = get_optional(param_dict, "symbol") |
| 189 | 191 | |
| 190 | 192 | if (options.verbose == True): |
| 191 | − print(f"Event type: {name}") | |
| 193 | + print("Event type: %s" % name) | |
| 192 | 194 | print_sample(sample) |
| 193 | 195 | |
| 194 | 196 | # If cannot find dso so cannot dump assembler, bail out |
| @@ -197,7 +199,7 @@ def process_event(param_dict): · 2 unmodified lines | ||
| 197 | 199 | |
| 198 | 200 | # Validate dso start and end addresses |
| 199 | 201 | if ((dso_start == '[unknown]') or (dso_end == '[unknown]')): |
| 200 | − print(f"Failed to find valid dso map for dso {dso}") | |
| 202 | + print("Failed to find valid dso map for dso %s" % dso) | |
| 201 | 203 | return |
| 202 | 204 | |
| 203 | 205 | if (name[0:12] == "instructions"): |
| @@ -244,15 +246,15 @@ def process_event(param_dict): · 40 unmodified lines | ||
| 244 | 246 | |
| 245 | 247 | # Handle CS_ETM_TRACE_ON packet if start_addr=0 and stop_addr=4 |
| 246 | 248 | if (start_addr == 0 and stop_addr == 4): |
| 247 | − print(f"CPU{cpu}: CS_ETM_TRACE_ON packet is inserted") | |
| 249 | + print("CPU%d: CS_ETM_TRACE_ON packet is inserted" % cpu) | |
| 248 | 250 | return |
| 249 | 251 | |
| 250 | 252 | if (start_addr < int(dso_start) or start_addr > int(dso_end)): |
| 251 | − print(f"Start address 0x{start_addr:x} is out of range [ 0x{dso_start:x} .. 0x{dso_end:x} ] for dso {dso}") | |
| 253 | + print("Start address 0x%x is out of range [ 0x%x .. 0x%x ] for dso %s" % (start_addr, int(dso_start), int(dso_end), dso)) | |
| 252 | 254 | return |
| 253 | 255 | |
| 254 | 256 | if (stop_addr < int(dso_start) or stop_addr > int(dso_end)): |
| 255 | − print(f"Stop address 0x{stop_addr:x} is out of range [ 0x{dso_start:x} .. 0x{dso_end:x} ] for dso {dso}") | |
| 257 | + print("Stop address 0x%x is out of range [ 0x%x .. 0x%x ] for dso %s" % (stop_addr, int(dso_start), int(dso_end), dso)) | |
| 256 | 258 | return |
| 257 | 259 | |
| 258 | 260 | if (options.objdump_name != None): |
| @@ -267,6 +269,6 @@ def process_event(param_dict): · 8 unmodified lines | ||
| 267 | 269 | if path.exists(dso_fname): |
| 268 | 270 | print_disam(dso_fname, dso_vm_start, start_addr, stop_addr) |
| 269 | 271 | else: |
| 270 | − print(f"Failed to find dso {dso} for address range [ 0x{start_addr:x} .. 0x{stop_addr:x} ]") | |
| 272 | + print("Failed to find dso %s for address range [ 0x%x .. 0x%x ]" % (dso, start_addr, stop_addr)) | |
| 271 | 273 | |
| 272 | 274 | print_srccode(comm, param_dict, sample, symbol, dso) |