diff options
Diffstat (limited to 'build-aux')
-rwxr-xr-x | build-aux/embed-sources.h.gen | 4 | ||||
-rwxr-xr-x | build-aux/lint-bin | 15 | ||||
-rwxr-xr-x | build-aux/lint-generic | 7 | ||||
-rwxr-xr-x | build-aux/lint-h | 6 | ||||
-rwxr-xr-x | build-aux/linux-errno.txt.gen | 17 | ||||
-rw-r--r-- | build-aux/measurestack/app_plugins.py | 56 | ||||
-rwxr-xr-x | build-aux/valgrind | 16 |
7 files changed, 55 insertions, 66 deletions
diff --git a/build-aux/embed-sources.h.gen b/build-aux/embed-sources.h.gen index 0329496..ee9eb42 100755 --- a/build-aux/embed-sources.h.gen +++ b/build-aux/embed-sources.h.gen @@ -6,5 +6,5 @@ nm --format=posix "$@" | sed -n -E \ - -e 's/(.*_(end|start)) [DR] .*/extern char \1[];/p' \ - -e 's/(.*_size) A .*/extern size_t \1;/p' + -e 's/(.*_(end|start)) [DR] .*/extern char \1[];/p' \ + -e 's/(.*_size) A .*/extern size_t \1;/p' diff --git a/build-aux/lint-bin b/build-aux/lint-bin index 78ed19f..91f1612 100755 --- a/build-aux/lint-bin +++ b/build-aux/lint-bin @@ -62,7 +62,7 @@ lint_globals() { cd "$rel_base" total=0 while read -r symbol addr size source; do - if (( addr == 0 )); then + if ((addr == 0)); then continue fi case "$source" in @@ -103,8 +103,9 @@ lint_stack() { fi done < <( comm -3 \ - <(sed -En 's/^included: (.*:)?//p' "${in_elffile%.elf}_stack.c" | sort -u) \ - <(readelf_funcs "$in_elffile" | sed -E -e 's/\.part\.[0-9]*$//' -e 's/^__(.*)_veneer$/\1/' | sort -u)) + <(sed -En 's/^included: (.*:)?//p' "${in_elffile%.elf}_stack.c" | sort -u) \ + <(readelf_funcs "$in_elffile" | sed -E -e 's/\.part\.[0-9]*$//' -e 's/^__(.*)_veneer$/\1/' | sort -u) + ) } lint_func_blocklist() { @@ -118,8 +119,8 @@ lint_func_blocklist() { while read -r func; do err "$in_elffile" "Contains blocklisted function: ${func}" done < <(readelf --syms --wide -- "$in_elffile" | - awk '$4 == "FUNC" { print $8 }' | - grep -Fx "${blocklist[@]/#/-e}") + awk '$4 == "FUNC" { print $8 }' | + grep -Fx "${blocklist[@]/#/-e}") } main() { @@ -130,8 +131,8 @@ main() { { echo 'Global variables:' lint_globals "${elf}.map" | sed 's/^/ /' - } > "${elf%.elf}.lint.globals" - (lint_stack "$elf") &> "${elf%.elf}.lint.stack" + } >"${elf%.elf}.lint.globals" + (lint_stack "$elf") &>"${elf%.elf}.lint.stack" lint_func_blocklist "$elf" done diff --git a/build-aux/lint-generic b/build-aux/lint-generic index 58a65d2..70e814a 100755 --- a/build-aux/lint-generic +++ b/build-aux/lint-generic @@ -25,12 +25,17 @@ for filename in "$@"; do if [ -x "$filename" ] && [ -z "$shebang" ]; then err "$filename" 'is executable but does not have a shebang' elif [ -n "$shebang" ] && ! [ -x "$filename" ]; then - err "$filename" 'has a shebang but is executable' + err "$filename" 'has a shebang but is not executable' fi if ! grep -E -q 'Copyright \(C\) 202[4-9]((-|, )202[5-9])* Luke T. Shumaker' "$filename"; then err "$filename" 'is missing a copyright statement' fi + if test -e .git && ! git diff --quiet milestone/2025-01-01 HEAD -- "$filename"; then + if ! grep -E -q 'Copyright \(C\) .*2025 Luke T. Shumaker' "$filename"; then + err "$filename" 'has an outdated copyright statement' + fi + fi if ! grep -q '\sSPDX-License-Identifier[:] ' "$filename"; then err "$filename" 'is missing an SPDX-License-Identifier' fi diff --git a/build-aux/lint-h b/build-aux/lint-h index 26ac13d..7459032 100755 --- a/build-aux/lint-h +++ b/build-aux/lint-h @@ -18,9 +18,9 @@ for filename in "$@"; do guard=${dscname//'/'/'_'} guard=${guard//'.'/'_'} guard="_${guard^^}_" - if ! { grep -Fxq "#ifndef ${guard}" "$filename" && - grep -Fxq "#define ${guard}" "$filename" && - grep -Fxq "#endif /* ${guard} */" "$filename"; }; then + if ! { grep -Fxq "#ifndef ${guard}" "$filename" && + grep -Fxq "#define ${guard}" "$filename" && + grep -Fxq "#endif /* ${guard} */" "$filename"; }; then err "$filename" "does not have ${guard} guard" fi done diff --git a/build-aux/linux-errno.txt.gen b/build-aux/linux-errno.txt.gen deleted file mode 100755 index f94178f..0000000 --- a/build-aux/linux-errno.txt.gen +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -# build-aux/linux-errno.txt.gen - Generate a listing of Linux kernel errnos -# -# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> -# SPDX-License-Identifier: AGPL-3.0-or-later - -set -e -linux_git=${1:?} -outfile=${2:?} - -( - cd "${linux_git}" - echo "# ${outfile} - Generated from $0 and linux.git $(git describe). DO NOT EDIT!" - git ls-files include/uapi/ | grep errno | - xargs sed -nE 's,#\s*define\s+(E[A-Z0-9]+)\s+([0-9]+)\s+/\* (.*) \*/,\2 \1 \3,p' | - sort --numeric-sort -) >"${outfile}" diff --git a/build-aux/measurestack/app_plugins.py b/build-aux/measurestack/app_plugins.py index 36e661b..bbb0eae 100644 --- a/build-aux/measurestack/app_plugins.py +++ b/build-aux/measurestack/app_plugins.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later import re +import subprocess import typing from . import analyze, util @@ -247,8 +248,8 @@ class LibCRIPCPlugin: return None if "/chan.c:" in loc and "front->dequeue(" in line: return [ - QName("_cr_chan_dequeue"), - QName("_cr_select_dequeue"), + QName("cr_chan_dequeue"), + QName("cr_select_dequeue"), ], False return None @@ -271,9 +272,8 @@ re_lib9p_callee = re.compile( class Lib9PPlugin: tmessage_handlers: set[QName] | None lib9p_msgs: set[str] - _CONFIG_9P_NUM_SOCKS: int | None - CONFIG_9P_SRV_MAX_REQS: int | None - CONFIG_9P_SRV_MAX_DEPTH: int | None + _CONFIG_9P_MAX_CONNS: int | None + _CONFIG_9P_MAX_REQS: int | None formatters: typing.Collection[BaseName] def __init__( @@ -305,25 +305,25 @@ class Lib9PPlugin: ) lib9p_generated_c_fname = util.get_zero_or_one( - lambda fname: fname.endswith("lib9p/9p.generated.c"), arg_c_fnames + lambda fname: fname.endswith("lib9p/_core_generated.c"), arg_c_fnames ) # Read config ########################################################## def config_h_get(varname: str) -> int | None: if config_h_fname: - with open(config_h_fname, "r", encoding="utf-8") as fh: - for line in fh: - line = line.rstrip() - if line.startswith("#define"): - parts = line.split() - if parts[1] == varname: - return int(parts[2]) + line = subprocess.run( + ["cpp"], + input=f'#include "{config_h_fname}"\n{varname}\n', + check=True, + capture_output=True, + encoding="utf-8", + ).stdout.split("\n")[-2] + return int(eval(line)) # pylint: disable=eval-used return None - self._CONFIG_9P_NUM_SOCKS = config_h_get("_CONFIG_9P_NUM_SOCKS") - self.CONFIG_9P_SRV_MAX_REQS = config_h_get("CONFIG_9P_SRV_MAX_REQS") - self.CONFIG_9P_SRV_MAX_DEPTH = config_h_get("CONFIG_9P_SRV_MAX_DEPTH") + self._CONFIG_9P_MAX_CONNS = config_h_get("_CONFIG_9P_MAX_REQS") + self._CONFIG_9P_MAX_REQS = config_h_get("_CONFIG_9P_MAX_REQS") # Read sources ######################################################### @@ -348,12 +348,12 @@ class Lib9PPlugin: self.lib9p_msgs = lib9p_msgs def thread_count(self, name: QName) -> int: - assert self._CONFIG_9P_NUM_SOCKS - assert self.CONFIG_9P_SRV_MAX_REQS + assert self._CONFIG_9P_MAX_CONNS + assert self._CONFIG_9P_MAX_REQS if "read" in str(name.base()): - return self._CONFIG_9P_NUM_SOCKS + return self._CONFIG_9P_MAX_CONNS if "write" in str(name.base()): - return self._CONFIG_9P_NUM_SOCKS * self.CONFIG_9P_SRV_MAX_REQS + return self._CONFIG_9P_MAX_REQS return 1 def is_intrhandler(self, name: QName) -> bool: @@ -405,11 +405,6 @@ class Lib9PPlugin: self.formatters, self._skipmodel__vfctprintf ), } - if isinstance(self.CONFIG_9P_SRV_MAX_DEPTH, int): - ret[BaseName("srv_util_pathfree")] = analyze.SkipModel( - self.CONFIG_9P_SRV_MAX_DEPTH, - self._skipmodel_srv_util_pathfree, - ) return ret def _skipmodel__lib9p_validate_unmarshal_marshal( @@ -423,17 +418,6 @@ class Lib9PPlugin: return False return m_caller.group("grp") != m_callee.group("grp") - def _skipmodel_srv_util_pathfree( - self, chain: typing.Sequence[QName], call: QName - ) -> bool: - assert isinstance(self.CONFIG_9P_SRV_MAX_DEPTH, int) - if call.base() == BaseName("srv_util_pathfree"): - return len(chain) >= self.CONFIG_9P_SRV_MAX_DEPTH and all( - c.base() == BaseName("srv_util_pathfree") - for c in chain[-self.CONFIG_9P_SRV_MAX_DEPTH :] - ) - return False - def _skipmodel__vfctprintf( self, chain: typing.Sequence[QName], call: QName ) -> bool: diff --git a/build-aux/valgrind b/build-aux/valgrind new file mode 100755 index 0000000..7ad2712 --- /dev/null +++ b/build-aux/valgrind @@ -0,0 +1,16 @@ +#!/bin/env bash +# build-aux/valgrind - Wrapper around valgrind to keep flags consistent +# +# Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com> +# SPDX-License-Identifier: AGPL-3.0-or-later + +exec \ + valgrind \ + --fair-sched=yes \ + --error-exitcode=2 \ + --leak-check=full \ + --show-leak-kinds=all \ + --errors-for-leak-kinds=all \ + --show-error-list=all \ + -- \ + "$@" |