Commit Graph

58 Commits

Author SHA1 Message Date
92e347b556 Add copyright headers to some files that lack them
We do our best to keep copyright headers up to date, yet
git history provides better information on this subject
and is more accurate than copyright headers.
2018-12-24 23:46:43 +00:00
b93d52fe3d Change the license of strace to LGPL-2.1-or-later
strace is now provided under the terms of the GNU Lesser General
Public License version 2.1 or later, see COPYING for more details.

strace test suite is now provided under the terms of the GNU General
Public License version 2 or later, see tests/COPYING for more details.
2018-12-10 00:00:00 +00:00
305e47a9ae build: enable gcc -Woverride-init and clang -Winitializer-overrides
* m4/st_warn_cflags.m4 (gl_WARN_ADD): Add -Winitializer-overrides
and -Woverride-init.
2018-09-16 11:44:01 +00:00
Eugene Syromyatnikov
5c481739d7 m4: move the gawk script from m4/gen_bpf_attr_m4.sh into a separate file
As it turns out, old versions of gawk do not support -e option.

* m4/gen_bpf_attr_m4.sh: Move the gawk script ...
* m4/gen_bpf_attr_m4.awk: ... here.
2018-06-01 13:37:12 +00:00
Eugene Syromyatnikov
9228e78d4f bpf: add support for checking structures outside union bpf_attr
struct bpf_prog_info and bpf_map_info need essentially the same handling
as union bpf_attr.

* gen_bpf_attr_check.sh: Derive type_name from $struct if it doesn't
start with "BPF_", derive TYPE_NAME from type_name, use them in code
generation.
* m4/gen_bpf_attr_m4.sh: Rewrite parsing/generation code into awk,
add support for structures outside union bpf_attr.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-05-28 17:34:50 +00:00
c9ace844ba build: rewrite libdw detection without pkg-config
pkg-config expected to be more convenient way to configure libdw,
but in practice it appeared to be less portable than good old
AC_CHECK_HEADERS and AC_CHECK_LIB.

* ci/install-dependencies.sh (common_packages): Remove pkg-config.
(STACKTRACE == "libdw"): Do not install libz-dev and liblzma-dev.
* debian/control (Build-Depends): Remove pkg-config.
* m4/st_libdw.m4 (st_ARG_LIBDW, st_LIBDW): Rewrite without pkg-config.
2018-05-05 14:38:38 +00:00
Masatake YAMATO
ddb5a4ba73 unwind: add libdw as an unwinder
Implement alternative libdw-based unwinder for stack tracing.
Add --with-libdw configure option to control whether libdw can be used
as an unwinder.

* m4/st_libdw.m4: New file.
* m4/st_stacktrace.m4 (st_STACKTRACE): Invoke st_ARG_LIBDW and st_LIBDW,
check for mutually exclusive configure options,
(AM_CONDITIONAL): Add USE_LIBDW.
* unwind-libdw.c: New file.
* Makefile.am [USE_LIBDW] (strace_SOURCES): Append unwind-libdw.c.
[USE_LIBDW] (strace_CPPFLAGS): Append $(libdw_CPPFLAGS).
[USE_LIBDW] (strace_CFLAGS): Append $(libdw_CFLAGS).
[USE_LIBDW] (strace_LDFLAGS): Append $(libdw_LDFLAGS).
[USE_LIBDW] (strace_LDADD): Append $(libdw_LIBS).
* NEWS: Mention this improvement.

Closes: https://github.com/strace/strace/issues/12
Closes: https://github.com/strace/strace/issues/13
Co-Authored-by: Mark Wielaard <mjw@redhat.com>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2018-04-11 22:01:37 +00:00
2713444cb7 unwind: prepare configure subsystem for alternative unwinders
Introduce --enable-stacktrace configure option to control whether
-k option support is compiled in, --with-libunwind option remains
available to control whether libunwind can be used as an unwinder.

