[PATCH 3/6] Generate arch_includes.h and arch_personalities.h

Edgar Kaziakhmedov edgar.kaziakhmedov at virtuozzo.com
Sun Dec 10 13:53:19 UTC 2017


Since arch_definitions.h contains full description about architectures,
arch_includes.h and arch_personalities.h can be generated.

* tools/asinfo/gen_asinfo_files.sh: New file.
* bootstrap: Add it.
* tools/asinfo/arch_includes.h: Delete it.
* tools/asinfo/arch_personalities.h: Likewise.
* tools/asinfo/Makefile.am: Include Makemodule.am.
(asinfo_SOURCES): Add $(ARCH_AUX_FILES).
* tools/asinfo/README-arch: New README explaining how to add new
architecture/ABI to asinfo tool.
* tools/asinfo/.gitignore: Add generated files.

Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov at virtuozzo.com>
---
 bootstrap                         |   1 +
 configure.ac                      |   5 +
 tools/asinfo/.gitignore           |   3 +
 tools/asinfo/Makefile.am          |   6 +-
 tools/asinfo/README-arch          |  38 ++++++
 tools/asinfo/arch_includes.h      | 272 ------------------------------------
 tools/asinfo/arch_personalities.h |  36 -----
 tools/asinfo/asinfo.1.in          | 280 ++++++++++++++++++++++++++++++++++++++
 tools/asinfo/gen_asinfo_files.sh  | 160 ++++++++++++++++++++++
 9 files changed, 491 insertions(+), 310 deletions(-)
 create mode 100644 tools/asinfo/README-arch
 delete mode 100644 tools/asinfo/arch_includes.h
 delete mode 100644 tools/asinfo/arch_personalities.h
 create mode 100644 tools/asinfo/asinfo.1.in
 create mode 100755 tools/asinfo/gen_asinfo_files.sh

diff --git a/bootstrap b/bootstrap
index a9cadf53..da06de3b 100755
--- a/bootstrap
+++ b/bootstrap
@@ -4,6 +4,7 @@
 ./xlat/gen.sh
 ./tests/gen_pure_executables.sh
 ./tests/gen_tests.sh
+./tools/asinfo/gen_asinfo_files.sh
 
 for m in m32 mx32; do
 	tests=tests-$m
