(path: str)
| 15 | """ |
| 16 | |
| 17 | def main(path: str) -> int: |
| 18 | try: |
| 19 | tree = ET.parse(path) |
| 20 | except Exception as e: |
| 21 | print(f"Failed to parse {path}: {e}") |
| 22 | return 1 |
| 23 | |
| 24 | root = tree.getroot() |
| 25 | # Find all leaf text that look like function symbols; Instruments usually |
| 26 | # includes stacks as text content or attributes in nested elements. We will |
| 27 | # count any text nodes that look like code symbols (contain '::' or '['file:line']'). |
| 28 | counter = Counter() |
| 29 | for elem in root.iter(): |
| 30 | text = (elem.text or '').strip() |
| 31 | if not text: |
| 32 | continue |
| 33 | if '::' in text or ' - [' in text or ' + ' in text: |
| 34 | # Normalize long frames by splitting on ' + ' (address offsets) |
| 35 | frame = text.split(' + ')[0] |
| 36 | counter[frame] += 1 |
| 37 | |
| 38 | print("Top frames by sample count (heuristic):") |
| 39 | for frame, count in counter.most_common(50): |
| 40 | print(f"{count:>8} {frame}") |
| 41 | |
| 42 | return 0 |
| 43 | |
| 44 | if __name__ == '__main__': |
| 45 | if len(sys.argv) != 2: |
no test coverage detected