* m4/st_demangle.m4: New file.
* m4/st_libunwind.m4: Likewise.
* m4/st_stacktrace.m4: Likewise.
* configure.ac: Replace all libunwind and libiberty checks
with a single st_STACKTRACE invocation.
* Makefile.am: Conditionalize checks for USE_LIBUNWIND and USE_DEMANGLE
on ENABLE_STACKTRACE.
[ENABLE_STACKTRACE] (strace_SOURCES): Append unwind.c and unwind.h.
* strace.1.in: Replace libunwind with an unwinder-agnostic wording.
* defs.h: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* strace.c: Likewise.
(print_version): Print stack-trace instead of stack-unwind.
* syscall.c: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* tests/Makefile.am: Likewise.  Replace LIBUNWIND_TESTS
with STACKTRACE_TESTS.
* tests/strace-V.test: Update expected output.
2018-04-08 22:01:12 +00:00
Eugene Syromyatnikov
a3509bac24 bpf: add support for array fields
* gen_bpf_attr_check.sh: Ignore field array size definition.
* m4/gen_bpf_attr_m4.sh (filter_entries): Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-04-08 22:01:12 +00:00
442560c875 build: generate all union bpf_attr checks automatically
Rather than list by hand some members of union bpf_attr that we check
for availability, automatically list all members of union bpf_attr we
are aware of.

* m4/gen_bpf_attr_m4.sh: New file.
* bootstrap: Invoke it.
* configure.ac (AC_CHECK_HEADERS([linux/bpf.h])): Use st_BPF_ATTR.
* m4/.gitignore: New file.
2018-04-04 12:24:19 +00:00
63080cac4d mpers.m4: enhance workaround for missing gnu/stubs-*.h files
Make generated empty gnu stub files available for mpers_test.sh check.

* m4/mpers.m4 (st_MPERS): Add $IFLAG to CPPFLAGS for mpers_test.sh
invocation.

Complements: v4.11~223 ("mpers.m4: workaround missing gnu/stubs-*.h files")
2018-03-20 20:44:34 +00:00
0b03de74bc build: prepare for -Wimplicit-fallthrough=5
* gcc_compat.h (ATTRIBUTE_FALLTHROUGH): New macro.
* block.c (block_ioctl): Use it instead of "fall through" comment.
* btrfs.c (btrfs_ioctl): Likewise.
* loop.c (loop_ioctl): Likewise.
* mtd.c (mtd_ioctl): Likewise.
* rtc.c (rtc_ioctl): Likewise.
* v4l2.c (v4l2_ioctl): Likewise.
* dm.c (dm_decode_values): Likewise.
* process.c (SYS_FUNC(ptrace)): Likewise.
* quota.c (decode_cmd_data): Likewise.
* ucopy.c (umovestr): Likewise.
* unwind.c (unwind_print_stacktrace, unwind_capture_stacktrace)):
Likewise.
* term.c (term_ioctl): Add ATTRIBUTE_FALLTHROUGH.
* ioctl.c (ioctl_decode) [ALPHA || POWERPC]: Likewise.
* m4/st_warn_cflags.m4 (gl_WARN_ADD): Add -Wimplicit-fallthrough=5.
* tests/ioctl_v4l2.c (init_v4l2_format): Reorganize the switch statement
without implicit fallthrough.
2018-03-06 23:52:08 +00:00
Eugene Syromyatnikov
3e13994e67 m4/mpers.m4: fix mpers name in comments added to config.h
* m4/mpers.m4 (st_MPERS_STRUCT_STAT): Use mpers_name instead of
MPERS_NAME in comments generated by AC_DEFINE.

Fixes: v4.14~169 ("mpers.m4: check for struct stat64, struct stat, and their members")
2018-02-24 23:06:51 +00:00
daaf8ab7fe Update copyright headers
Headers updated automatically using maint/update_copyright_years.sh
script.
2018-02-13 22:00:00 +00:00
Eugene Syromyatnikov
b2fe2a60ac Add support for --enable-mpers=m32|mx32
* configure.ac (AC_ARG_ENABLE([mpers])): Allow m32 and mx32 values
for --enable-mpers option.
* m4/mpers.m4 (st_MPERS): Check for personality support if personality
name is provided as an option.  Fail if the requested personality
support is not available.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-01-19 17:50:09 +00:00
Eugene Syromyatnikov
558ece68c8 Add support for specifying compiler options for mpers builds
Because some architectures are very, very special.

