-
Notifications
You must be signed in to change notification settings - Fork 15
/
debug-sym-file.py
executable file
·55 lines (44 loc) · 1.53 KB
/
debug-sym-file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Prints information about a sym file including whether it kicks up
# a parse error.
# Usage: debug-sym-file.py [SYMFILE]
import os
import time
import click
import symbolic
@click.command()
@click.argument("symfile")
@click.pass_context
def sym_file_debug(ctx, symfile):
"""Prints information about a sym file including whether it parses correctly."""
# Print size
stats = os.stat(symfile)
click.echo(f"{symfile}")
click.echo(f"size: {stats.st_size:,}")
# Print header
with open(symfile, "r") as fp:
for line in fp.readlines():
line = line.strip()
if line.startswith(("MODULE", "INFO")):
print(f"header: {line}")
else:
break
# Parse with symbolic and create symcache
try:
click.echo("parsing with symbolic ...")
archive = symbolic.Archive.open(symfile)
click.echo("listing objects and making symcaches ...")
for obj in archive.iter_objects():
click.echo(f"* {obj.debug_id = } ", nl=False)
start_time = time.time()
obj.make_symcache()
delta = time.time() - start_time
click.echo(f"{delta:.3f}ms")
except Exception:
click.echo("symbolic can't parse it")
raise
if __name__ == "__main__":
sym_file_debug()