fix(ruff): update Python code to conform to 0.16

This commit is contained in:
Jonathan Steffan
2026-07-24 21:14:49 +02:00
committed by xytovl
parent 8b54ba1643
commit 00d2727049
11 changed files with 465 additions and 396 deletions
+30 -28
View File
@@ -1,47 +1,49 @@
#!/usr/bin/env python3
import os
import re
import subprocess
import sys
from elftools.elf.elffile import ELFFile
from elftools.elf.sections import NoteSection
import os
import sys
import subprocess
def get_lib_list(path):
def get_build_id(filename):
with open(filename, 'rb') as f:
for sect in ELFFile(f).iter_sections():
if not isinstance(sect, NoteSection):
continue
for note in sect.iter_notes():
if note['n_type'] in {'NT_GNU_BUILD_ID', 'NT_GNU_GOLD_VERSION'}:
return note['n_desc']
return None
def get_build_id(filename):
with open(filename, "rb") as f:
for sect in ELFFile(f).iter_sections():
if not isinstance(sect, NoteSection):
continue
for note in sect.iter_notes():
if note["n_type"] in {"NT_GNU_BUILD_ID", "NT_GNU_GOLD_VERSION"}:
return note["n_desc"]
return None
libs = {}
libs = {}
for root, dirs, files in os.walk(path):
for name in files:
if name.endswith('.so'):
build_id = get_build_id(os.path.join(root, name))
if build_id:
libs[build_id] = os.path.join(root, name)
for root, dirs, files in os.walk(path):
for name in files:
if name.endswith(".so"):
build_id = get_build_id(os.path.join(root, name))
if build_id:
libs[build_id] = os.path.join(root, name)
return libs
return libs
libs = get_lib_list('build/intermediates/merged_native_libs')
libs = get_lib_list("build/intermediates/merged_native_libs")
r = re.compile("^.*#[0-9]+ pc ([0-9a-f]+) .*BuildId: ([0-9a-f]*).*")
for line in sys.stdin:
m = r.match(line.rstrip())
if m:
address = m[1]
build_id = m[2]
m = r.match(line.rstrip())
if m:
address = m[1]
build_id = m[2]
if build_id in libs:
lib = libs[build_id]
subprocess.run(['llvm-symbolizer'], input=(lib + ' 0x' + address).encode("utf-8"))
if build_id in libs:
lib = libs[build_id]
subprocess.run(
["llvm-symbolizer"], input=(lib + " 0x" + address).encode("utf-8"), check=False
)