* configure.ac (cc_flags_m32, cc_flags_mx32): New variables. AC_SUBST
them.
* m4/mpers.m4 (MPERS_CFLAGS): Use instead of CFLAG, pushdef as
$cc_flags_$1.
Use mpers_name instead of CFLAG in AC_CACHE_CHECK messages.
Pass MPERS_CFLAGS as the second argument to mpers_test.sh
* mpers.sh: Add CC_ARCH_FLAGS as the second argument (PARSER_FILE
is moved to the third one). Do not expect leading dash in ARCH_FLAG
anymore.
* mpers_test.sh (mpers_cc_flags): New variable, initialise to the second
command line argument.
Pass $mpers_name without leading dash to mpers.sh.
Pass $mpers_cc_flags as the second argument to mpers.sh ($sample is
the third argument now).
* Makefile.am (mpers-m%.stamp:): Pass $(mpers_CC_FLAGS) as the second
argument to mpers.sh ($$f is now the third argument).
($(mpers_m32_targets)): Define target variable mpers_CC_FLAGS with the
value of @cc_flags_m32@
($(mpers_mx32_targets)): Define target variable mpers_CC_FLAGS with the
value of @cc_flags_mx32@
* tests/Makefile.am (MERS_CC_FLAGS): New variable.
* bootstrap: Append @cc_flags_$1@ to MPERS_CC_FLAGS. Append
$(MPERS_CC_FLAGS) to ARCH_MFLAGS.
2018-01-16 23:02:35 +01:00
Eugene Syromyatnikov
3eb199a29d configure: add --disable-mpers and --enable-mpers=check options
On architectures supporting multiple personalities, multiple
personalities support in strace is required for proper decoding of
structures used by tracees with personalities that differ from the
personality of strace.

New configure options control whether multiple personalities support
in strace is mandatory, optional, or disabled.

The default is changed from what is now equivalent of
--enable-mpers=check (automatically detect whether required mpers
support could be enabled) to --enable-mpers (terminate the build
if required mpers support could not be enabled).

* configure.ac (AC_ARG_ENABLE([mpers])): New option.
* m4/mpers.m4 (st_MPERS): Use enable_mpers.  Terminate the build
if mpers could not be enabled and enable_mpers==yes.
* strace.spec.in: Specify --enable-mpers=check to %configure.
* debian/rules (build/Makefile, build64/Makefile): Specify
--enable-mpers=check to configure.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Suggested-by: DJ Delorie <dj@redhat.com>
2018-01-11 23:09:56 +00:00
acffeae467 mpers: fix cross-compiling
In cross builds, a target version of readelf has to be used
instead of a native one.

* configure.ac (AC_CHECK_TOOL): Add readelf.
* Makefile.am (READELF): New variable.
(mpers-m%.stamp): Pass it to $(srcdir)/mpers.sh.
* m4/mpers.m4 (st_MPERS): Pass READELF environment variable
to $srcdir/mpers_test.sh.
* mpers.sh (READELF): New variable.
Use it instead of readelf.
* maint/ioctls_sym.sh: Likewise.
* NEWS: Mention this fix.

Reported-by: Rolf Eike Beer <eb@emlix.com>
2017-11-25 01:55:44 +00:00
9df60f314d Simplify union bpf_attr field checks
* configure.ac: Use AC_CHECK_MEMBERS instead of st_CHECK_UNION_BPF_ATTR
for union bpf_attr field checks as the former seems to be enough
for the case.
* m4/st_bpf.m4: Remove.
2017-11-21 22:32:31 +00:00
18f69cceeb Update copyright headers
Headers updated semi-automatically using
maint/update_copyright_years.sh script.

* m4/mpers.m4: Update copyright years.
* tests/kcmp.c: Likewise.
* tests/membarrier.c: Likewise.
2017-11-12 00:11:06 +00:00
9517cfa996 mpers.m4: check for size of long and kernel_long_t
The primary purpose of this new check is diagnostics.

* m4/mpers.m4 (st_MPERS): Check for size of long and kernel_long_t.
2017-11-06 19:21:58 +00:00
Eugene Syromyatnikov
dc3dfc68b4 Update copyright headers
Headers updated automatically with

    maint/update_copyright_headers.sh -c
