| 74 | |
| 75 | |
| 76 | def addr2line_batch(addrs: list[int]) -> dict[int, str]: |
| 77 | if not addrs: |
| 78 | return {} |
| 79 | inp = "\n".join(f"0x{a:x}" for a in addrs) |
| 80 | proc = subprocess.run( |
| 81 | [str(ADDR2LINE), "-e", str(ELF)], |
| 82 | input=inp, |
| 83 | capture_output=True, |
| 84 | text=True, |
| 85 | check=True, |
| 86 | ) |
| 87 | out_lines = proc.stdout.splitlines() |
| 88 | res: dict[int, str] = {} |
| 89 | for a, ln in zip(addrs, out_lines): |
| 90 | # strip line:col |
| 91 | f = ln.strip() |
| 92 | f = re.sub(r":\d+(?::\d+)?$", "", f) |
| 93 | f = re.sub(r" \(discriminator \d+\)", "", f) |
| 94 | res[a] = f |
| 95 | return res |
| 96 | |
| 97 | |
| 98 | # Map filename → high-level category |