CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
131 lines
4.3 KiB
Python
Executable File
131 lines
4.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import subprocess
|
|
import optparse
|
|
import os
|
|
import os.path
|
|
import re
|
|
import sys
|
|
|
|
|
|
def extract_exe_symbol_names(arch, exe_path, match_str):
|
|
command = 'dsymutil --arch %s -s "%s" | grep "%s" | colrm 1 69' % (
|
|
arch,
|
|
exe_path,
|
|
match_str,
|
|
)
|
|
(command_exit_status, command_output) = subprocess.getstatusoutput(command)
|
|
if command_exit_status == 0:
|
|
if command_output:
|
|
return command_output[0:-1].split("'\n")
|
|
else:
|
|
print("error: command returned no output")
|
|
else:
|
|
print(
|
|
"error: command failed with exit status %i\n command: %s"
|
|
% (command_exit_status, command)
|
|
)
|
|
return list()
|
|
|
|
|
|
def verify_api(all_args):
|
|
"""Verify the API in the specified library is valid given one or more binaries."""
|
|
usage = "usage: verify_api --library <path> [ --library <path> ...] executable1 [executable2 ...]"
|
|
description = """Verify the API in the specified library is valid given one or more binaries.
|
|
|
|
Example:
|
|
|
|
verify_api.py --library ~/Documents/src/lldb/build/Debug/LLDB.framework/LLDB --arch x86_64 /Applications/Xcode.app/Contents/PlugIns/DebuggerLLDB.ideplugin/Contents/MacOS/DebuggerLLDB --api-regex lldb
|
|
"""
|
|
parser = optparse.OptionParser(
|
|
description=description, prog="verify_api", usage=usage
|
|
)
|
|
parser.add_option(
|
|
"-v",
|
|
"--verbose",
|
|
action="store_true",
|
|
dest="verbose",
|
|
help="display verbose debug info",
|
|
default=False,
|
|
)
|
|
parser.add_option(
|
|
"-a",
|
|
"--arch",
|
|
type="string",
|
|
action="append",
|
|
dest="archs",
|
|
help="architecture to use when checking the api",
|
|
)
|
|
parser.add_option(
|
|
"-r",
|
|
"--api-regex",
|
|
type="string",
|
|
dest="api_regex_str",
|
|
help="Exclude any undefined symbols that do not match this regular expression when searching for missing APIs.",
|
|
)
|
|
parser.add_option(
|
|
"-l",
|
|
"--library",
|
|
type="string",
|
|
action="append",
|
|
dest="libraries",
|
|
help="Specify one or more libraries that will contain all needed APIs for the executables.",
|
|
)
|
|
(options, args) = parser.parse_args(all_args)
|
|
|
|
api_external_symbols = list()
|
|
if options.archs:
|
|
for arch in options.archs:
|
|
for library in options.libraries:
|
|
external_symbols = extract_exe_symbol_names(
|
|
arch, library, "( SECT EXT)"
|
|
)
|
|
if external_symbols:
|
|
for external_symbol in external_symbols:
|
|
api_external_symbols.append(external_symbol)
|
|
else:
|
|
sys.exit(1)
|
|
else:
|
|
print("error: must specify one or more architectures with the --arch option")
|
|
sys.exit(4)
|
|
if options.verbose:
|
|
print("API symbols:")
|
|
for i, external_symbol in enumerate(api_external_symbols):
|
|
print("[%u] %s" % (i, external_symbol))
|
|
|
|
api_regex = None
|
|
if options.api_regex_str:
|
|
api_regex = re.compile(options.api_regex_str)
|
|
|
|
for arch in options.archs:
|
|
for exe_path in args:
|
|
print('Verifying (%s) "%s"...' % (arch, exe_path))
|
|
exe_errors = 0
|
|
undefined_symbols = extract_exe_symbol_names(
|
|
arch, exe_path, "( UNDF EXT)"
|
|
)
|
|
for undefined_symbol in undefined_symbols:
|
|
if api_regex:
|
|
match = api_regex.search(undefined_symbol)
|
|
if not match:
|
|
if options.verbose:
|
|
print("ignoring symbol: %s" % (undefined_symbol))
|
|
continue
|
|
if undefined_symbol in api_external_symbols:
|
|
if options.verbose:
|
|
print("verified symbol: %s" % (undefined_symbol))
|
|
else:
|
|
print("missing symbol: %s" % (undefined_symbol))
|
|
exe_errors += 1
|
|
if exe_errors:
|
|
print(
|
|
"error: missing %u API symbols from %s"
|
|
% (exe_errors, options.libraries)
|
|
)
|
|
else:
|
|
print("success")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
verify_api(sys.argv[1:])
|