2017-09-05 10:09:10 +02:00
4577bb6c89 m4: macroize union bpf_attr field checks
* m4/st_bpf.m4: New file.
* configure.ac: Use st_CHECK_UNION_BPF_ATTR.
2017-07-26 10:28:25 +00:00
Eugene Syromyatnikov
6f90837382 m4: remove equal sign from define directive in ax_valgrind_check.m4
Support for providing equal sign in define directives has been added
only in GNU Make 3.82 [1] and it provides the same semantics (variables
should be recursively expanded) as when it is omitted at all, so let's
remove it in order to preserve compatibility with older GNU Make
versions (like the one used on Travis).

[1] https://git.savannah.gnu.org/cgit/make.git/tree/ChangeLog?h=3.82#n766

* m4/ax_valgrind_check.m4 <define valgrind_tool_rule>: Remove equal
sign.
2017-07-22 02:09:56 +02:00
6ed39c0fc8 build: add check-valgrind-* to recursive targets
As make -j$N check-valgrind cannot parallelize properly, add
recursive targets for each of valgrind checks.  This way one can run
	for t in $valgrind_enabled_tools; do
		make -k check-valgrind-$n || rc=$?
	done
in $top_builddir.

* configure.ac (AM_EXTRA_RECURSIVE_TARGETS): Remove.
* m4/ax_valgrind_check.m4 (AX_VALGRIND_CHECK): Add check-valgrind
and check-valgrind-* to AM_EXTRA_RECURSIVE_TARGETS.
2017-07-20 22:03:31 +00:00
129c1af897 Update AX_VALGRIND_CHECK
* m4/ax_valgrind_check.m4: Update to serial 15.  In particular,
this version does not eat check-valgrind errors.
2017-07-19 21:29:33 +00:00
acd867117c Update AX_CODE_COVERAGE
* m4/ax_code_coverage.m4: Update to serial 24.  In particular,
this version has no lcov version check.
* Makefile.am (strace_LDADD): Rename CODE_COVERAGE_LDFLAGS
to CODE_COVERAGE_LIBS.
2017-07-19 21:29:33 +00:00
556edf91e3 Enable coverage when strace is self terminated by signal
The data collected by -fprofile-arcs during program run is saved
on program exit.  When program is terminated by signal, the data
is not saved.  However, libgcov provides an interface to dump
the data at runtime.

* m4/ax_code_coverage.m4 (AX_CODE_COVERAGE): Add -DENABLE_COVERAGE_GCOV
to CODE_COVERAGE_CPPFLAGS.
* strace.c [ENABLE_COVERAGE_GCOV] (__gcov_flush): New prototype.
(main) [ENABLE_COVERAGE_GCOV]: Call __gcov_flush() before raise()
and sigprocmask() calls that might cause program termination.
2017-05-27 18:58:31 +00:00
Eugene Syromyatnikov
9d095c7860 Add copyright headers 2017-05-22 17:33:51 +00:00
0fcb3efcf3 m4: fix check-valgrind-* rules generated by AX_VALGRIND_CHECK
* m4/ax_valgrind_check.m4 (check-valgrind-$(1)): Depend
on $(BUILT_SOURCES), honor $(AM_MAKEFLAGS), build check-am
instead of check-TESTS.
2016-12-18 14:09:51 +00:00
Thomas De Schampheleire
a3da3c32c1 Makefile.am: don't confuse CFLAGS and CFLAGS_FOR_BUILD
Commit dc427d50d9 enabled a number of extra
warning flags through configure.ac.  The configure script will determine
dynamically if CC supports these flags before adding them to WARN_CFLAGS.

ioctlsort is compiled with CC_FOR_BUILD, rather than CC.  Nevertheless,
the flags passed to this compilation also include WARN_CFLAGS (through
AM_CFLAGS).  This is incorrect: in a cross-compilation use case, CC
and CC_FOR_BUILD are not the same.  The former is the cross-compiler,
the latter is the host compiler.  Both may be of different versions
and support different warning flags.