diff --git a/configure.ac b/configure.ac
index 0492bd8b..79690ba1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,7 @@ AC_INIT([strace],
 	[https://strace.io])
 m4_define([copyright_year], m4_esyscmd([./copyright-year-gen .year]))
 m4_define([manpage_date], m4_esyscmd([./file-date-gen strace.1.in]))
+m4_define([asinfo_manpage_date], m4_esyscmd([./file-date-gen tools/asinfo/asinfo.1.in]))
 AC_COPYRIGHT([Copyright (c) 1999-]copyright_year[ The strace developers.])
 AC_CONFIG_SRCDIR([strace.c])
 AC_CONFIG_AUX_DIR([.])
@@ -67,6 +68,9 @@ AC_SUBST([COPYRIGHT_YEAR], [copyright_year])
 AC_DEFINE([MANPAGE_DATE], "[manpage_date]", [Date])
 AC_SUBST([MANPAGE_DATE], [manpage_date])
 
+AC_DEFINE([ASINFO_MANPAGE_DATE], "[asinfo_manpage_date]", [Date])
+AC_SUBST([ASINFO_MANPAGE_DATE], [asinfo_manpage_date])
+
 AC_MSG_CHECKING([for supported architecture])
 arch_m32=
 arch_mx32=
@@ -904,6 +908,7 @@ AC_CONFIG_FILES([Makefile
 		 tests-mx32/Makefile
 		 strace.1
 		 strace-log-merge.1
+		 tools/asinfo/asinfo.1
 		 tools/Makefile
 		 tools/asinfo/Makefile
 		 strace.spec
diff --git a/tools/asinfo/.gitignore b/tools/asinfo/.gitignore
index 09400c47..3254269c 100644
--- a/tools/asinfo/.gitignore
+++ b/tools/asinfo/.gitignore
@@ -1,2 +1,5 @@
+arch_includes.h
+arch_personalities.h
 asinfo
 asinfo.1
+Makemodule.am
diff --git a/tools/asinfo/Makefile.am b/tools/asinfo/Makefile.am
index 5051766e..f2b23e74 100644
--- a/tools/asinfo/Makefile.am
+++ b/tools/asinfo/Makefile.am
@@ -38,6 +38,9 @@ AM_CPPFLAGS = -I$(builddir) \
 	      -I$(top_srcdir)/$(OS) \
 	      -I$(top_builddir) \
 	      -I$(top_srcdir)
+
+include Makemodule.am
+
 asinfo_CPPFLAGS = $(AM_CPPFLAGS)
 asinfo_CFLAGS = $(AM_CFLAGS)
 asinfo_LDFLAGS =
@@ -47,10 +50,9 @@ asinfo_LDADD = -L$(top_srcdir) \
 
 asinfo_SOURCES =		\
 	arch_definitions.h	\
-	arch_includes.h		\
 	arch_interface.c	\
+	$(ARCH_AUX_FILES)	\
 	arch_interface.h	\
-	arch_personalities.h	\
 	asinfo.c		\
 	dispatchers.c		\
 	dispatchers.h		\
diff --git a/tools/asinfo/README-arch b/tools/asinfo/README-arch
new file mode 100644
index 00000000..6b73aa01
--- /dev/null
+++ b/tools/asinfo/README-arch
@@ -0,0 +1,38 @@
+This file describes the storage format of arch_definitions.h
+
+Storage format:
+/* [ARCH_SPECIFIC_DEFINE],[ACONST1,ACONST2] */
+ARCH_DESC_DEFINE(ARCH_NAME,ARCH_ABI,PASS({COMPAT_PERS1,COMPAT_PERS2,...}),\
+PASS({ALIAS1,ALIAS2,...}))
+
+ARCH_SPECIFIC_DEFINE:
+One syscallent.h header can contain several set of system calls for each
+compatible mode. And specific set can be switched by passing particular
+definition.
+So ARCH_SPECIFIC_DEFINE allows to forward a given definition, where
+!ARCH_SPECIFIC_DEFINE forwards undefined.
+If it is not required, left empty.
+
+ACONST1,ACONST2:
+It could be used to store architecture specific constants and pass them to code.
+If is is not required each one must be set to zero.
+
+ARCH_NAME:
+The main name of architecture will be used to generate the personality
+constants.
+The personality constant is equal to ARCH_+\$ARCH_ABI+_+\$ARCH_NAME.
+
+ARCH_ABI:
+Application binary interface for a given architecture, i.e. 32bit, 64bit, oabi,
+eabi, o32 etc.
+
+COMPAT_PERS1,COMPAT_PERS2,...:
+Compatible mode for a given architecture. It should be one of personality
+constants.
+If is is not required, left empty.
+
+ALIAS1,ALIAS2,...:
+Other name of the same architecture, like x86 and i386. At least one alias
+must to be set as it shows the name of architecture while printing.
+If current ARCH_NAME is just the compatible ABI mode, left empty.
+
diff --git a/tools/asinfo/arch_includes.h b/tools/asinfo/arch_includes.h
deleted file mode 100644
index e73a8328..00000000
--- a/tools/asinfo/arch_includes.h
+++ /dev/null
@@ -1,272 +0,0 @@
-/* ARCH_blackfin */
-static const struct_sysent blackfin_32bit_sysent[] = {
-	#include "bfin/syscallent.h"
-};
-static const int blackfin_32bit_usr1 = 0;
-const int blackfin_32bit_usr2 = 0;
-/* ARCH_ia64 */
-struct_sysent ia64_64bit_sysent[] = {
-	#include "ia64/syscallent.h"
-};
-static const int ia64_64bit_usr1 = 0;
-static const int ia64_64bit_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_m68k */
-static const struct_sysent m68k_32bit_sysent[] = {
-	#include "m68k/syscallent.h"
-};
-static const int m68k_32bit_usr1 = 0;
-static const int m68k_32bit_usr2 = 0;
-/* ARCH_sparc64 64bit ABI */
-static const struct_sysent sparc64_64bit_sysent[] = {
-	#include "sparc64/syscallent.h"
-};
-static const int sparc64_64bit_usr1 = 0;
-static const int sparc64_64bit_usr2 = 0;
-/* ARCH_sparc and 32bit ABI */
-static const struct_sysent sparc_32bit_sysent[] = {
-	#include "sparc/syscallent.h"
-};
-static const int sparc_32bit_usr1 = 0;
-static const int sparc_32bit_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_metag */
-static const struct_sysent metag_32bit_sysent[] = {
-	#include "metag/syscallent.h"
-};
-static const int metag_32bit_usr1 = 0;
-static const int metag_32bit_usr2 = 0;
-/* ARCH_mips n64 ABI */
-#ifndef LINUX_MIPSN64
-# define LINUX_MIPSN64 1
-# define NOW_DEFINED 1
-#endif
-static const struct_sysent mips64_n64_sysent[] = {
-	#include "dummy.h"
-	#include "mips/syscallent-compat.h"
-	#include "mips/syscallent-n64.h"
-};
-#ifdef NOW_DEFINED
-# undef LINUX_MIPSN32
-# undef NOW_DEFINED
-#endif
-static const int mips64_n64_usr1 = 0;
-static const int mips64_n64_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_mips n32 ABI */
-#ifndef LINUX_MIPSN32
-# define LINUX_MIPSN32 1
-# define NOW_DEFINED 1
-#endif
-static const struct_sysent mips64_n32_sysent[] = {
-	#include "dummy.h"
-	#include "mips/syscallent-compat.h"
-	#include "mips/syscallent-n32.h"
-};
-#ifdef NOW_DEFINED
-# undef LINUX_MIPSN32
-# undef NOW_DEFINED
-#endif
-static const int mips64_n32_usr1 = 0;
-static const int mips64_n32_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_mips o32 ABI */
-#ifndef LINUX_MIPSO32
-# define LINUX_MIPSO32 1
-# define NOW_DEFINED 1
-#endif
-static const struct_sysent mips_o32_sysent[] = {
-	#include "dummy.h"
-	#include "mips/syscallent-compat.h"
-	#include "mips/syscallent-o32.h"
-};
-#ifdef NOW_DEFINED
-# undef LINUX_MIPSO32
-# undef NOW_DEFINED
-#endif
-static const int mips_o32_usr1 = 0;
-static const int mips_o32_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_alpha */
-static const struct_sysent alpha_64bit_sysent[] = {
-	#include "alpha/syscallent.h"
-};
-static const int alpha_64bit_usr1 = 0;
-static const int alpha_64bit_usr2 = 0;
-/* ARCH_ppc64 64bit ABI */
-static const struct_sysent ppc64_64bit_sysent[] = {
-	#include "powerpc64/syscallent.h"
-};
-static const int ppc64_64bit_usr1 = 0;
-static const int ppc64_64bit_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_ppc and 32bit */
-static const struct_sysent ppc_32bit_sysent[] = {
-	#include "powerpc/syscallent.h"
-};
-static const int ppc_32bit_usr1 = 0;
-static const int ppc_32bit_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_aarch64 64bit ABI */
-static const struct_sysent aarch64_64bit_sysent[] = {
-	#include "aarch64/syscallent.h"
-};
-static const int aarch64_64bit_usr1 = 0;
-static const int aarch64_64bit_usr2 = 0;
-/* ARCH_arm OABI*/
-#ifdef __ARM_EABI__
-# undef __ARM_EABI__
-# define NOW_UNDEFINED 1
-#endif
-static const struct_sysent arm_oabi_sysent[] = {
-	#include "arm/syscallent.h"
-};
-static const int arm_oabi_usr1 = ARM_FIRST_SHUFFLED_SYSCALL;
-static const int arm_oabi_usr2 = ARM_LAST_SPECIAL_SYSCALL;
-#undef ARM_FIRST_SHUFFLED_SYSCALL
-#undef ARM_LAST_SPECIAL_SYSCALL
-#undef SYS_socket_subcall
-#ifdef NOW_UNDEFINED
-# define __ARM_EABI__ 1
-# undef NOW_UNDEFINED
-#endif
-/* ARCH_arm EABI*/
-#ifndef __ARM_EABI__
-# define __ARM_EABI__ 1
-# define NOW_DEFINED 1
-#endif
-static const struct_sysent arm_eabi_sysent[] = {
-	#include "arm/syscallent.h"
-};
-static const int arm_eabi_usr1 = ARM_FIRST_SHUFFLED_SYSCALL;
-static const int arm_eabi_usr2 = ARM_LAST_SPECIAL_SYSCALL;
-#undef ARM_FIRST_SHUFFLED_SYSCALL
-#undef ARM_LAST_SPECIAL_SYSCALL
-#ifdef NOW_DEFINED
-# undef __ARM_EABI__
-# undef NOW_DEFINED
-#endif
-/* ARCH_avr32 */
-static const struct_sysent avr32_32bit_sysent[] = {
-	#include "avr32/syscallent.h"
-};
-static const int avr32_32bit_usr1 = 0;
-static const int avr32_32bit_usr2 = 0;
-/* ARCH_arc */
-static const struct_sysent arc_32bit_sysent[] = {
-	#include "arc/syscallent.h"
-};
-static const int arc_32bit_usr1 = 0;
-static const int arc_32bit_usr2 = 0;
-/* ARCH_s390x */
-static const struct_sysent s390x_64bit_sysent[] = {
-	#include "s390x/syscallent.h"
-};
-static const int s390x_64bit_usr1 = 0;
-static const int s390x_64bit_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_s390 */
-static const struct_sysent s390_32bit_sysent[] = {
-	#include "s390/syscallent.h"
-};
-static const int s390_32bit_usr1 = 0;
-static const int s390_32bit_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_hppa */
-static const struct_sysent hppa_32bit_sysent[] = {
-	#include "hppa/syscallent.h"
-};
-static const int hppa_32bit_usr1 = 0;
-static const int hppa_32bit_usr2 = 0;
-/* ARCH_sh64 */
-static const struct_sysent sh64_64bit_sysent[] = {
-	#include "sh64/syscallent.h"
-};
-static const int sh64_64bit_usr1 = 0;
-static const int sh64_64bit_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_sh */
-static const struct_sysent sh_32bit_sysent[] = {
-	#include "sh/syscallent.h"
-};
-static const int sh_32bit_usr1 = 0;
-static const int sh_32bit_usr2 = 0;
-/* ARCH_x86_64 64bit ABI mode */
-static const struct_sysent x86_64_64bit_sysent[] = {
-	#include "x86_64/syscallent.h"
-};
-static const int x86_64_64bit_usr1 = 0;
-static const int x86_64_64bit_usr2 = 0;
-/* ARCH_x86_64 x32 ABI mode */
-static const struct_sysent x86_64_x32_sysent[] = {
-	#include "x86_64/syscallent2.h"
-};
-static const int x86_64_x32_usr1 = 0;
-static const int x86_64_x32_usr2 = 0;
-/* ARCH_x86 */
-static const struct_sysent x86_32bit_sysent[] = {
-	#include "i386/syscallent.h"
-};
-static const int x86_32bit_usr1 = 0;
-static const int x86_32bit_usr2 = 0;
-/* ARCH_cris */
-static struct_sysent cris_32bit_sysent[] = {
-	#include "crisv10/syscallent.h"
-};
-static const int cris_32bit_usr1 = 0;
-static const int cris_32bit_usr2 = 0;
-/* ARCH_crisv32 */
-static const struct_sysent crisv32_32bit_sysent[] = {
-	#include "crisv32/syscallent.h"
-};
-static const int crisv32_32bit_usr1 = 0;
-static const int crisv32_32bit_usr2 = 0;
-#undef SYS_socket_subcall
-/* ARCH_tile 64bit ABI mode */
-static const struct_sysent tile_64bit_sysent[] = {
-	#include "tile/syscallent.h"
-};
-static const int tile_64bit_usr1 = 0;
-static const int tile_64bit_usr2 = 0;
-/* ARCH_tile 32bit ABI mode */
-static const struct_sysent tile_32bit_sysent[] = {
-	#include "tile/syscallent1.h"
-};
-static const int tile_32bit_usr1 = 0;
-static const int tile_32bit_usr2 = 0;
-/* ARCH_microblaze */
-static const struct_sysent microblaze_32bit_sysent[] = {
-	#include "microblaze/syscallent.h"
-};
-static const int microblaze_32bit_usr1 = 0;
-static const int microblaze_32bit_usr2 = 0;
-/* ARCH_nios2 */
-static const struct_sysent nios2_32bit_sysent[] = {
-	#include "nios2/syscallent.h"
-};
-static const int nios2_32bit_usr1 = 0;
-static const int nios2_32bit_usr2 = 0;
-/* ARCH_openrisc */
-struct_sysent openrisc_32bit_sysent[] = {
-	#include "or1k/syscallent.h"
-};
-static const int openrisc_32bit_usr1 = 0;
-static const int openrisc_32bit_usr2 = 0;
-/* ARCH_xtensa */
-static const struct_sysent xtensa_32bit_sysent[] = {
-	#include "xtensa/syscallent.h"
-};
-static const int xtensa_32bit_usr1 = 0;
-static const int xtensa_32bit_usr2 = 0;
-/* ARCH_riscv 64bit ABI mode */
-static const struct_sysent riscv_64bit_sysent[] = {
-	#include "riscv/syscallent.h"
-};
-static const int riscv_64bit_usr1 = 0;
-static const int riscv_64bit_usr2 = 0;
-/* ARCH_riscv 32bit ABI mode */
-static const struct_sysent riscv_32bit_sysent[] = {
-	#include "riscv/syscallent1.h"
-};
-static const int riscv_32bit_usr1 = 0;
-static const int riscv_32bit_usr2 = 0;
diff --git a/tools/asinfo/arch_personalities.h b/tools/asinfo/arch_personalities.h
deleted file mode 100644
index 9499c5aa..00000000
--- a/tools/asinfo/arch_personalities.h
+++ /dev/null
@@ -1,36 +0,0 @@
-ARCH_no_pers,
-ARCH_blackfin_32bit,
-ARCH_ia64_64bit,
-ARCH_m68k_32bit,
-ARCH_sparc64_64bit,
-ARCH_sparc_32bit,
-ARCH_metag_32bit,
-ARCH_mips64_n64,
-ARCH_mips64_n32,
-ARCH_mips_o32,
-ARCH_alpha_64bit,
-ARCH_ppc64_64bit,
-ARCH_ppc_32bit,
-ARCH_aarch64_64bit,
-ARCH_arm_oabi,
-ARCH_arm_eabi,
-ARCH_avr32_32bit,
-ARCH_arc_32bit,
-ARCH_s390x_64bit,
-ARCH_s390_32bit,
-ARCH_hppa_32bit,
-ARCH_sh64_64bit,
-ARCH_sh_32bit,
-ARCH_x86_64_64bit,
-ARCH_x86_64_x32,
-ARCH_x86_32bit,
-ARCH_cris_32bit,
-ARCH_crisv32_32bit,
-ARCH_tile_64bit,
-ARCH_tile_32bit,
-ARCH_microblaze_32bit,
-ARCH_nios2_32bit,
-ARCH_openrisc_32bit,
-ARCH_xtensa_32bit,
-ARCH_riscv_64bit,
-ARCH_riscv_32bit
diff --git a/tools/asinfo/asinfo.1.in b/tools/asinfo/asinfo.1.in
new file mode 100644
index 00000000..009c69ed
--- /dev/null
+++ b/tools/asinfo/asinfo.1.in
@@ -0,0 +1,280 @@
+.\" Copyright (c) 2017 Edgar Kaziakhmedov <edgar.kaziakhmedov at virtuozzo.com>
+.\" Copyright (c) 1996-2017 The strace developers.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. The name of the author may not be used to endorse or promote products
+.\"    derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+.\" Required option.
+.de OR
+.  ie \\n(.$-1 \
+.    RI "\fB\\$1\fP" "\ \\$2"
+.  el \
+.    BR "\\$1"
+..
+.TH ASINFO 1 "@ASINFO_MANPAGE_DATE@" "strace package @VERSION@"
+.SH NAME
+asinfo \- advanced system call information tool
+.SH SYNOPSIS
+.SY asinfo
+.BR "" \fR[{
+.OR \-\-set\-arch arch
+.BR "" |
+.OR \-\-get\-arch
+.BR "" }
+.OR \fR[\fP\-\-set\-abi abi
+.BR "" |
+.OR \-\-list\-abi\fR]\fR]
+.BR "" {
+.BR "" {
+.OR \-\-get\-sname expr
+.BR "" |
+.OR \-\-get\-snum expr
+.BR "" }
+.OP \-\-nargs
+.BR "" }
+.OP "\-\-raw"
+.YS
+.SY asinfo
+.BR "" {
+.OR \-\-set\-arch arch
+.BR "" |
+.OR \-\-get\-arch
+.BR "" |
+.OR \-\-list\-arch
+.BR "" }
+.BD "" [
+.OR \fR[\fP\-\-set\-abi abi
+.BR "" |
+.OR \-\-list\-abi\fR]
+.OP "\-\-raw"
+
+.SH DESCRIPTION
+.B asinfo
+is a useful tool, which aimed to provide information about system calls,
+architectures, and application binary interfaces (ABIs). In the simplest
+case it provides mapping from system call name to number and reverse.
+The main advantage of tool is it can work in single/multi arch modes with
+the opportunity to show discrepancies in system call characteristics.
+Also, the single arch mode allows program to take a guess about the
+current architecture and ABI, if they are not specified. Furthermore,
+.B asinfo
+provides convenient filtering for selecting system calls.
+
+.SH OPTIONS
+.SS "Architecture parameters"
+.TP 7
+.BI "\-\-set\-arch " arch
+Specify architecture/architectures manually. The format of the
+.I arch
+expression is:
+.RS 9
+.IP
+\fIarch1\/\fR[\fB,\fIarch2\/\fR]...
+.RE
+.IP
+.TP
+.B \-\-get\-arch
+Select achitecture based on the current machine.
+.TP
+.B \-\-list-arch
+Print out all supported architectures.
+Combined use with any ABI option is permitted.
+.SS "ABI parameters"
+.TP 7
+.BI "\-\-set\-abi " abi
+Specify ABI/ABIs manually. The format of the experession is:
+.RS 9
+.IP
+\fIabi1\/\fR[\fB,\fIabi2\/\fR]...
+.RE
+.IP
+.IP
+Note that ABI should be selected for each corresponding architecture.
+In addition, the special value
+.B all
+allows to choose all ABIs for the respective architecture.
+.TP
+.B "\-\-list\-abi "
+Select all ABIs for the chosen architecture/architectures.
+.IP
+If ABI parameters are not used and only single architecture is selected, tool
+will take a guess about ABI based on the strace package build.
+.SS "System call parameters"
+.TP 7
+.BI "\-\-get\-sname " expr
+Select system calls that satisfy a filtering expression
+.I
+expr
+and print out name of system calls and numbers for each architecture/ABI.
+.TP
+.BI "\-\-get\-snum " expr
+Select system calls that satisfy a filtering expression
+.I
+expr
+and print out number of system calls and names for each architecture/ABI.
+.TP
+.B \-\-nargs
+Switch the second output system call characteristic to number of arguments.
+.SS Output formatting
+.TP 7
+.B "\-\-raw"
+Reset alignment and remove titles, use ';' as a delimiter.
+.SS Miscellaneous
+.TP 7
+.B \-h
+Print the help summary.
+.TP
+.B \-v
+Print the version number.
+
+.SH "FILTERING EXPRESSION"
+A filtering expression is a pattern that describes a set of syscall names,
+syscall numbers, and syscall group. The format of the expression is:
+.RS 2
+.IP
+[\fB!\fR][\fB?\fR]\,\fIvalue1\/\fR[\fB,\fR[\fB?\fR]\,\fIvalue2\/\fR]...
+.RE
+.LP
+where
+.I value
+is a symbol or number. Using an exclamation mark negates the set of values.
+For example,
+.BR \fIvalue\fR = write
+means print strictly the write system call.  By contrast,
+.BR \fIvalue\fR = !write
+means to dump every system call except write. Question mark before the
+syscall qualification allows suppression of error in case no syscalls matched
+the qualification provided, that can be particularly useful in multiarch mode,
+when system call is not presented in all selected architectures. In addition,
+the special values
+.B all
+and
+.B none
+have the obvious meanings.
+.LP
+Note that some shells use the exclamation point for history
+expansion even inside quoted arguments.  If so, you must escape
+the exclamation point with a backslash.
+.SS "Strict match"
+.TP 7
+.B \fIvalue\fR=\,\fIset\fR
+Print out only the specified set of system calls. For example,
+.BR \fIvalue\fR = open,close,read,write
+means to only show those four system calls.
+.SS "Regex match"
+.TP 7
+.B \fIvalue\fR=/\,\fIregex\fR
+Show only those system calls that match the
+.IR regex .
+You can use
+.B POSIX
+Extended Regular Expression syntax (see
+.BR regex (7)).
+.SS "Class match"
+.TP 7
+.BR \fIvalue\fR = %file
+.TQ
+.BR \fIvalue\fR  = file " (deprecated)"
+Show all system calls which take a file name as an argument.  You
+can think of this as an abbreviation for
+.BR \fIvalue\fR = open,stat,chmod,unlink,...
+Furthermore, using the abbreviation will ensure that you don't
+accidentally forget to include a call like
+.B lstat
+in the list.
+.PP
+.BR \fIvalue\fR = %process
+.TQ
+.BR \fIvalue\fR = process " (deprecated)"
+Show all system calls which involve process management.
+.PP
+.BR \fIvalue\fR = %network
+.TQ
+.BR \fIvalue\fR = network " (deprecated)"
+Show all the network related system calls.
+.PP
+.BR \fIvalue\fR = %signal
+.TQ
+.BR \fIvalue\fR = signal " (deprecated)"
+Show all signal related system calls.
+.PP
+.BR \fIvalue\fR = %ipc
+.TQ
+.BR \fIvalue\fR = ipc " (deprecated)"
+Show all IPC related system calls.
+.PP
+.BR \fIvalue\fR = %desc
+.TQ
+.BR \fIvalue\fR = desc " (deprecated)"
+Show all file descriptor related system calls.
+.PP
+.BR \fIvalue\fR = %memory
+.TQ
+.BR \fIvalue\fR = memory " (deprecated)"
+Show all memory mapping related system calls.
+.TP
+.BR \fIvalue\fR = %stat
+Show stat syscall variants.
+.TP
+.BR \fIvalue\fR = %lstat
+Show lstat syscall variants.
+.TP
+.BR \fIvalue\fR = %fstat
+Show fstat and fstatat syscall variants.
+.TP
+.BR \fIvalue\fR = %%stat
+Show syscalls used for requesting file status (stat, lstat, fstat, fstatat,
+statx, and their variants).
+.TP
+.BR \fIvalue\fR = %statfs
+Show statfs, statfs64, statvfs, osf_statfs, and osf_statfs64 system calls.
+The same effect can be achieved with
+.BR \fIvalue\fR = /^(.*_)?statv?fs
+regular expression.
+.TP
+.BR \fIvalue\fR = %fstatfs
+Show fstatfs, fstatfs64, fstatvfs, osf_fstatfs, and osf_fstatfs64 system calls.
+The same effect can be achieved with
+.BR \fIvalue\fR = /fstatv?fs
+regular expression.
+.TP
+.BR \fIvalue\fR = %%statfs
+Show syscalls related to file system statistics (statfs-like, fstatfs-like,
+and ustat).  The same effect can be achieved with
+.BR \fIvalue\fR = /statv?fs|fsstat|ustat
+regular expression.
+
+.SH "EXIT STATUS"
+On success,
+.B asinfo
+returns 0. Otherwise, in case of wrong input or no matches found, 1.
+
+.SH "REPORTING BUGS"
+Problems with
+.B asinfo
+should be reported to the
+.B strace
+mailing list at <strace-devel at lists.sourceforge.net>.
+
+.SH "SEE ALSO"
+.BR strace (1)
diff --git a/tools/asinfo/gen_asinfo_files.sh b/tools/asinfo/gen_asinfo_files.sh
new file mode 100755
index 00000000..bd7b33ae
--- /dev/null
+++ b/tools/asinfo/gen_asinfo_files.sh
@@ -0,0 +1,160 @@
+#!/bin/sh
+#
+# Code generator simplifies addition of new architecture to asinfo tool
+#
+# Copyright (c) 2017 Edgar A. Kaziakhmedov <edgar.kaziakhmedov at virtuozzo.com>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+#    derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+cur_pers=""
+
+gen_pers_line()
+{
+	local out_file="$1"
+	local line="$2"
+	local arch_abi=""
+
+	LC_COLLATE=C
+	arch_abi="$(printf %s "${line}" |
+		    sed 's/ARCH_DESC_DEFINE(//' | cut -d, -f 1,2 |
+		    sed 's/,/_/g')"
+	cur_pers="${arch_abi}"
+	echo "ARCH_${arch_abi}," >> "${out_file}"
+}
+
+gen_includes_block()
+{
+	local out_file="$1"
+	local line="$2"
+	local def is_def includes include nums num count
+
+	(
+	LC_COLLATE=C
+	echo "/* ${cur_pers} */"
+	def="$(printf %s "${line#*\*}" | cut -d] -f 1 | sed 's/.*[][]//g')"
+	#Generate define construction
+	if [ "${def#!}" != "" ] && [ $(printf %.1s "${def}") = "!" ]; then
+		cat <<-EOF
+		#ifdef ${def#!}
+		# undef ${def#!}
+		# define ${def#!}_DUMMY_UNDEFINE
+		#endif
+		EOF
+		is_def="def"
+	else if [ "${def#!}" != "" ]; then
+		cat <<-EOF
+		#ifndef ${def}
+		# define ${def}
+		# define ${def}_DUMMY_DEFINE
+		#endif
+		EOF
+		is_def="undef"
+	fi
+	fi
+	#Generate includes
+	includes="$(printf %s "${line#*\*}" | cut -d] -f 2 | sed 's/.*[][]//g')"
+	echo "static const struct_sysent ${cur_pers}_sysent[] = {"
+	for include in $(echo "${includes}" | sed "s/,/ /g")
+	do
+		echo "	#include \"${include}\""
+	done
+	echo "};"
+	#Undefine definitions, if it is required
+	if [ "${is_def}" = "def" ]; then
+		cat <<-EOF
+		#ifdef ${def#!}_DUMMY_UNDEFINE
+		# define ${def#!} 1
+		# undef ${def#!}_DUMMY_UNDEFINE
+		#endif
+		EOF
+	else if [ "${is_def}" = "undef" ]; then
+		cat <<-EOF
+		#ifdef ${def#!}_DUMMY_DEFINE
+		# undef ${def#!}
+		# undef ${def#!}_DUMMY_DEFINE
+		#endif
+		EOF
+	fi
+	fi
+	#Generate arch specific numbers
+	nums="$(printf %s "${line#*\*}" | cut -d] -f 3 | sed 's/.*[][]//g')"
+	count=1
+	for num in $(echo "${nums}" | sed "s/,/ /g")
+	do
+		echo "static const int ${cur_pers}_usr${count} = ${num};"
+		count=$((count+1))
+		case "${num}" in
+		*[A-Za-z_]*) echo "#undef ${num}" ;;
+		*) ;;
+		esac
+	done
+	if [ $count -eq 1 ]; then
+		echo "static const int ${cur_pers}_usr${count} = 0;"
+	fi
+	echo "#undef SYS_socket_subcall"
+	) >> "${out_file}"
+	echo "${def}" >> "${out_file}"
+}
+
+main()
+{
+	set -- "${0%/*}" "${0%/*}"
+
+	local input="$1"
+	local output="$2"
+	local defs_file="arch_definitions.h"
+	local pers_file="arch_personalities.h"
+	local includes_file="arch_includes.h"
+	local pline=""
+
+	echo "ARCH_no_pers," > "${output}/${pers_file}"
+	echo -n > "${output}/${includes_file}"
+
+	#Main work
+	while read line; do
+		line="$(printf %s "${line}" | sed 's/[[:space:]]//g')"
+		if $(printf %s "${line}" |
+		     grep -F "ARCH_DESC_DEFINE" > /dev/null); then
+			gen_pers_line "${output}/${pers_file}" "${line}"
+		fi
+		if $(printf %s "${pline}" | grep -F "/*" > /dev/null); then
+			gen_includes_block "${output}/${includes_file}"\
+					   "${pline}"
+		fi
+		pline="${line}"
+	done < "${input}/${defs_file}"
+	#Makemodule.am
+	(
+	printf "ARCH_AUX_FILES = ${includes_file} ${pers_file}"
+	echo
+	printf '\$(top_srcdir)/tools/asinfo/%s: \$(top_srcdir)/tools/asinfo/%s \$(top_srcdir)/tools/asinfo/gen_asinfo_files.sh' "${includes_file}" "${defs_file}"
+	echo
+	echo '	\$(AM_V_GEN)\$(top_srcdir)/tools/asinfo/gen_asinfo_files.sh'
+	printf '\$(top_srcdir)/tools/asinfo/%s: \$(top_srcdir)/tools/asinfo/%s \$(top_srcdir)/tools/asinfo/gen_asinfo_files.sh' "${pers_file}" "${defs_file}"
+	echo
+	echo '	\$(AM_V_GEN)\$(top_srcdir)/tools/asinfo/gen_asinfo_files.sh'
+	) > "${output}/Makemodule.am"
+}
+
+main "$@"
-- 
2.11.0





More information about the Strace-devel mailing list