summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2021-02-13 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2021-02-13 08:00:00 +0000
commitaebc987170528342b2c31f60b60a0f6fb071b24c (patch)
treec2acaad191bdb5c68ddec75428c51626686230e9
parent580dfefc34bccb02ad24614b8e909dbecb1963c3 (diff)
downloadstrace-aebc987170528342b2c31f60b60a0f6fb071b24c.tar.gz
Remove src/types infrastructure
All its former users have been converted to use bundled Linux uapi header files. * src/types/gen.sh: Remove. * src/types/find_last_type_fields.awk: Likewise. * Makefile.am (ACLOCAL_AMFLAGS): Remove "-I src/types". * bootstrap: Remove ./src/types/gen.sh invocation. * configure.ac: Remove st_CHECK_TYPES invocation. * src/Makefile.am: Do not include types/Makemodule.am. (EXTRA_DIST): Remove types/find_last_type_fields.awk and types/gen.sh.
-rw-r--r--Makefile.am2
-rwxr-xr-xbootstrap1
-rw-r--r--configure.ac1
-rw-r--r--src/Makefile.am3
-rw-r--r--src/types/find_last_type_fields.awk24
-rwxr-xr-xsrc/types/gen.sh209
6 files changed, 1 insertions, 239 deletions
diff --git a/Makefile.am b/Makefile.am
index 02ca8e0eb..6a3cbb8e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,7 @@ SUBDIRS = bundled src tests $(TESTS_M32) $(TESTS_MX32)
man_MANS = doc/strace.1 doc/strace-log-merge.1
-ACLOCAL_AMFLAGS = -I m4 -I src/types -I src/xlat
+ACLOCAL_AMFLAGS = -I m4 -I src/xlat
@CODE_COVERAGE_RULES@
CODE_COVERAGE_BRANCH_COVERAGE = 1
diff --git a/bootstrap b/bootstrap
index 83a33c18c..867e60b04 100755
--- a/bootstrap
+++ b/bootstrap
@@ -7,7 +7,6 @@
./m4/gen_bpf_attr_m4.sh
./src/generate_mpers_am.sh
-./src/types/gen.sh
./src/xlat/gen.sh
./tests/gen_pure_executables.sh
./tests/gen_tests.sh
diff --git a/configure.ac b/configure.ac
index 4e47e1144..268ee52fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -598,7 +598,6 @@ AC_CHECK_MEMBERS([struct clone_args.cgroup],,, [#include <linux/sched.h>])
CPPFLAGS="$saved_CPPFLAGS"
-st_CHECK_TYPES
st_CHECK_ENUMS
AC_CHECK_DECLS([sys_errlist])
diff --git a/src/Makefile.am b/src/Makefile.am
index cbb4cfcf7..c938b483d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,7 +33,6 @@ AM_CPPFLAGS = -I$(builddir)/$(OS)/$(ARCH) \
AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD)
AM_CPPFLAGS_FOR_BUILD = $(AM_CPPFLAGS)
-include types/Makemodule.am
include xlat/Makemodule.am
strace_CPPFLAGS = $(AM_CPPFLAGS) -DIN_STRACE=1
@@ -939,8 +938,6 @@ EXTRA_DIST = \
scno.head \
strace-graph \
strace-log-merge \
- types/find_last_type_fields.awk \
- types/gen.sh \
$(XLAT_INPUT_FILES) \
$(XLAT_HEADER_FILES) \
xlat/gen.sh \
diff --git a/src/types/find_last_type_fields.awk b/src/types/find_last_type_fields.awk
deleted file mode 100644
index b9121e88c..000000000
--- a/src/types/find_last_type_fields.awk
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/gawk -f
-#
-# Copyright (c) 2018-2020 Dmitry V. Levin <ldv@strace.io>
-# All rights reserved.
-#
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-/^typedef struct {$/ {
- in_struct = 1
- last_field = ""
- next
-}
-
-(in_struct == 1) {
- if (match($0, /^}( ATTRIBUTE_[^ ]*)* struct_([a-z][a-z_0-9]*);$/, a)) {
- in_struct = 0
- print a[2] "." last_field
- next
- }
- if (match($0, /^[[:space:]]+[^];[:space:]:\/[][^];:[]*[[:space:]]+([^][:space:];:[]+)(\[[^];:[]*\])?;.*$/, a)) {
- last_field = a[1]
- next
- }
-}
diff --git a/src/types/gen.sh b/src/types/gen.sh
deleted file mode 100755
index 019c757e7..000000000
--- a/src/types/gen.sh
+++ /dev/null
@@ -1,209 +0,0 @@
-#!/bin/sh -efu
-#
-# Copyright (c) 2014-2015 Mike Frysinger <vapier@gentoo.org>
-# Copyright (c) 2014-2015 Dmitry V. Levin <ldv@strace.io>
-# Copyright (c) 2014-2020 The strace developers.
-# All rights reserved.
-#
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-[ "x${D:-0}" != x1 ] || set -x
-
-export LC_ALL=C
-
-usage()
-{
- cat <<EOF
-Usage: $0 <input-header> <output-c> <output-m4>
-
-Generate .c and .m4 files from <input-header> (a file or dir of files)
-and write the generated files to <output-c> and <output-m4>.
-EOF
- exit 1
-}
-
-gen_c_check()
-{
- local input output
- input="$1"; shift
- output="$1"; shift
-
- local type_fields
- type_fields="$(gawk -f "${0%/*}/find_last_type_fields.awk" "$input")"
- [ -n "$type_fields" ] || {
- echo >&2 "$input: no types found"
- return 1
- }
-
- echo "generating $output"
- {
- cat <<-EOF
- /* Generated by $0 from $input; do not edit. */
- #include "defs.h"
- #include "static_assert.h"
- #include "types/${input##*/}"
- EOF
- local type_field type field TYPE FIELD
- for type_field in $type_fields; do
- type="${type_field%%.*}"
- field="${type_field#*.}"
- TYPE="$(printf %s "$type" |tr '[:lower:] ' '[:upper:]_')"
- FIELD="$(printf %s "$field" |tr '[:lower:].' '[:upper:]_')"
-
- cat <<-EOF
-
- #ifdef HAVE_STRUCT_$TYPE
- # ifdef HAVE_STRUCT_${TYPE}_$FIELD
- static_assert(sizeof(struct $type) == sizeof(struct_$type),
- "struct $type size mismatch, please update the decoder or fix the kernel");
- # else
- static_assert(sizeof(struct $type) <= offsetof(struct_$type, $field),
- "struct $type size mismatch, please update the decoder or fix the kernel");
- # endif /* HAVE_STRUCT_${TYPE}_$FIELD */
- #endif /* HAVE_STRUCT_$TYPE */
- EOF
- done
- } > "$output"
-}
-
-gen_m4_check()
-{
- local input output macro
- input="$1"; shift
- output="$1"; shift
- macro="$1"; shift
-
- local type_fields
- type_fields="$(gawk -f "${0%/*}/find_last_type_fields.awk" "$input")"
- [ -n "$type_fields" ] || {
- echo >&2 "$input: no types found"
- return 1
- }
-
- local header
- header="$(sed -n 's/^#[[:space:]]*include[[:space:]]\+<\([^>]\+\)>.*/\1/p' "$input" |
- tail -1)"
- [ -n "$header" ] || {
- echo >&2 "$input: no included headers found"
- return 1
- }
-
- local inc_expr1 inc_expr2 includes header_includes
- inc_expr1='s/^#[[:space:]]*include[[:space:]]\+\(<[^>]\+>\).*/#include \1/p'
- inc_expr2='s/^#[[:space:]]*include[[:space:]]\+"\([^"]\+\)".*/#include "\$srcdir\/src\/\1"/p'
- includes="$(sed -n "$inc_expr1; $inc_expr2" "$input")"
- header_includes="$(printf %s "$includes" |sed '$d')"
-
- echo "generating $output"
- {
- cat <<-EOF
- dnl Generated by $0 from $input; do not edit.
- AC_DEFUN([$macro],[
- AC_CHECK_HEADERS([$header],[
- EOF
- local type_field type field
- for type_field in $type_fields; do
- type="${type_field%%.*}"
- field="${type_field#*.}"
- cat <<-EOF
-
- AC_CHECK_TYPES([struct $type],
- [AC_CHECK_MEMBERS([struct $type.$field],,,[AC_INCLUDES_DEFAULT
- $includes])],,[AC_INCLUDES_DEFAULT
- $includes])
- EOF
- done
- cat <<-EOF
- ],[],[AC_INCLUDES_DEFAULT
- $header_includes])])
- EOF
- } > "$output"
-}
-
-gen_m4_entry()
-{
- local output
- output="$1"; shift
- echo "generating $output"
- {
- printf 'AC_DEFUN([st_CHECK_TYPES],[\n'
- printf '\t%s\n' "$@"
- printf '])\n'
- } >"$output"
-}
-
-gen_gitignore()
-{
- local output
- output="$1"; shift
- echo "generating $output"
- {
- printf '/%s\n' .gitignore Makemodule.am st_check_types.m4
- printf '/check-%s.c\n' "$@"
- printf '/check-%s.m4\n' "$@"
- } >"$output"
-}
-
-gen_makefile()
-{
- local output
- output="$1"; shift
- echo "generating $output"
- {
- printf 'TYPES_HEADER_FILES = '
- [ $# -eq 0 ] ||
- printf 'types/%s.h ' "$@"
- echo
- printf 'TYPES_CHECK_FILES = '
- [ $# -eq 0 ] ||
- printf 'types/check-%s.c ' "$@"
- echo
- } >"$output"
-}
-
-process_all()
-{
- local dir
- dir="${0%/*}"
-
- set +f
- set -- "$dir"/*.h
- set -f
-
- local f
- local names= macros=
- for f; do
- [ -f "$f" ] || continue
- local name macro
- name=${f##*/}
- name=${name%.h}
- macro="st_CHECK_TYPES_$(printf %s "$name" |tr '[:lower:].' '[:upper:]_')"
- gen_c_check "$f" "$dir/check-$name.c"
- gen_m4_check "$f" "$dir/check-$name.m4" "$macro"
- names="$names $name"
- macros="$macros $macro"
- done
- gen_m4_entry "$dir/st_check_types.m4" $macros
- gen_gitignore "$dir/.gitignore" $names
- gen_makefile "$dir/Makemodule.am" $names
-}
-
-process_one()
-{
- local input output_c output_m4 name macro
- input="$1"; shift
- output_c="$1"; shift
- output_m4="$1"; shift
-
- name=${input##*/}
- name=${name%.h}
- macro="st_CHECK_TYPES_$(printf %s "$name" |tr '[:lower:].' '[:upper:]_')"
- gen_c_check "$input" "$output_c"
- gen_m4_check "$input" "$output_m4" "$macro"
-}
-
-case $# in
- 0) process_all ;;
- 3) process_one "$@" ;;
- *) usage ;;
-esac