In particular, this posed a problem when cross-compiling with a host
compiler gcc 4.1, which does not support all the new flags:

    /usr/bin/gcc -DHAVE_CONFIG_H   -I./linux/arm -I./linux/arm -I./linux
    -I./linux -I. -I. -I/host-sysroot/usr/include -Wall -Wempty-body
    -Wformat-security -Wignored-qualifiers -Winit-self -Wlogical-op
    -Wmissing-parameter-type -Wnested-externs -Wold-style-declaration
    -Wold-style-definition -Wsign-compare -Wtype-limits -Wwrite-strings -O2
    -I/host-sysroot/usr/include -DIOCTLSORT_INC=\"ioctls_all0.h\" -c -o
    ioctlsort0.o ./ioctlsort.c
    cc1: error: unrecognized command line option "-Wempty-body"
    cc1: error: unrecognized command line option "-Wignored-qualifiers"
    cc1: error: unrecognized command line option "-Wlogical-op"
    cc1: error: unrecognized command line option "-Wmissing-parameter-type"
    cc1: error: unrecognized command line option "-Wold-style-declaration"
    cc1: error: unrecognized command line option "-Wtype-limits"
    make[2]: *** [ioctlsort0.o] Error 1

* Makefile.am (AM_CFLAGS_FOR_BUILD, AM_CPPFLAGS_FOR_BUILD): New
variables.
(ioctlsort_CPPFLAGS): Use AM_CPPFLAGS_FOR_BUILD instead of AM_CPPFLAGS.
(ioctlsort_CFLAGS): Use AM_CFLAGS_FOR_BUILD instead of AM_CFLAGS.
(ioctlsort_LDFLAGS): Use AM_LDFLAGS_FOR_BUILD instead of AM_LDFLAGS.
* m4/ax_prog_cc_for_build.m4 (AX_PROG_CC_FOR_BUILD): Redirect
WARN_CFLAGS and gl_unknown_warnings_are_errors, call st_WARN_CFLAGS,
substitute WARN_CFLAGS_FOR_BUILD.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
2016-12-07 15:53:13 +00:00
f91def0384 m4: prepare gl_WARN_ADD for simultaneous use of multiple compilers
* m4/warnings.m4 (gl_COMPILER_OPTION_IF): Change gl_Flags to use
_AC_LANG_PREFIX[]FLAGS in unquoted form.  Change gl_Warn to use gl_Flags
instead of _AC_LANG_ABBREV.  Change notification message to mention
the variable name of the compiler.
(gl_UNKNOWN_WARNINGS_ARE_ERRORS): Do nothing if
gl_unknown_warnings_are_errors is set.
(gl_WARN_ADD): Change the use of gl_UNKNOWN_WARNINGS_ARE_ERRORS from
AC_REQUIRE to a regular call.
2016-12-07 15:53:13 +00:00
cdeb5dda0a AX_PROG_CC_FOR_BUILD: redirect more variables related to C compiler
Some of these variables cannot be redirected using traditional
pushdef/popdef mechanism because of complex constructions like
[ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu] employed by autoconf macros.
Use st_SAVE_VAR/st_RESTORE_VAR to workaround this issue.

* m4/ax_prog_cc_for_build.m4: Redirect ac_cv_prog_cc_stdc,
ac_cv_prog_cc_c11, ac_cv_prog_cc_c99, ac_cv_prog_cc_c89,
am_cv_prog_cc_c_o, and am_cv_CC_dependencies_compiler_type using
pushdef/popdef.
Redirect ac_c_decl_warn_flag, ac_c_preproc_warn_flag, ac_c_werror_flag,
ac_compile, ac_compiler_gnu, ac_cpp, ac_cv_c_compiler_gnu,
ac_cv_c_decl_report, and ac_link using st_SAVE_VAR/st_RESTORE_VAR.
2016-12-07 11:14:03 +00:00
9beaf2c3d3 Move all gl_WARN_ADD calls to a separate m4 macro
This is going to be needed for the upcoming AX_PROG_CC_FOR_BUILD
change.

* configure.ac: Call st_WARN_CFLAGS before AX_PROG_CC_FOR_BUILD.
Move all gl_WARN_ADD calls ...
* m4/st_warn_cflags.m4: ... here.
2016-12-07 10:59:52 +00:00
c26d031c1f m4: introduce st_SAVE_VAR and st_RESTORE_VAR macros
These new macros are going to be needed for the upcoming
AX_PROG_CC_FOR_BUILD change.

* m4/st_save_restore_var.m4: New file.
2016-12-07 10:58:24 +00:00
5c20f4aac4 tests: add valgrind support to "make check"
* m4/ax_valgrind_check.m4: Import from the autoconf-archive package.
* configure.ac: Invoke AX_VALGRIND_CHECK.
* valgrind.supp: Move to tests/strace.supp.
* Makefile.am (EXTRA_DIST): Remove valgrind.supp.
* tests/Makefile.am: Add @VALGRIND_CHECK_RULES@.
(VALGRIND_FLAGS, VALGRIND_SUPPRESSIONS_FILES): New variables.
(EXTRA_DIST): Add strace.supp.
* tests/init.sh: Add valgrind command prefix to $STRACE when appropriate.
2016-12-06 16:20:54 +00:00
c778f7aff6 mpers.m4: check for struct stat64, struct stat, and their members
* m4/mpers.m4 (st_MPERS_STRUCT_STAT): New macro.
(st_MPERS): Use it.
2016-08-24 12:10:55 +00:00
6d3162acf1 Do not enable mpers runtime checks if mpers is not enabled
* m4/mpers.m4 (HAVE_RUNTIME): Enable iff both mpers and runtime
work properly.
2016-07-28 18:32:29 +00:00
c415387157 Update AX_CODE_COVERAGE
* m4/ax_code_coverage.m4: Update to serial 16.
* Makefile.am (CODE_COVERAGE_LCOV_OPTIONS): Remove.
(CODE_COVERAGE_GENHTML_OPTIONS): Update, add prefix.
(CODE_COVERAGE_BRANCH_COVERAGE): Set to 1.
2016-05-10 09:51:56 +00:00
Gabriel Laskar
cba67108a0 Add configure --enable-code-coverage option
* m4/ax_code_coverage.m4: New file.
* configure.ac: Use AX_CODE_COVERAGE.
* Makefile.am: Add @CODE_COVERAGE_RULES@.
(CODE_COVERAGE_LCOV_OPTIONS, CODE_COVERAGE_GENHTML_OPTIONS,
CODE_COVERAGE_IGNORE_PATTERN): New variables.
(strace_CPPFLAGS): Add $(CODE_COVERAGE_CPPFLAGS).
(strace_CFLAGS): Add $(CODE_COVERAGE_CFLAGS).
(strace_LDADD): Add $(CODE_COVERAGE_LDFLAGS).
* .gitignore: Add *.gcda and *.gcno.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2016-02-04 03:36:11 +00:00
38a34c9349 Add copyright headers to some files which lack them
Before this change, all files that exist since 20th century had
copyright headers, while most files that appeared later didn't.  This
change fixes the inconsistency by adding missing copyright headers.

It doesn't mean that copyright headers became maintained.  In my view,
git history provides much better information on this subject and is much
more accurate than copyright headers.
2015-12-17 17:56:48 +00:00
da126fbd77 Replace HAVE_LITTLE_ENDIAN_LONG_LONG with WORDS_BIGENDIAN
* defs.h: Use WORDS_BIGENDIAN instead of HAVE_LITTLE_ENDIAN_LONG_LONG.
* configure.ac (AC_LITTLE_ENDIAN_LONG_LONG): Remove.
* m4/long_long.m4: Remove.
2015-12-14 11:57:59 +00:00
e2a3370f67 mpers.m4: workaround missing gnu/stubs-*.h files
On some systems missing gnu/stubs-*.h files make -m32/-mx32 compilation
checks fail.  As we want to support multiple personalities despite of
this limitation, workaround the check by creating empty gnu stub files
if necessary.

* m4/mpers.m4 (st_MPERS): Check for the gnu stub file.  Create an empty
gnu stub file if the system one is missing.
* Makefile.am (DISTCLEANFILES): Add gnu/stubs-32.h and gnu/stubs-x32.h.
2015-08-28 08:46:24 +00:00
Elvira Khabirova
092942206c Add mpers support
Add a subsystem for semi-automatical definition of how parsers should
work with personality-dependent (mpers) types of tracee's data.  Create
auxiliary libraries containing mpers syscall parsers and printer
functions, one library for each possible nonnative target personality.

Currently some parsers do not handle differences in definitions of data
types between personalities, namely LP64 and ILP32.  When
this is the case, long integers, pointers, and all compound
types containing long and pointer members may be printed incorrectly,
because of differences in sizes, offsets and alignments.

Since in most cases these are the only differences in desired behaviour
of parsers and printers for different personalities, a correct way
would be to compile one source code into multiple parsers, differing
only in definitions of mpers types.

To get a definition of a given type for nonnative personality
a very basic .c file containing a declaration of a variable of this type
is being compiled for this personality (using -m32 or -mx32 compiler
flag).  Information about the type is then being extracted from
this binary's DWARF debug info with an awk script and put
into a corresponding header file.  Resulting headers are being used to
compile mpers variations of syscall parsers and printer functions.

In addition to syscall parsers, there can occur a need to create mpers
printing functions, which then can be called from many places
in the code (for example, printsiginfo_at).  Such functions (printers)
are marked in a special manner.

For each possible nonnative target personality a library is being
created, containing mpers variations of syscall parsers and printers.
Only syscall parsers from files marked in a special manner and specially
marked functions from such files are being recompiled and included
in these libraries.

generate_mpers_am.sh is called by bootstrap to find the files
from strace_SOURCES which include MPERS_DEFS.  During compilation,
these files are being inspected for inclusions of DEF_MPERS_TYPE,
and nonnative variations of each included type are being generated
by an awk script.

Mpers parser names are being modified during inclusions of syscallent
headers for nonnative personalities.  Pointers to printers are
being stored in structs struct_printers, and a master
pointer printers is being updated on every set_personality.

* README-mpers: New README explaining how to use mpers support.
* empty.h: New empty file.
* generate_mpers_am.sh: New file.
* mpers.awk: Likewise.
* mpers.sh: Likewise.
* mpers_test.sh: Likewise.
* mpers_type.h: Likewise.
* Makefile.am (strace_SOURCES): Add empty.h and mpers_type.h.
(strace_CPPFLAGS, strace_LDFLAGS, strace_LDADD): Move to the beginning
of the file.
(strace_LDADD, noinst_LIBRARIES): Add libmpers-%.a.
(EXTRA_DIST): Add mpers.awk, mpers.sh, mpers_test.sh.
(BUILT_SOURCES, CLEANFILES): Add new generated files:
native_printer_decls.h, native_printer_defs.h, printers.h,
[HAVE_M32_MPERS] $(mpers_m32_targets), and [HAVE_MX32_MPERS]
$(mpers_mx32_targets).
(mpers_NAME, mpers_PREFIX, mpers_DEFS, mpers_INCLUDES, mpers_CPPFLAGS,
mpers_sh_opts, libmpers_CPPFLAGS, libmpers_m[x]32_a_SOURCES,
libmpers_m[x]32_a_CPPFLAGS, mpers_m[x]32_targets): New variables.
(mpers-m[x]32.stamp, m[x]32_defs.h, m[x]32_funcs.h, printers.h,
%_printer_decls.h, %_printer_defs.h, clean-local,
native_printer_decls.h, native_printer_defs.h, $mpers_m[x]32_targets):
New targets.
* bootstrap: Add generate_mpers_am.sh.
* configure.ac: Add AC_PROG_RANLIB.
* m4/mpers.m4: Add HAVE_MPERS variable.  Add $st_cv_mpers checks.
* defs.h: Include mpers_type.h.
Include printers.h, native_printer_decls.h, define MPERS_PRINTER_NAME.
Redefine SYS_FUNC_NAME.  Define MPERS_PRINTER_DECL.
[HAVE_M32_MPERS]: define PERSONALITY1_INCLUDE_FUNCS,
PERSONALITY1_INCLUDE_PRINTERS_DECLS, PERSONALITY1_INCLUDE_PRINTERS_DEFS
for X86_64, X32.
[HAVE_MX32_MPERS]: define PERSONALITY2_INCLUDE_FUNCS,
PERSONALITY2_INCLUDE_PRINTERS_DECLS, PERSONALITY2_INCLUDE_PRINTERS_DEFS
for X86_64.
Add fallback definitions of
PERSONALITY1_INCLUDE_FUNCS, PERSONALITY2_INCLUDE_FUNCS,
PERSONALITY0_INCLUDE_PRINTERS_DECLS, PERSONALITY0_INCLUDE_PRINTERS_DEFS,
PERSONALITY1_INCLUDE_PRINTERS_DECLS, PERSONALITY1_INCLUDE_PRINTERS_DEFS,
PERSONALITY2_INCLUDE_PRINTERS_DECLS, PERSONALITY2_INCLUDE_PRINTERS_DEFS.
* syscall.c: Include PERSONALITY1_INCLUDE_FUNCS,
PERSONALITY2_INCLUDE_FUNCS,
PERSONALITY0_INCLUDE_PRINTERS_DECLS, PERSONALITY0_INCLUDE_PRINTERS_DEFS,
PERSONALITY1_INCLUDE_PRINTERS_DECLS, PERSONALITY1_INCLUDE_PRINTERS_DEFS,
PERSONALITY2_INCLUDE_PRINTERS_DECLS, PERSONALITY2_INCLUDE_PRINTERS_DEFS.
(printers): New struct.  Update it when needed.
* .gitignore: Add libmpers-m32.a, libmpers-mx32.a, m32_defs.h,
m32_funcs.h, m32_printer_decls.h, m32_printer_defs.h, mpers-m32,
mpers-m32.stamp, mpers-mx32, mpers-mx32.stamp, mpers.am, mx32_defs.h,
mx32_funcs.h, mx32_printer_decls.h, mx32_printer_defs.h,
native_printer_decls.h, native_printer_defs.h, and printers.h.
2015-08-28 08:46:23 +00:00
f8b49133b7 Macroize -m32/-mx32 configure checks
Prepare for additional configure checks that would be needed
for new multiple personalities support.

* m4/mpers.m4: New file.
* configure.ac: Use it.
2015-07-23 11:39:32 +00:00
Mike Frysinger
58c7fe9903 Fix cross-compiling of ioctlsort
Use the AX_PROG_CC_FOR_BUILD helper to set up build settings when cross
compiling.  This way ioctlsort uses the build tools all the time.

* configure.ac: Call AX_PROG_CC_FOR_BUILD.
* Makefile.am (ioctlsort_CC): Set to CC_FOR_BUILD.
(ioctlsort_CPPFLAGS): Change CPPFLAGS to CPPFLAGS_FOR_BUILD.
(ioctlsort_CFLAGS): Change CFLAGS to CFLAGS_FOR_BUILD.
(ioctlsort_LDFLAGS): Change LDFLAGS to LDFLAGS_FOR_BUILD.
(ioctlsort_LD): Delete.
(ioctlsort%): Change to ioctlsort%$(BUILD_EXEEXT).  Use ioctlsort_CFLAGS.
* m4/ax_prog_cc_for_build.m4: Import from the autoconf-archive package.
2015-02-27 04:43:06 +00:00
174583df28 Update warnings.m4
* m4/warnings.m4: Update from gnulib.
2015-01-21 21:06:10 +00:00
69099e714c configure.ac: remove unused AC_INCLUDEDIR
* configure.ac (AC_INCLUDEDIR): Remove.
* m4/includedir.m4: Remove.
2015-01-21 16:43:18 +00:00
9e6a7bf202 Use AC_CHECK_TYPES to check for struct statfs64
* m4/statfs.m4: Remove.
* configure.ac (AC_STATFS64): Remove.
(AC_CHECK_TYPES): Add struct statfs64.
* statfs.c: Replace HAVE_STATFS64 with HAVE_STRUCT_STATFS64.
2015-01-08 04:12:29 +00:00
7b9bc44e63 Use AC_CHECK_TYPES to check for struct stat64
* m4/stat.m4: Remove.
* configure.ac (AC_STAT64): Remove.
(AC_CHECK_TYPES): Add struct stat64.
* file.c: Replace HAVE_STAT64 with HAVE_STRUCT_STAT64.
2015-01-08 04:06:06 +00:00