1999-02-19 03:21:36 +03:00
/*
* Copyright ( c ) 1991 , 1992 Paul Kranenburg < pk @ cs . few . eur . nl >
* Copyright ( c ) 1993 Branko Lankester < branko @ hacktic . nl >
* Copyright ( c ) 1993 , 1994 , 1995 , 1996 Rick Sladkey < jrs @ world . std . com >
1999-12-23 17:20:14 +03:00
* Copyright ( c ) 1996 - 1999 Wichert Akkerman < wichert @ cistron . nl >
* Copyright ( c ) 1999 IBM Deutschland Entwicklung GmbH , IBM Corporation
* Linux for s390 port by D . J . Barrow
* < barrow_dj @ mail . yahoo . com , djbarrow @ de . ibm . com >
1999-02-19 03:21:36 +03:00
* 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 .
*/
# include "defs.h"
2015-09-16 00:51:15 +03:00
# include "native_defs.h"
1999-02-19 03:21:36 +03:00
# include <sys/param.h>
2016-01-12 03:04:30 +03:00
# include <signal.h>
1999-06-24 17:55:29 +04:00
2015-02-13 05:12:14 +03:00
/* for struct iovec */
# include <sys/uio.h>
2014-10-20 03:02:48 +04:00
2015-02-28 15:20:21 +03:00
# include "regs.h"
2015-02-13 03:26:38 +03:00
# include "ptrace.h"
1999-07-14 02:20:16 +04:00
2012-02-25 05:38:52 +04:00
# if defined(SPARC64)
2004-07-07 David S. Miller <davem@nuts.davemloft.net>
* linux/sparc/syscallent.h: Sync with reality.
* linux/sparc/syscall.h (sys_sendfile64, sys_futex, sys_gettid,
sys_sched_setaffinity, sys_sched_getaffinity, sys_setxattr,
sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr,
sys_fgetxattr, sys_listxattr, sys_llistxattr, sys_flistxattr,
sys_removexattr, sys_lremovexattr, sys_fremovexattr,
sys_remap_file_pages, sys_readahead, sys_tgkill, sys_statfs64,
sys_fstatfs64, sys_clock_settime, sys_clock_gettime,
sys_clock_getres, sys_clock_nanosleep, sys_timer_create,
sys_timer_settime, sys_timer_gettime): New declarations.
* linux/sparc64/dummy2.h, linux/sparc64/syscallent2.h,
linux/sparc64/syscall.h, linux/sparc64/errnoent.h,
linux/sparc64/errnoent1.h, linux/sparc64/errnoent2.h,
linux/sparc64/ioctlent.h, linux/sparc64/ioctlent1.h,
linux/sparc64/ioctlent2.h, linux/sparc64/signalent.h,
linux/sparc64/signalent.h, linux/sparc64/signalent.h,
linux/sparc64/signalent1.h, linux/sparc64/signalent2.h,
linux/sparc64/syscall1.h, linux/sparc64/syscallent.h,
linux/sparc64/syscallent1.h: New files.
* defs.h (LINUXSPARC): Define also when SPARC64.
(LINUX && SPARC64): Set SUPPORTED_PERSONALITIES to 3.
Ignore SIGTRAP after execve by defining TCB_WAITEXECVE.
Define possibly missing __NR_exit_group. Declare getrval2.
* configure.ac (sparc64): New architecture case.
* config.h.in (SPARC64): New define.
* file.c (stat_sparc64): New structure.
(printstat_sparc64): New output routine for that.
(printstat): Call it, if personality is 2.
(printstat64): Likewise.
* util.c: Conditionalize ptrace defines on LINUXSPARC
not LINUX && SPARC.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(_hack_syscall5): Correct trap number when SPARC64.
(PTRACE_WRITE{TEXT,DATA}): Add SPARC64 to ifdef guard.
(getpc): Handle SPARC64 && LINUX.
(printcall): Likewise.
(arg fetching/setting): Use same code for SPARC64 LINUX
as for SPARC.
(setbpt): Handle SPARC64 && LINUX.
(clearbpt): Likewise.
* signal.c: Conditionalize ptrace defines on SPARC and
SPARC64.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(m_siginfo): Use same definition on SPARC64 as SPARC.
(sys_sigreturn): Handle LINUX && SPARC64.
* syscall.c: Conditionalize ptrace defines on SPARC and
SPARC64.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(getscno): Use same static state on SPARC64 as SPARC,
and add SPARC64 handling.
(get_error): Handle LINUX && SPARC64.
(force_result): Likewise.
(syscall_enter): Likewise.
(trace_syscall): Handle sys_socketcall and sys_ipc on SPARC64
just like SPARC.
(getrval2): Handle LINUX && SPARC64.
* process.c: Conditionalize ptrace defines on SPARC and
SPARC64.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(change_syscall): Handle LINUX && SPARC64.
(struct_user_offsets): Ifdef out those which do not exist
on SPARC64.
* net.c (sys_pipe): Handle LINUX && SPARC64.
* ioctl.c: Fix initializer typo for nioctlents2, was
nioctlents1 by accident.
2004-07-12 11:44:08 +04:00
# undef PTRACE_GETREGS
# define PTRACE_GETREGS PTRACE_GETREGS64
# undef PTRACE_SETREGS
# define PTRACE_SETREGS PTRACE_SETREGS64
2012-02-25 05:38:52 +04:00
# endif
2004-07-07 David S. Miller <davem@nuts.davemloft.net>
* linux/sparc/syscallent.h: Sync with reality.
* linux/sparc/syscall.h (sys_sendfile64, sys_futex, sys_gettid,
sys_sched_setaffinity, sys_sched_getaffinity, sys_setxattr,
sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr,
sys_fgetxattr, sys_listxattr, sys_llistxattr, sys_flistxattr,
sys_removexattr, sys_lremovexattr, sys_fremovexattr,
sys_remap_file_pages, sys_readahead, sys_tgkill, sys_statfs64,
sys_fstatfs64, sys_clock_settime, sys_clock_gettime,
sys_clock_getres, sys_clock_nanosleep, sys_timer_create,
sys_timer_settime, sys_timer_gettime): New declarations.
* linux/sparc64/dummy2.h, linux/sparc64/syscallent2.h,
linux/sparc64/syscall.h, linux/sparc64/errnoent.h,
linux/sparc64/errnoent1.h, linux/sparc64/errnoent2.h,
linux/sparc64/ioctlent.h, linux/sparc64/ioctlent1.h,
linux/sparc64/ioctlent2.h, linux/sparc64/signalent.h,
linux/sparc64/signalent.h, linux/sparc64/signalent.h,
linux/sparc64/signalent1.h, linux/sparc64/signalent2.h,
linux/sparc64/syscall1.h, linux/sparc64/syscallent.h,
linux/sparc64/syscallent1.h: New files.
* defs.h (LINUXSPARC): Define also when SPARC64.
(LINUX && SPARC64): Set SUPPORTED_PERSONALITIES to 3.
Ignore SIGTRAP after execve by defining TCB_WAITEXECVE.
Define possibly missing __NR_exit_group. Declare getrval2.
* configure.ac (sparc64): New architecture case.
* config.h.in (SPARC64): New define.
* file.c (stat_sparc64): New structure.
(printstat_sparc64): New output routine for that.
(printstat): Call it, if personality is 2.
(printstat64): Likewise.
* util.c: Conditionalize ptrace defines on LINUXSPARC
not LINUX && SPARC.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(_hack_syscall5): Correct trap number when SPARC64.
(PTRACE_WRITE{TEXT,DATA}): Add SPARC64 to ifdef guard.
(getpc): Handle SPARC64 && LINUX.
(printcall): Likewise.
(arg fetching/setting): Use same code for SPARC64 LINUX
as for SPARC.
(setbpt): Handle SPARC64 && LINUX.
(clearbpt): Likewise.
* signal.c: Conditionalize ptrace defines on SPARC and
SPARC64.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(m_siginfo): Use same definition on SPARC64 as SPARC.
(sys_sigreturn): Handle LINUX && SPARC64.
* syscall.c: Conditionalize ptrace defines on SPARC and
SPARC64.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(getscno): Use same static state on SPARC64 as SPARC,
and add SPARC64 handling.
(get_error): Handle LINUX && SPARC64.
(force_result): Likewise.
(syscall_enter): Likewise.
(trace_syscall): Handle sys_socketcall and sys_ipc on SPARC64
just like SPARC.
(getrval2): Handle LINUX && SPARC64.
* process.c: Conditionalize ptrace defines on SPARC and
SPARC64.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(change_syscall): Handle LINUX && SPARC64.
(struct_user_offsets): Ifdef out those which do not exist
on SPARC64.
* net.c (sys_pipe): Handle LINUX && SPARC64.
* ioctl.c: Fix initializer typo for nioctlents2, was
nioctlents1 by accident.
2004-07-12 11:44:08 +04:00
2015-02-13 05:12:14 +03:00
# if defined SPARC64
# include <asm / psrcompat.h>
# elif defined SPARC
# include <asm / psr.h>
2013-02-14 06:29:48 +04:00
# endif
2015-03-06 02:30:02 +03:00
# ifdef IA64
# include <asm / rse.h>
# endif
2015-02-14 01:53:00 +03:00
# ifndef NT_PRSTATUS
# define NT_PRSTATUS 1
# endif
1999-02-19 03:21:36 +03:00
# ifndef NSIG
2012-02-25 05:44:25 +04:00
# warning: NSIG is not defined, using 32
# define NSIG 32
1999-02-19 03:21:36 +03:00
# endif
# include "syscall.h"
/* Define these shorthand notations to simplify the syscallent files. */
2005-07-05 07:25:35 +04:00
# define TD TRACE_DESC
1999-02-19 03:21:36 +03:00
# define TF TRACE_FILE
# define TI TRACE_IPC
# define TN TRACE_NETWORK
# define TP TRACE_PROCESS
# define TS TRACE_SIGNAL
Add -e trace=memory option
Add a new 'memory' category for tracing memory mapping related syscalls.
Affected syscalls are: break, brk, get_mempolicy, madvise, mbind,
migrate_pages, mincore, mlock, mlockall, mmap, move_pages, mprotect,
mremap, msync, munlock, munlockall, munmap, remap_file_pages, and
set_mempolicy.
* defs.h (TRACE_MEMORY): New macro.
* syscall.c (lookup_class): Handle trace=memory option.
* strace.1: Document it.
* linux/alpha/syscallent.h: Add TM flag to memory mapping related syscalls.
* linux/arm/syscallent.h: Likewise.
* linux/avr32/syscallent.h: Likewise.
* linux/bfin/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/tile/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
2012-10-24 06:41:57 +04:00
# define TM TRACE_MEMORY
2011-01-18 20:36:20 +03:00
# define NF SYSCALL_NEVER_FAILS
2011-08-23 15:24:17 +04:00
# define MA MAX_ARGS
2014-04-16 10:33:11 +04:00
# define SI STACKTRACE_INVALIDATE_CACHE
# define SE STACKTRACE_CAPTURE_ON_ENTER
1999-02-19 03:21:36 +03:00
2015-12-15 21:32:17 +03:00
# define SEN(syscall_name) SEN_ ## syscall_name, SYS_FUNC_NAME(sys_ ## syscall_name)
2015-07-10 22:24:48 +03:00
2013-02-22 16:37:36 +04:00
const struct_sysent sysent0 [ ] = {
1999-02-19 03:21:36 +03:00
# include "syscallent.h"
} ;
2013-02-22 16:26:10 +04:00
# if SUPPORTED_PERSONALITIES > 1
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-04 01:47:02 +03:00
# include PERSONALITY1_INCLUDE_FUNCS
2013-02-22 16:26:10 +04:00
static const struct_sysent sysent1 [ ] = {
2012-02-25 05:44:25 +04:00
# include "syscallent1.h"
1999-02-19 03:21:36 +03:00
} ;
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
# endif
1999-02-19 03:21:36 +03:00
2013-02-22 16:26:10 +04:00
# if SUPPORTED_PERSONALITIES > 2
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-04 01:47:02 +03:00
# include PERSONALITY2_INCLUDE_FUNCS
2013-02-22 16:26:10 +04:00
static const struct_sysent sysent2 [ ] = {
2012-02-25 05:44:25 +04:00
# include "syscallent2.h"
1999-02-19 03:21:36 +03:00
} ;
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
# endif
1999-02-19 03:21:36 +03:00
/* Now undef them since short defines cause wicked namespace pollution. */
2015-07-10 22:24:48 +03:00
# undef SEN
2005-07-05 07:25:35 +04:00
# undef TD
1999-02-19 03:21:36 +03:00
# undef TF
# undef TI
# undef TN
# undef TP
# undef TS
Add -e trace=memory option
Add a new 'memory' category for tracing memory mapping related syscalls.
Affected syscalls are: break, brk, get_mempolicy, madvise, mbind,
migrate_pages, mincore, mlock, mlockall, mmap, move_pages, mprotect,
mremap, msync, munlock, munlockall, munmap, remap_file_pages, and
set_mempolicy.
* defs.h (TRACE_MEMORY): New macro.
* syscall.c (lookup_class): Handle trace=memory option.
* strace.1: Document it.
* linux/alpha/syscallent.h: Add TM flag to memory mapping related syscalls.
* linux/arm/syscallent.h: Likewise.
* linux/avr32/syscallent.h: Likewise.
* linux/bfin/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/tile/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
2012-10-24 06:41:57 +04:00
# undef TM
2011-01-18 20:36:20 +03:00
# undef NF
2011-08-23 15:24:17 +04:00
# undef MA
2014-04-16 10:33:11 +04:00
# undef SI
# undef SE
1999-02-19 03:21:36 +03:00
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
/*
ioctl: take all 32 bits of ioctl commands into account
Historically, only 16 bits (8-bit number and 8-bit type) of 32-bit ioctl
commands were used for decoding, which was the source for numerous
annoying collisions like this:
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, MGSL_IOCGPARAMS or MMTIMER_GETRES or MTIOCTOP or SNDCTL_MIDI_MPUMODE, 0x7fffd47f7338) = -1 ENOTTY (Inappropriate ioctl for device)
The solution is to use all 32 bits for decoding, not just "number" and
"type", but also "size" and "direction".
As some architectures override defaults that come from asm-generic/ and
provide alternative definitions for some ioctl commands, we support
per-architecture ioctl definitions and merge them with common
definitions at build time. During the merge, we used to keep both
generic and architecture-specific definitions, now architecture-specific
definitions have precedence over generic ones -- ioctlsort omits
definitions from asm-generic/ for those ioctl names that have different
definitions in asm/.
Additional bits of "direction" are architecture specific -- the number
of bits and their values differ between architectures. To reduce
architecture differences in the source code, we keep "direction" in
symbolic form and compile it in ioctlsort.
Additional bits of "size" are also architecture specific -- not only the
number of bits differ between architectures, but sizes of many types
depend on sizeof(long). To reduce architecture differences in the
source code, we keep 32-bit and 64-bit versions of common ioctl
definitions, and use the appropriate version for each architecture and
personality.
To implement this, the tools for generating ioctl definitions from
kernel headers have been rewritten, and the source format of ioctl
definitions has been extended. The final ioctlent*.h files that are
included by syscall.c are now generated from source ioctls_inc*.h and
ioctls_arch*.h files at build time with ioctlsort.
* ioctl.c (ioctl_lookup): Use all 32 bits of ioctl command code.
* ioctlsort.c: Rewritten.
* linux/32/ioctls_inc.h: New file.
* linux/64/ioctls_inc.h: New file.
* linux/aarch64/ioctls_arch0.h: New file.
* linux/aarch64/ioctls_arch1.h: New file.
* linux/aarch64/ioctls_inc0.h: New file.
* linux/aarch64/ioctls_inc1.h: New file.
* linux/alpha/ioctls_arch0.h: New file.
* linux/alpha/ioctls_inc0.h: New file.
* linux/arc/ioctls_arch0.h: New file.
* linux/arc/ioctls_inc0.h: New file.
* linux/arm/ioctls_arch0.h: New file.
* linux/arm/ioctls_inc0.h: New file.
* linux/avr32/ioctls_arch0.h: New file.
* linux/avr32/ioctls_inc0.h: New file.
* linux/bfin/ioctls_arch0.h: New file.
* linux/bfin/ioctls_inc0.h: New file.
* linux/hppa/ioctls_arch0.h: New file.
* linux/hppa/ioctls_inc0.h: New file.
* linux/i386/ioctls_arch0.h: New file.
* linux/i386/ioctls_inc0.h: New file.
* linux/ia64/ioctls_arch0.h: New file.
* linux/ia64/ioctls_inc0.h: New file.
* linux/m68k/ioctls_arch0.h: New file.
* linux/m68k/ioctls_inc0.h: New file.
* linux/metag/ioctls_arch0.h: New file.
* linux/metag/ioctls_inc0.h: New file.
* linux/microblaze/ioctls_arch0.h: New file.
* linux/microblaze/ioctls_inc0.h: New file.
* linux/mips/ioctls_arch0.h: New file.
* linux/mips/ioctls_inc0.h: New file.
* linux/or1k/ioctls_arch0.h: New file.
* linux/or1k/ioctls_inc0.h: New file.
* linux/powerpc/ioctls_arch0.h: New file.
* linux/powerpc/ioctls_inc0.h: New file.
* linux/powerpc64/ioctls_arch0.h: New file.
* linux/powerpc64/ioctls_arch1.h: New file.
* linux/powerpc64/ioctls_inc0.h: New file.
* linux/powerpc64/ioctls_inc1.h: New file.
* linux/s390/ioctls_arch0.h: New file.
* linux/s390/ioctls_inc0.h: New file.
* linux/s390x/ioctls_arch0.h: New file.
* linux/s390x/ioctls_inc0.h: New file.
* linux/sh/ioctls_arch0.h: New file.
* linux/sh/ioctls_inc0.h: New file.
* linux/sh64/ioctls_arch0.h: New file.
* linux/sh64/ioctls_inc0.h: New file.
* linux/sparc/ioctls_arch0.h: New file.
* linux/sparc/ioctls_inc0.h: New file.
* linux/sparc64/ioctls_arch0.h: New file.
* linux/sparc64/ioctls_arch2.h: New file.
* linux/sparc64/ioctls_inc0.h: New file.
* linux/sparc64/ioctls_inc2.h: New file.
* linux/tile/ioctls_arch0.h: New file.
* linux/tile/ioctls_arch1.h: New file.
* linux/tile/ioctls_inc0.h: New file.
* linux/tile/ioctls_inc1.h: New file.
* linux/x32/ioctls_arch0.h: New file.
* linux/x32/ioctls_arch1.h: New file.
* linux/x32/ioctls_inc0.h: New file.
* linux/x32/ioctls_inc1.h: New file.
* linux/x86_64/ioctls_arch0.h: New file.
* linux/x86_64/ioctls_arch1.h: New file.
* linux/x86_64/ioctls_inc0.h: New file.
* linux/x86_64/ioctls_inc1.h: New file.
* linux/xtensa/ioctls_arch0.h: New file.
* linux/xtensa/ioctls_inc0.h: New file.
* linux/aarch64/ioctlent.h.in: Remove.
* linux/aarch64/ioctlent1.h: Remove.
* linux/alpha/ioctlent.h.in: Remove.
* linux/arc/ioctlent.h.in: Remove.
* linux/arm/ioctlent.h.in: Remove.
* linux/avr32/ioctlent.h.in: Remove.
* linux/bfin/ioctlent.h.in: Remove.
* linux/hppa/ioctlent.h.in: Remove.
* linux/i386/ioctlent.h.in: Remove.
* linux/ia64/ioctlent.h.in: Remove.
* linux/ioctlent.h.in: Remove.
* linux/ioctlent.sh: Remove.
* linux/m68k/ioctlent.h.in: Remove.
* linux/metag/ioctlent.h.in: Remove.
* linux/microblaze/ioctlent.h.in: Remove.
* linux/mips/ioctlent.h.in: Remove.
* linux/mips/ioctlent.sh: Remove.
* linux/or1k/ioctlent.h.in: Remove.
* linux/powerpc/ioctlent.h.in: Remove.
* linux/powerpc64/ioctlent.h: Remove.
* linux/powerpc64/ioctlent1.h: Remove.
* linux/s390/ioctlent.h.in: Remove.
* linux/s390x/ioctlent.h.in: Remove.
* linux/sh/ioctlent.h.in: Remove.
* linux/sh64/ioctlent.h.in: Remove.
* linux/sparc/ioctlent.h.in: Remove.
* linux/sparc64/ioctlent.h.in: Remove.
* linux/sparc64/ioctlent2.h: Remove.
* linux/tile/ioctlent.h.in: Remove.
* linux/tile/ioctlent1.h: Remove.
* linux/x32/ioctlent.h.in: Remove.
* linux/x32/ioctlent1.h: Remove.
* linux/x86_64/ioctlent.h.in: Remove.
* linux/x86_64/ioctlent1.h: Remove.
* linux/xtensa/ioctlent.h.in: Remove.
* linux/x86_64/ioctlent2.h: Include ioctlent0.h instead of ioctlent.h.
* syscall.c (struct_ioctlent ioctlent0): Likewise.
* Makefile.am: Remove all ioctlent-related definitions.
Define the list of ioctlent*.h files that have to be generated by
presence of $(srcdir)/$(OS)/$(ARCH)/ioctls_inc*.h files.
Add rules for ioctlent*.h files generation.
(EXTRA_DIST): Update.
* maint/ioctls_gen.sh: New file.
* maint/ioctls_hex.sh: New file.
* maint/ioctls_sym.sh: New file.
* maint/print_ioctlent.c: New file.
* HACKING-scripts: Update for ioctlent.sh -> ioctls_gen.sh migration.
* .gitignore: Add ioctlent[012].h and ioctls_all[012].h.
* configure.ac (AC_CHECK_HEADERS): Add linux/hiddev.h
and linux/mmtimer.h for tests.
* tests/ioctl.c: New file.
* tests/ioctl.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add ioctl.
(TESTS): Add ioctl.test.
* tests/.gitignore: Add ioctl.
2015-01-19 20:02:16 +03:00
* ` ioctlent [ 012 ] . h ' files are automatically generated by the auxiliary
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
* program ` ioctlsort ' , such that the list is sorted by the ` code ' field .
* This has the side - effect of resolving the _IO . . macros into
* plain integers , eliminating the need to include here everything
* in " /usr/include " .
*/
2013-02-22 16:37:36 +04:00
const char * const errnoent0 [ ] = {
1999-02-19 03:21:36 +03:00
# include "errnoent.h"
} ;
2013-02-22 16:37:36 +04:00
const char * const signalent0 [ ] = {
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
# include "signalent.h"
} ;
2013-02-22 16:37:36 +04:00
const struct_ioctlent ioctlent0 [ ] = {
ioctl: take all 32 bits of ioctl commands into account
Historically, only 16 bits (8-bit number and 8-bit type) of 32-bit ioctl
commands were used for decoding, which was the source for numerous
annoying collisions like this:
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, MGSL_IOCGPARAMS or MMTIMER_GETRES or MTIOCTOP or SNDCTL_MIDI_MPUMODE, 0x7fffd47f7338) = -1 ENOTTY (Inappropriate ioctl for device)
The solution is to use all 32 bits for decoding, not just "number" and
"type", but also "size" and "direction".
As some architectures override defaults that come from asm-generic/ and
provide alternative definitions for some ioctl commands, we support
per-architecture ioctl definitions and merge them with common
definitions at build time. During the merge, we used to keep both
generic and architecture-specific definitions, now architecture-specific
definitions have precedence over generic ones -- ioctlsort omits
definitions from asm-generic/ for those ioctl names that have different
definitions in asm/.
Additional bits of "direction" are architecture specific -- the number
of bits and their values differ between architectures. To reduce
architecture differences in the source code, we keep "direction" in
symbolic form and compile it in ioctlsort.
Additional bits of "size" are also architecture specific -- not only the
number of bits differ between architectures, but sizes of many types
depend on sizeof(long). To reduce architecture differences in the
source code, we keep 32-bit and 64-bit versions of common ioctl
definitions, and use the appropriate version for each architecture and
personality.
To implement this, the tools for generating ioctl definitions from
kernel headers have been rewritten, and the source format of ioctl
definitions has been extended. The final ioctlent*.h files that are
included by syscall.c are now generated from source ioctls_inc*.h and
ioctls_arch*.h files at build time with ioctlsort.
* ioctl.c (ioctl_lookup): Use all 32 bits of ioctl command code.
* ioctlsort.c: Rewritten.
* linux/32/ioctls_inc.h: New file.
* linux/64/ioctls_inc.h: New file.
* linux/aarch64/ioctls_arch0.h: New file.
* linux/aarch64/ioctls_arch1.h: New file.
* linux/aarch64/ioctls_inc0.h: New file.
* linux/aarch64/ioctls_inc1.h: New file.
* linux/alpha/ioctls_arch0.h: New file.
* linux/alpha/ioctls_inc0.h: New file.
* linux/arc/ioctls_arch0.h: New file.
* linux/arc/ioctls_inc0.h: New file.
* linux/arm/ioctls_arch0.h: New file.
* linux/arm/ioctls_inc0.h: New file.
* linux/avr32/ioctls_arch0.h: New file.
* linux/avr32/ioctls_inc0.h: New file.
* linux/bfin/ioctls_arch0.h: New file.
* linux/bfin/ioctls_inc0.h: New file.
* linux/hppa/ioctls_arch0.h: New file.
* linux/hppa/ioctls_inc0.h: New file.
* linux/i386/ioctls_arch0.h: New file.
* linux/i386/ioctls_inc0.h: New file.
* linux/ia64/ioctls_arch0.h: New file.
* linux/ia64/ioctls_inc0.h: New file.
* linux/m68k/ioctls_arch0.h: New file.
* linux/m68k/ioctls_inc0.h: New file.
* linux/metag/ioctls_arch0.h: New file.
* linux/metag/ioctls_inc0.h: New file.
* linux/microblaze/ioctls_arch0.h: New file.
* linux/microblaze/ioctls_inc0.h: New file.
* linux/mips/ioctls_arch0.h: New file.
* linux/mips/ioctls_inc0.h: New file.
* linux/or1k/ioctls_arch0.h: New file.
* linux/or1k/ioctls_inc0.h: New file.
* linux/powerpc/ioctls_arch0.h: New file.
* linux/powerpc/ioctls_inc0.h: New file.
* linux/powerpc64/ioctls_arch0.h: New file.
* linux/powerpc64/ioctls_arch1.h: New file.
* linux/powerpc64/ioctls_inc0.h: New file.
* linux/powerpc64/ioctls_inc1.h: New file.
* linux/s390/ioctls_arch0.h: New file.
* linux/s390/ioctls_inc0.h: New file.
* linux/s390x/ioctls_arch0.h: New file.
* linux/s390x/ioctls_inc0.h: New file.
* linux/sh/ioctls_arch0.h: New file.
* linux/sh/ioctls_inc0.h: New file.
* linux/sh64/ioctls_arch0.h: New file.
* linux/sh64/ioctls_inc0.h: New file.
* linux/sparc/ioctls_arch0.h: New file.
* linux/sparc/ioctls_inc0.h: New file.
* linux/sparc64/ioctls_arch0.h: New file.
* linux/sparc64/ioctls_arch2.h: New file.
* linux/sparc64/ioctls_inc0.h: New file.
* linux/sparc64/ioctls_inc2.h: New file.
* linux/tile/ioctls_arch0.h: New file.
* linux/tile/ioctls_arch1.h: New file.
* linux/tile/ioctls_inc0.h: New file.
* linux/tile/ioctls_inc1.h: New file.
* linux/x32/ioctls_arch0.h: New file.
* linux/x32/ioctls_arch1.h: New file.
* linux/x32/ioctls_inc0.h: New file.
* linux/x32/ioctls_inc1.h: New file.
* linux/x86_64/ioctls_arch0.h: New file.
* linux/x86_64/ioctls_arch1.h: New file.
* linux/x86_64/ioctls_inc0.h: New file.
* linux/x86_64/ioctls_inc1.h: New file.
* linux/xtensa/ioctls_arch0.h: New file.
* linux/xtensa/ioctls_inc0.h: New file.
* linux/aarch64/ioctlent.h.in: Remove.
* linux/aarch64/ioctlent1.h: Remove.
* linux/alpha/ioctlent.h.in: Remove.
* linux/arc/ioctlent.h.in: Remove.
* linux/arm/ioctlent.h.in: Remove.
* linux/avr32/ioctlent.h.in: Remove.
* linux/bfin/ioctlent.h.in: Remove.
* linux/hppa/ioctlent.h.in: Remove.
* linux/i386/ioctlent.h.in: Remove.
* linux/ia64/ioctlent.h.in: Remove.
* linux/ioctlent.h.in: Remove.
* linux/ioctlent.sh: Remove.
* linux/m68k/ioctlent.h.in: Remove.
* linux/metag/ioctlent.h.in: Remove.
* linux/microblaze/ioctlent.h.in: Remove.
* linux/mips/ioctlent.h.in: Remove.
* linux/mips/ioctlent.sh: Remove.
* linux/or1k/ioctlent.h.in: Remove.
* linux/powerpc/ioctlent.h.in: Remove.
* linux/powerpc64/ioctlent.h: Remove.
* linux/powerpc64/ioctlent1.h: Remove.
* linux/s390/ioctlent.h.in: Remove.
* linux/s390x/ioctlent.h.in: Remove.
* linux/sh/ioctlent.h.in: Remove.
* linux/sh64/ioctlent.h.in: Remove.
* linux/sparc/ioctlent.h.in: Remove.
* linux/sparc64/ioctlent.h.in: Remove.
* linux/sparc64/ioctlent2.h: Remove.
* linux/tile/ioctlent.h.in: Remove.
* linux/tile/ioctlent1.h: Remove.
* linux/x32/ioctlent.h.in: Remove.
* linux/x32/ioctlent1.h: Remove.
* linux/x86_64/ioctlent.h.in: Remove.
* linux/x86_64/ioctlent1.h: Remove.
* linux/xtensa/ioctlent.h.in: Remove.
* linux/x86_64/ioctlent2.h: Include ioctlent0.h instead of ioctlent.h.
* syscall.c (struct_ioctlent ioctlent0): Likewise.
* Makefile.am: Remove all ioctlent-related definitions.
Define the list of ioctlent*.h files that have to be generated by
presence of $(srcdir)/$(OS)/$(ARCH)/ioctls_inc*.h files.
Add rules for ioctlent*.h files generation.
(EXTRA_DIST): Update.
* maint/ioctls_gen.sh: New file.
* maint/ioctls_hex.sh: New file.
* maint/ioctls_sym.sh: New file.
* maint/print_ioctlent.c: New file.
* HACKING-scripts: Update for ioctlent.sh -> ioctls_gen.sh migration.
* .gitignore: Add ioctlent[012].h and ioctls_all[012].h.
* configure.ac (AC_CHECK_HEADERS): Add linux/hiddev.h
and linux/mmtimer.h for tests.
* tests/ioctl.c: New file.
* tests/ioctl.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add ioctl.
(TESTS): Add ioctl.test.
* tests/.gitignore: Add ioctl.
2015-01-19 20:02:16 +03:00
# include "ioctlent0.h"
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
} ;
1999-02-19 03:21:36 +03:00
2013-02-22 16:26:10 +04:00
# if SUPPORTED_PERSONALITIES > 1
2004-09-03 Roland McGrath <roland@redhat.com>
* syscall.c (sysent0, sysent1, sysent2, sysent): Add const to defn.
(nsyscalls0, nsyscalls1, nsyscalls2): Likewise.
(errnoent0, errnoent1, errnoent2, errnoent): Likewise.
(nerrnos0, nerrnos1, nerrnos2): Likewise.
* signal.c (signalent0, signalent1, signalent2): Likewise.
(nsignals0, nsignals1, nsignals2): Likewise.
(signame): LIkewise.
* ioctl.c (ioctlent0, ioctlent1, ioctlent2): Likewise.
(nioctlents0, nioctlents1, nioctlents2): Likewise.
(ioctl_lookup, ioctl_next_match): Likewise.
* defs.h: Update decls.
* io.c (sys_ioctl): Update users.
2004-09-04 07:53:10 +04:00
static const char * const errnoent1 [ ] = {
2012-02-25 05:44:25 +04:00
# include "errnoent1.h"
1999-02-19 03:21:36 +03:00
} ;
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
static const char * const signalent1 [ ] = {
2012-02-25 05:44:25 +04:00
# include "signalent1.h"
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
} ;
2013-02-22 16:26:10 +04:00
static const struct_ioctlent ioctlent1 [ ] = {
2012-02-25 05:44:25 +04:00
# include "ioctlent1.h"
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
} ;
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-04 01:47:02 +03:00
# include PERSONALITY0_INCLUDE_PRINTERS_DECLS
static const struct_printers printers0 = {
# include PERSONALITY0_INCLUDE_PRINTERS_DEFS
} ;
# include PERSONALITY1_INCLUDE_PRINTERS_DECLS
static const struct_printers printers1 = {
# include PERSONALITY1_INCLUDE_PRINTERS_DEFS
} ;
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
# endif
1999-02-19 03:21:36 +03:00
2013-02-22 16:26:10 +04:00
# if SUPPORTED_PERSONALITIES > 2
2004-09-03 Roland McGrath <roland@redhat.com>
* syscall.c (sysent0, sysent1, sysent2, sysent): Add const to defn.
(nsyscalls0, nsyscalls1, nsyscalls2): Likewise.
(errnoent0, errnoent1, errnoent2, errnoent): Likewise.
(nerrnos0, nerrnos1, nerrnos2): Likewise.
* signal.c (signalent0, signalent1, signalent2): Likewise.
(nsignals0, nsignals1, nsignals2): Likewise.
(signame): LIkewise.
* ioctl.c (ioctlent0, ioctlent1, ioctlent2): Likewise.
(nioctlents0, nioctlents1, nioctlents2): Likewise.
(ioctl_lookup, ioctl_next_match): Likewise.
* defs.h: Update decls.
* io.c (sys_ioctl): Update users.
2004-09-04 07:53:10 +04:00
static const char * const errnoent2 [ ] = {
2012-02-25 05:44:25 +04:00
# include "errnoent2.h"
1999-02-19 03:21:36 +03:00
} ;
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
static const char * const signalent2 [ ] = {
2012-02-25 05:44:25 +04:00
# include "signalent2.h"
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
} ;
2013-02-22 16:26:10 +04:00
static const struct_ioctlent ioctlent2 [ ] = {
2012-02-25 05:44:25 +04:00
# include "ioctlent2.h"
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
} ;
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-04 01:47:02 +03:00
# include PERSONALITY2_INCLUDE_PRINTERS_DECLS
static const struct_printers printers2 = {
# include PERSONALITY2_INCLUDE_PRINTERS_DEFS
} ;
Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.
Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.
* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-20 04:12:33 +04:00
# endif
2013-02-27 02:02:30 +04:00
enum {
nsyscalls0 = ARRAY_SIZE ( sysent0 )
# if SUPPORTED_PERSONALITIES > 1
, nsyscalls1 = ARRAY_SIZE ( sysent1 )
# if SUPPORTED_PERSONALITIES > 2
, nsyscalls2 = ARRAY_SIZE ( sysent2 )
# endif
# endif
} ;
enum {
nerrnos0 = ARRAY_SIZE ( errnoent0 )
# if SUPPORTED_PERSONALITIES > 1
, nerrnos1 = ARRAY_SIZE ( errnoent1 )
# if SUPPORTED_PERSONALITIES > 2
, nerrnos2 = ARRAY_SIZE ( errnoent2 )
# endif
# endif
} ;
enum {
nsignals0 = ARRAY_SIZE ( signalent0 )
# if SUPPORTED_PERSONALITIES > 1
, nsignals1 = ARRAY_SIZE ( signalent1 )
# if SUPPORTED_PERSONALITIES > 2
, nsignals2 = ARRAY_SIZE ( signalent2 )
# endif
# endif
} ;
enum {
nioctlents0 = ARRAY_SIZE ( ioctlent0 )
# if SUPPORTED_PERSONALITIES > 1
, nioctlents1 = ARRAY_SIZE ( ioctlent1 )
# if SUPPORTED_PERSONALITIES > 2
, nioctlents2 = ARRAY_SIZE ( ioctlent2 )
# endif
# endif
} ;
2013-02-22 16:37:36 +04:00
# if SUPPORTED_PERSONALITIES > 1
2013-02-22 16:26:10 +04:00
const struct_sysent * sysent = sysent0 ;
2012-03-19 12:36:42 +04:00
const char * const * errnoent = errnoent0 ;
const char * const * signalent = signalent0 ;
2013-02-22 16:26:10 +04:00
const struct_ioctlent * ioctlent = ioctlent0 ;
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-04 01:47:02 +03:00
const struct_printers * printers = & printers0 ;
2013-02-22 16:37:36 +04:00
# endif
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-04 01:47:02 +03:00
2012-03-19 12:36:42 +04:00
unsigned nsyscalls = nsyscalls0 ;
unsigned nerrnos = nerrnos0 ;
unsigned nsignals = nsignals0 ;
unsigned nioctlents = nioctlents0 ;
2013-02-22 16:37:36 +04:00
unsigned num_quals ;
qualbits_t * qual_vec [ SUPPORTED_PERSONALITIES ] ;
static const unsigned nsyscall_vec [ SUPPORTED_PERSONALITIES ] = {
nsyscalls0 ,
# if SUPPORTED_PERSONALITIES > 1
nsyscalls1 ,
# endif
# if SUPPORTED_PERSONALITIES > 2
nsyscalls2 ,
# endif
} ;
static const struct_sysent * const sysent_vec [ SUPPORTED_PERSONALITIES ] = {
sysent0 ,
# if SUPPORTED_PERSONALITIES > 1
sysent1 ,
# endif
# if SUPPORTED_PERSONALITIES > 2
sysent2 ,
# endif
} ;
enum {
MAX_NSYSCALLS1 = ( nsyscalls0
# if SUPPORTED_PERSONALITIES > 1
> nsyscalls1 ? nsyscalls0 : nsyscalls1
# endif
) ,
MAX_NSYSCALLS2 = ( MAX_NSYSCALLS1
# if SUPPORTED_PERSONALITIES > 2
> nsyscalls2 ? MAX_NSYSCALLS1 : nsyscalls2
# endif
) ,
MAX_NSYSCALLS = MAX_NSYSCALLS2 ,
/* We are ready for arches with up to 255 signals,
* even though the largest known signo is on MIPS and it is 128.
* The number of existing syscalls on all arches is
* larger that 255 anyway , so it is just a pedantic matter .
*/
MIN_QUALS = MAX_NSYSCALLS > 255 ? MAX_NSYSCALLS : 255
} ;
1999-02-19 03:21:36 +03:00
2012-03-19 12:36:42 +04:00
# if SUPPORTED_PERSONALITIES > 1
2013-02-15 17:55:14 +04:00
unsigned current_personality ;
1999-02-19 03:21:36 +03:00
2013-02-15 17:55:14 +04:00
# ifndef current_wordsize
unsigned current_wordsize ;
static const int personality_wordsize [ SUPPORTED_PERSONALITIES ] = {
2006-01-12 13:18:53 +03:00
PERSONALITY0_WORDSIZE ,
PERSONALITY1_WORDSIZE ,
2012-03-19 12:36:42 +04:00
# if SUPPORTED_PERSONALITIES > 2
2006-01-12 13:18:53 +03:00
PERSONALITY2_WORDSIZE ,
2012-03-19 12:36:42 +04:00
# endif
2011-08-20 03:50:09 +04:00
} ;
2013-02-15 17:55:14 +04:00
# endif
2006-01-12 13:18:53 +03:00
2011-08-20 03:50:09 +04:00
void
2006-12-21 01:37:21 +03:00
set_personality ( int personality )
1999-02-19 03:21:36 +03:00
{
2013-02-22 16:37:36 +04:00
nsyscalls = nsyscall_vec [ personality ] ;
sysent = sysent_vec [ personality ] ;
1999-02-19 03:21:36 +03:00
switch ( personality ) {
case 0 :
errnoent = errnoent0 ;
nerrnos = nerrnos0 ;
ioctlent = ioctlent0 ;
nioctlents = nioctlents0 ;
signalent = signalent0 ;
nsignals = nsignals0 ;
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-04 01:47:02 +03:00
printers = & printers0 ;
1999-02-19 03:21:36 +03:00
break ;
case 1 :
errnoent = errnoent1 ;
nerrnos = nerrnos1 ;
ioctlent = ioctlent1 ;
nioctlents = nioctlents1 ;
signalent = signalent1 ;
nsignals = nsignals1 ;
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-04 01:47:02 +03:00
printers = & printers1 ;
1999-02-19 03:21:36 +03:00
break ;
2013-02-22 16:26:10 +04:00
# if SUPPORTED_PERSONALITIES > 2
1999-02-19 03:21:36 +03:00
case 2 :
errnoent = errnoent2 ;
nerrnos = nerrnos2 ;
ioctlent = ioctlent2 ;
nioctlents = nioctlents2 ;
signalent = signalent2 ;
nsignals = nsignals2 ;
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-04 01:47:02 +03:00
printers = & printers2 ;
1999-02-19 03:21:36 +03:00
break ;
2012-03-19 12:36:42 +04:00
# endif
1999-02-19 03:21:36 +03:00
}
current_personality = personality ;
2013-02-15 17:55:14 +04:00
# ifndef current_wordsize
current_wordsize = personality_wordsize [ personality ] ;
# endif
1999-02-19 03:21:36 +03:00
}
2011-12-23 04:50:49 +04:00
static void
2014-09-10 17:46:04 +04:00
update_personality ( struct tcb * tcp , unsigned int personality )
2011-12-23 04:50:49 +04:00
{
if ( personality = = current_personality )
return ;
set_personality ( personality ) ;
if ( personality = = tcp - > currpers )
return ;
tcp - > currpers = personality ;
Consistently use error_msg instead of fprintf(stderr)
* linux/alpha/get_scno.c: Use error_msg.
* linux/arm/get_scno.c: Likewise.
* linux/mips/get_scno.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/x86_64/get_scno.c: Likewise.
* exit.c (sys_exit): Likewise.
* pathtrace.c (pathtrace_select, pathtrace_match): Likewise.
* strace.c (alloctcb, droptcb, detach, startup_attach,
test_ptrace_seize, init, cleanup, print_debug_info,
maybe_allocate_tcb, startup_tcb, trace): Likewise.
* syscall.c (update_personality, trace_syscall_exiting,
get_scno): Likewise.
* unwind.c (DPRINTF): Likewise.
* tests/bexecve.test: Update patterns.
* tests/detach-stopped.test: Likewise.
2015-05-26 01:51:19 +03:00
# undef PERSONALITY_NAMES
# if defined POWERPC64
# define PERSONALITY_NAMES {"64 bit", "32 bit"}
# elif defined X86_64
# define PERSONALITY_NAMES {"64 bit", "32 bit", "x32"}
# elif defined X32
# define PERSONALITY_NAMES {"x32", "32 bit"}
# elif defined AARCH64
2015-12-09 03:43:39 +03:00
# define PERSONALITY_NAMES {"64 bit", "32 bit"}
Consistently use error_msg instead of fprintf(stderr)
* linux/alpha/get_scno.c: Use error_msg.
* linux/arm/get_scno.c: Likewise.
* linux/mips/get_scno.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/x86_64/get_scno.c: Likewise.
* exit.c (sys_exit): Likewise.
* pathtrace.c (pathtrace_select, pathtrace_match): Likewise.
* strace.c (alloctcb, droptcb, detach, startup_attach,
test_ptrace_seize, init, cleanup, print_debug_info,
maybe_allocate_tcb, startup_tcb, trace): Likewise.
* syscall.c (update_personality, trace_syscall_exiting,
get_scno): Likewise.
* unwind.c (DPRINTF): Likewise.
* tests/bexecve.test: Update patterns.
* tests/detach-stopped.test: Likewise.
2015-05-26 01:51:19 +03:00
# elif defined TILE
# define PERSONALITY_NAMES {"64-bit", "32-bit"}
# endif
# ifdef PERSONALITY_NAMES
Add tilegx support to strace
tilegx support has been in the kernel since 3.0.
In addition, fix some issues with the tilepro support already
present in strace, primarily the decision to use the
<asm/unistd.h> numbering space for system calls.
* defs.h [TILE]: Include <asm/ptrace.h> and provide an extern
struct pt_regs tile_regs for efficiency. Provide compat 32-bit
personality via SUPPORTED_PERSONALITIES, PERSONALITY0_WORDSIZE,
PERSONALITY1_WORDSIZE, and DEFAULT_PERSONALITY.
* linux/tile/errnoent1.h: New file, includes linux/errnoent.h.
* linux/tile/ioctlent1.h: New file, includes linux/ioctlent.h.
* linux/tile/signalent1.h: New file, includes linux/signalent.h.
* linux/tile/syscallent.h: Update with new asm-generic syscalls.
The version previously committed was the from the first tile patch
to LKML, which subsequently was changed to use <asm-generic/unistd.h>.
* linux/tile/syscallent1.h: Copy from linux/tile/syscallent.h.
* mem.c (addtileflags) [TILE]: use %ld properly for a "long" variable.
* process.c [TILE]: Choose clone arguments correctly and properly
suppress all "struct user" related offsets in user_struct_offsets.
* signal.c [TILE]: Use tile_regs not upeek.
* syscall.c (update_personality) [TILE]: Print mode.
(PT_FLAGS_COMPAT) [TILE]: Provide if not in system headers.
(tile_regs) [TILE]: Define 'struct pt_regs' variable to hold state.
(get_regs) [TILE]: use PTRACE_GETREGS to set tile_regs rather than using upeek.
(get_scno) [TILE]: Set personality.
(get_syscall_args) [TILE]: Use tile_regs.
(get_syscall_result) [TILE]: Update tile_regs.
(get_error) [TILE]: Use tile_regs.
(printcall) [TILE]: Print pc.
(arg0_offset, arg1_offset, restore_arg0, restore_arg1) [TILE]:
Properly handle tile call semantics and support tilegx.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-05 20:48:33 +04:00
if ( ! qflag ) {
Consistently use error_msg instead of fprintf(stderr)
* linux/alpha/get_scno.c: Use error_msg.
* linux/arm/get_scno.c: Likewise.
* linux/mips/get_scno.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/x86_64/get_scno.c: Likewise.
* exit.c (sys_exit): Likewise.
* pathtrace.c (pathtrace_select, pathtrace_match): Likewise.
* strace.c (alloctcb, droptcb, detach, startup_attach,
test_ptrace_seize, init, cleanup, print_debug_info,
maybe_allocate_tcb, startup_tcb, trace): Likewise.
* syscall.c (update_personality, trace_syscall_exiting,
get_scno): Likewise.
* unwind.c (DPRINTF): Likewise.
* tests/bexecve.test: Update patterns.
* tests/detach-stopped.test: Likewise.
2015-05-26 01:51:19 +03:00
static const char * const names [ ] = PERSONALITY_NAMES ;
error_msg ( " [ Process PID=%d runs in %s mode. ] " ,
tcp - > pid , names [ personality ] ) ;
Add tilegx support to strace
tilegx support has been in the kernel since 3.0.
In addition, fix some issues with the tilepro support already
present in strace, primarily the decision to use the
<asm/unistd.h> numbering space for system calls.
* defs.h [TILE]: Include <asm/ptrace.h> and provide an extern
struct pt_regs tile_regs for efficiency. Provide compat 32-bit
personality via SUPPORTED_PERSONALITIES, PERSONALITY0_WORDSIZE,
PERSONALITY1_WORDSIZE, and DEFAULT_PERSONALITY.
* linux/tile/errnoent1.h: New file, includes linux/errnoent.h.
* linux/tile/ioctlent1.h: New file, includes linux/ioctlent.h.
* linux/tile/signalent1.h: New file, includes linux/signalent.h.
* linux/tile/syscallent.h: Update with new asm-generic syscalls.
The version previously committed was the from the first tile patch
to LKML, which subsequently was changed to use <asm-generic/unistd.h>.
* linux/tile/syscallent1.h: Copy from linux/tile/syscallent.h.
* mem.c (addtileflags) [TILE]: use %ld properly for a "long" variable.
* process.c [TILE]: Choose clone arguments correctly and properly
suppress all "struct user" related offsets in user_struct_offsets.
* signal.c [TILE]: Use tile_regs not upeek.
* syscall.c (update_personality) [TILE]: Print mode.
(PT_FLAGS_COMPAT) [TILE]: Provide if not in system headers.
(tile_regs) [TILE]: Define 'struct pt_regs' variable to hold state.
(get_regs) [TILE]: use PTRACE_GETREGS to set tile_regs rather than using upeek.
(get_scno) [TILE]: Set personality.
(get_syscall_args) [TILE]: Use tile_regs.
(get_syscall_result) [TILE]: Update tile_regs.
(get_error) [TILE]: Use tile_regs.
(printcall) [TILE]: Print pc.
(arg0_offset, arg1_offset, restore_arg0, restore_arg1) [TILE]:
Properly handle tile call semantics and support tilegx.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-05 20:48:33 +04:00
}
2012-02-25 05:44:25 +04:00
# endif
2011-12-23 04:50:49 +04:00
}
# endif
2004-09-04 08:20:43 +04:00
2013-02-21 19:17:08 +04:00
static int qual_syscall ( ) , qual_signal ( ) , qual_desc ( ) ;
1999-02-19 03:21:36 +03:00
2004-09-04 08:20:43 +04:00
static const struct qual_options {
2014-09-10 17:46:04 +04:00
unsigned int bitflag ;
2010-09-07 02:08:24 +04:00
const char * option_name ;
2010-09-15 20:18:20 +04:00
int ( * qualify ) ( const char * , int , int ) ;
2010-09-07 02:08:24 +04:00
const char * argument_name ;
1999-02-19 03:21:36 +03:00
} qual_options [ ] = {
2002-12-30 13:23:00 +03:00
{ QUAL_TRACE , " trace " , qual_syscall , " system call " } ,
{ QUAL_TRACE , " t " , qual_syscall , " system call " } ,
{ QUAL_ABBREV , " abbrev " , qual_syscall , " system call " } ,
{ QUAL_ABBREV , " a " , qual_syscall , " system call " } ,
{ QUAL_VERBOSE , " verbose " , qual_syscall , " system call " } ,
{ QUAL_VERBOSE , " v " , qual_syscall , " system call " } ,
{ QUAL_RAW , " raw " , qual_syscall , " system call " } ,
{ QUAL_RAW , " x " , qual_syscall , " system call " } ,
{ QUAL_SIGNAL , " signal " , qual_signal , " signal " } ,
{ QUAL_SIGNAL , " signals " , qual_signal , " signal " } ,
{ QUAL_SIGNAL , " s " , qual_signal , " signal " } ,
{ QUAL_READ , " read " , qual_desc , " descriptor " } ,
{ QUAL_READ , " reads " , qual_desc , " descriptor " } ,
{ QUAL_READ , " r " , qual_desc , " descriptor " } ,
{ QUAL_WRITE , " write " , qual_desc , " descriptor " } ,
{ QUAL_WRITE , " writes " , qual_desc , " descriptor " } ,
{ QUAL_WRITE , " w " , qual_desc , " descriptor " } ,
1999-02-19 03:21:36 +03:00
{ 0 , NULL , NULL , NULL } ,
} ;
2013-02-22 16:37:36 +04:00
static void
2014-09-10 17:46:04 +04:00
reallocate_qual ( const unsigned int n )
2013-02-22 16:37:36 +04:00
{
unsigned p ;
qualbits_t * qp ;
for ( p = 0 ; p < SUPPORTED_PERSONALITIES ; p + + ) {
Introduce memory allocation wrappers
Introduce wrappers to the following functions that do memory allocation:
malloc, calloc, realloc, strdup.
This commit is a follow-up to the related discussions in strace-devel ML:
http://sourceforge.net/p/strace/mailman/message/33618180/
http://sourceforge.net/p/strace/mailman/message/33733470/
* defs.h (xmalloc, xcalloc, xreallocarray, xstrdup): New prototypes.
* xmalloc.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* count.c (count_syscall, call_summary_pers): Use xcalloc.
* desc.c (decode_select): Use xmalloc.
* dirent.c (sys_getdents, sys_getdents64): Likewise.
* net.c (sys_recvmmsg): Use xstrdup.
* pathtrace.c (storepath): Use xreallocarray.
(pathtrace_match): Use xmalloc.
* strace.c (die_out_of_memory): Move to xmalloc.c.
(expand_tcbtab): Use xcalloc and xreallocarray.
(startup_child): Use xstrdup.
(init): Use xmalloc, xcalloc, and xstrdup.
* syscall.c (reallocate_qual): Use xreallocarray.
(qualify): Use xstrdup.
* unwind.c (unwind_tcb_init): Use xmalloc.
(build_mmap_cache): Use xcalloc, xreallocarray, and xstrdup.
(get_symbol_name): Use xreallocarray.
(stacktrace_walk, queue_put): Use xmalloc.
* util.c (printstr): Use xmalloc.
* vsprintf.c (strace_vfprintf): Likewise.
2015-05-25 23:41:02 +03:00
qp = qual_vec [ p ] = xreallocarray ( qual_vec [ p ] , n ,
sizeof ( qualbits_t ) ) ;
2013-02-22 16:37:36 +04:00
memset ( & qp [ num_quals ] , 0 , ( n - num_quals ) * sizeof ( qualbits_t ) ) ;
}
num_quals = n ;
}
2002-12-30 13:23:00 +03:00
static void
2014-09-10 17:46:04 +04:00
qualify_one ( const unsigned int n , unsigned int bitflag , const int not , const int pers )
2002-12-30 13:23:00 +03:00
{
2014-09-10 17:46:04 +04:00
int p ;
2006-01-12 12:50:49 +03:00
2013-02-22 16:37:36 +04:00
if ( num_quals < = n )
reallocate_qual ( n + 1 ) ;
2006-01-12 12:50:49 +03:00
2013-02-22 16:37:36 +04:00
for ( p = 0 ; p < SUPPORTED_PERSONALITIES ; p + + ) {
if ( pers = = p | | pers < 0 ) {
if ( not )
qual_vec [ p ] [ n ] & = ~ bitflag ;
else
qual_vec [ p ] [ n ] | = bitflag ;
}
2006-01-12 12:50:49 +03:00
}
2002-12-30 13:23:00 +03:00
}
1999-02-19 03:21:36 +03:00
static int
2014-09-10 17:46:04 +04:00
qual_syscall ( const char * s , const unsigned int bitflag , const int not )
1999-02-19 03:21:36 +03:00
{
2014-09-10 17:46:04 +04:00
int p ;
unsigned int i ;
2005-02-02 07:40:11 +03:00
int rc = - 1 ;
1999-02-19 03:21:36 +03:00
2012-03-23 14:29:01 +04:00
if ( * s > = ' 0 ' & & * s < = ' 9 ' ) {
2013-02-22 16:37:36 +04:00
i = string_to_uint ( s ) ;
2013-02-23 21:19:28 +04:00
if ( i > = MAX_NSYSCALLS )
2009-02-27 23:32:52 +03:00
return - 1 ;
2010-09-15 20:18:20 +04:00
qualify_one ( i , bitflag , not , - 1 ) ;
2009-02-27 23:32:52 +03:00
return 0 ;
2006-01-12 12:45:56 +03:00
}
2006-01-12 12:50:49 +03:00
2013-02-22 16:37:36 +04:00
for ( p = 0 ; p < SUPPORTED_PERSONALITIES ; p + + ) {
for ( i = 0 ; i < nsyscall_vec [ p ] ; i + + ) {
if ( sysent_vec [ p ] [ i ] . sys_name
& & strcmp ( s , sysent_vec [ p ] [ i ] . sys_name ) = = 0
) {
2013-03-01 19:50:22 +04:00
qualify_one ( i , bitflag , not , p ) ;
2013-02-22 16:37:36 +04:00
rc = 0 ;
}
2006-01-12 12:50:49 +03:00
}
2013-02-22 16:37:36 +04:00
}
2007-08-23 01:43:30 +04:00
2005-02-02 07:40:11 +03:00
return rc ;
1999-02-19 03:21:36 +03:00
}
static int
2014-09-10 17:46:04 +04:00
qual_signal ( const char * s , const unsigned int bitflag , const int not )
1999-02-19 03:21:36 +03:00
{
2014-09-10 17:46:04 +04:00
unsigned int i ;
1999-02-19 03:21:36 +03:00
2012-03-23 14:29:01 +04:00
if ( * s > = ' 0 ' & & * s < = ' 9 ' ) {
2012-03-26 01:49:48 +04:00
int signo = string_to_uint ( s ) ;
2013-02-22 16:37:36 +04:00
if ( signo < 0 | | signo > 255 )
2009-02-27 23:32:52 +03:00
return - 1 ;
2010-09-15 20:18:20 +04:00
qualify_one ( signo , bitflag , not , - 1 ) ;
2009-02-27 23:32:52 +03:00
return 0 ;
2002-12-30 13:23:00 +03:00
}
2010-09-07 02:08:24 +04:00
if ( strncasecmp ( s , " SIG " , 3 ) = = 0 )
1999-02-19 03:21:36 +03:00
s + = 3 ;
2012-03-23 14:29:01 +04:00
for ( i = 0 ; i < = NSIG ; i + + ) {
2010-09-07 02:08:24 +04:00
if ( strcasecmp ( s , signame ( i ) + 3 ) = = 0 ) {
2010-09-15 20:18:20 +04:00
qualify_one ( i , bitflag , not , - 1 ) ;
2005-02-02 06:51:18 +03:00
return 0 ;
2002-12-30 13:23:00 +03:00
}
2012-03-23 14:29:01 +04:00
}
2005-02-02 06:51:18 +03:00
return - 1 ;
1999-02-19 03:21:36 +03:00
}
static int
2014-09-10 17:46:04 +04:00
qual_desc ( const char * s , const unsigned int bitflag , const int not )
1999-02-19 03:21:36 +03:00
{
2012-03-23 14:29:01 +04:00
if ( * s > = ' 0 ' & & * s < = ' 9 ' ) {
2012-03-26 01:49:48 +04:00
int desc = string_to_uint ( s ) ;
2013-02-22 16:37:36 +04:00
if ( desc < 0 | | desc > 0x7fff ) /* paranoia */
2005-02-02 07:40:11 +03:00
return - 1 ;
2010-09-15 20:18:20 +04:00
qualify_one ( desc , bitflag , not , - 1 ) ;
2003-04-10 22:58:20 +04:00
return 0 ;
2002-12-30 13:23:00 +03:00
}
1999-02-19 03:21:36 +03:00
return - 1 ;
}
static int
2010-09-07 02:08:24 +04:00
lookup_class ( const char * s )
1999-02-19 03:21:36 +03:00
{
if ( strcmp ( s , " file " ) = = 0 )
return TRACE_FILE ;
if ( strcmp ( s , " ipc " ) = = 0 )
return TRACE_IPC ;
if ( strcmp ( s , " network " ) = = 0 )
return TRACE_NETWORK ;
if ( strcmp ( s , " process " ) = = 0 )
return TRACE_PROCESS ;
if ( strcmp ( s , " signal " ) = = 0 )
return TRACE_SIGNAL ;
2005-07-05 07:25:35 +04:00
if ( strcmp ( s , " desc " ) = = 0 )
return TRACE_DESC ;
Add -e trace=memory option
Add a new 'memory' category for tracing memory mapping related syscalls.
Affected syscalls are: break, brk, get_mempolicy, madvise, mbind,
migrate_pages, mincore, mlock, mlockall, mmap, move_pages, mprotect,
mremap, msync, munlock, munlockall, munmap, remap_file_pages, and
set_mempolicy.
* defs.h (TRACE_MEMORY): New macro.
* syscall.c (lookup_class): Handle trace=memory option.
* strace.1: Document it.
* linux/alpha/syscallent.h: Add TM flag to memory mapping related syscalls.
* linux/arm/syscallent.h: Likewise.
* linux/avr32/syscallent.h: Likewise.
* linux/bfin/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/ia64/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/mips/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/tile/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
2012-10-24 06:41:57 +04:00
if ( strcmp ( s , " memory " ) = = 0 )
return TRACE_MEMORY ;
1999-02-19 03:21:36 +03:00
return - 1 ;
}
void
2010-09-07 02:08:24 +04:00
qualify ( const char * s )
1999-02-19 03:21:36 +03:00
{
2004-09-04 08:20:43 +04:00
const struct qual_options * opt ;
2010-09-07 02:08:24 +04:00
char * copy ;
const char * p ;
2014-09-10 17:46:04 +04:00
int not ;
unsigned int i ;
1999-02-19 03:21:36 +03:00
2013-02-22 16:37:36 +04:00
if ( num_quals = = 0 )
reallocate_qual ( MIN_QUALS ) ;
1999-02-19 03:21:36 +03:00
opt = & qual_options [ 0 ] ;
for ( i = 0 ; ( p = qual_options [ i ] . option_name ) ; i + + ) {
2014-09-10 17:46:04 +04:00
unsigned int len = strlen ( p ) ;
if ( strncmp ( s , p , len ) = = 0 & & s [ len ] = = ' = ' ) {
1999-02-19 03:21:36 +03:00
opt = & qual_options [ i ] ;
2014-09-10 17:46:04 +04:00
s + = len + 1 ;
1999-02-19 03:21:36 +03:00
break ;
}
}
not = 0 ;
if ( * s = = ' ! ' ) {
not = 1 ;
s + + ;
}
if ( strcmp ( s , " none " ) = = 0 ) {
not = 1 - not ;
s = " all " ;
}
if ( strcmp ( s , " all " ) = = 0 ) {
2013-02-22 16:37:36 +04:00
for ( i = 0 ; i < num_quals ; i + + ) {
2010-09-15 20:18:20 +04:00
qualify_one ( i , opt - > bitflag , not , - 1 ) ;
1999-02-19 03:21:36 +03:00
}
return ;
}
2013-02-22 16:37:36 +04:00
for ( i = 0 ; i < num_quals ; i + + ) {
2010-09-15 20:18:20 +04:00
qualify_one ( i , opt - > bitflag , ! not , - 1 ) ;
1999-02-19 03:21:36 +03:00
}
Introduce memory allocation wrappers
Introduce wrappers to the following functions that do memory allocation:
malloc, calloc, realloc, strdup.
This commit is a follow-up to the related discussions in strace-devel ML:
http://sourceforge.net/p/strace/mailman/message/33618180/
http://sourceforge.net/p/strace/mailman/message/33733470/
* defs.h (xmalloc, xcalloc, xreallocarray, xstrdup): New prototypes.
* xmalloc.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* count.c (count_syscall, call_summary_pers): Use xcalloc.
* desc.c (decode_select): Use xmalloc.
* dirent.c (sys_getdents, sys_getdents64): Likewise.
* net.c (sys_recvmmsg): Use xstrdup.
* pathtrace.c (storepath): Use xreallocarray.
(pathtrace_match): Use xmalloc.
* strace.c (die_out_of_memory): Move to xmalloc.c.
(expand_tcbtab): Use xcalloc and xreallocarray.
(startup_child): Use xstrdup.
(init): Use xmalloc, xcalloc, and xstrdup.
* syscall.c (reallocate_qual): Use xreallocarray.
(qualify): Use xstrdup.
* unwind.c (unwind_tcb_init): Use xmalloc.
(build_mmap_cache): Use xcalloc, xreallocarray, and xstrdup.
(get_symbol_name): Use xreallocarray.
(stacktrace_walk, queue_put): Use xmalloc.
* util.c (printstr): Use xmalloc.
* vsprintf.c (strace_vfprintf): Likewise.
2015-05-25 23:41:02 +03:00
copy = xstrdup ( s ) ;
2010-09-07 02:08:24 +04:00
for ( p = strtok ( copy , " , " ) ; p ; p = strtok ( NULL , " , " ) ) {
2014-09-10 17:46:04 +04:00
int n ;
1999-02-19 03:21:36 +03:00
if ( opt - > bitflag = = QUAL_TRACE & & ( n = lookup_class ( p ) ) > 0 ) {
2013-02-22 16:37:36 +04:00
unsigned pers ;
for ( pers = 0 ; pers < SUPPORTED_PERSONALITIES ; pers + + ) {
for ( i = 0 ; i < nsyscall_vec [ pers ] ; i + + )
if ( sysent_vec [ pers ] [ i ] . sys_flags & n )
2013-03-01 19:50:22 +04:00
qualify_one ( i , opt - > bitflag , not , pers ) ;
2013-02-22 16:37:36 +04:00
}
1999-02-19 03:21:36 +03:00
continue ;
}
2010-09-15 20:18:20 +04:00
if ( opt - > qualify ( p , opt - > bitflag , not ) ) {
2012-03-08 14:54:10 +04:00
error_msg_and_die ( " invalid %s '%s' " ,
1999-02-19 03:21:36 +03:00
opt - > argument_name , p ) ;
}
}
2010-09-07 02:08:24 +04:00
free ( copy ) ;
1999-02-19 03:21:36 +03:00
return ;
}
2012-03-16 02:08:55 +04:00
# ifdef SYS_socket_subcall
2005-06-09 00:45:28 +04:00
static void
2012-03-16 02:08:55 +04:00
decode_socket_subcall ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
2012-03-16 02:08:55 +04:00
unsigned long addr ;
2015-03-22 18:52:40 +03:00
unsigned int n ;
2012-03-16 02:08:55 +04:00
if ( tcp - > u_arg [ 0 ] < 0 | | tcp - > u_arg [ 0 ] > = SYS_socket_nsubcalls )
return ;
tcp - > scno = SYS_socket_subcall + tcp - > u_arg [ 0 ] ;
2013-02-21 19:13:47 +04:00
tcp - > qual_flg = qual_flags [ tcp - > scno ] ;
tcp - > s_ent = & sysent [ tcp - > scno ] ;
2012-03-16 02:08:55 +04:00
addr = tcp - > u_arg [ 1 ] ;
2013-02-21 19:13:47 +04:00
n = tcp - > s_ent - > nargs ;
2015-03-22 18:52:40 +03:00
if ( sizeof ( tcp - > u_arg [ 0 ] ) = = current_wordsize ) {
memset ( tcp - > u_arg , 0 , n * sizeof ( tcp - > u_arg [ 0 ] ) ) ;
( void ) umoven ( tcp , addr , n * sizeof ( tcp - > u_arg [ 0 ] ) , tcp - > u_arg ) ;
} else {
unsigned int args [ n ] ;
unsigned int i ;
memset ( args , 0 , sizeof ( args ) ) ;
( void ) umove ( tcp , addr , & args ) ;
for ( i = 0 ; i < n ; + + i )
tcp - > u_arg [ i ] = args [ i ] ;
1999-02-19 03:21:36 +03:00
}
}
2012-03-16 02:08:55 +04:00
# endif
# ifdef SYS_ipc_subcall
static void
decode_ipc_subcall ( struct tcb * tcp )
{
2013-02-21 19:13:47 +04:00
unsigned int i , n ;
2012-03-16 02:08:55 +04:00
if ( tcp - > u_arg [ 0 ] < 0 | | tcp - > u_arg [ 0 ] > = SYS_ipc_nsubcalls )
return ;
2012-03-15 09:09:19 +04:00
2012-03-16 02:08:55 +04:00
tcp - > scno = SYS_ipc_subcall + tcp - > u_arg [ 0 ] ;
2013-02-21 19:13:47 +04:00
tcp - > qual_flg = qual_flags [ tcp - > scno ] ;
tcp - > s_ent = & sysent [ tcp - > scno ] ;
n = tcp - > s_ent - > nargs ;
for ( i = 0 ; i < n ; i + + )
2012-03-16 02:08:55 +04:00
tcp - > u_arg [ i ] = tcp - > u_arg [ i + 1 ] ;
}
# endif
1999-02-19 03:21:36 +03:00
2015-04-17 12:14:19 +03:00
# ifdef LINUX_MIPSO32
static void
decode_mips_subcall ( struct tcb * tcp )
{
if ( ! SCNO_IS_VALID ( tcp - > u_arg [ 0 ] ) )
return ;
tcp - > scno = tcp - > u_arg [ 0 ] ;
tcp - > qual_flg = qual_flags [ tcp - > scno ] ;
tcp - > s_ent = & sysent [ tcp - > scno ] ;
memmove ( & tcp - > u_arg [ 0 ] , & tcp - > u_arg [ 1 ] ,
sizeof ( tcp - > u_arg ) - sizeof ( tcp - > u_arg [ 0 ] ) ) ;
/*
* Fetching the last arg of 7 - arg syscalls ( fadvise64_64
* and sync_file_range ) would require additional code ,
* see linux / mips / get_syscall_args . c
*/
}
# endif
2011-08-24 20:07:22 +04:00
int
printargs ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
2011-08-24 20:07:22 +04:00
if ( entering ( tcp ) ) {
int i ;
2013-02-21 19:13:47 +04:00
int n = tcp - > s_ent - > nargs ;
for ( i = 0 ; i < n ; i + + )
2011-08-24 20:07:22 +04:00
tprintf ( " %s%#lx " , i ? " , " : " " , tcp - > u_arg [ i ] ) ;
}
return 0 ;
}
2006-12-21 14:44:28 +03:00
2012-02-27 17:18:02 +04:00
int
2016-02-14 19:26:37 +03:00
printargs_u ( struct tcb * tcp )
2012-02-27 17:18:02 +04:00
{
2016-02-14 18:53:05 +03:00
const int n = tcp - > s_ent - > nargs ;
int i ;
for ( i = 0 ; i < n ; + + i )
2016-02-14 19:26:37 +03:00
tprintf ( " %s%u " , i ? " , " : " " ,
( unsigned int ) tcp - > u_arg [ i ] ) ;
2016-02-14 18:53:05 +03:00
return RVAL_DECODED ;
2012-02-27 17:18:02 +04:00
}
int
2016-02-14 19:26:37 +03:00
printargs_d ( struct tcb * tcp )
2012-02-27 17:18:02 +04:00
{
2016-02-14 18:53:05 +03:00
const int n = tcp - > s_ent - > nargs ;
int i ;
for ( i = 0 ; i < n ; + + i )
2016-02-14 19:26:37 +03:00
tprintf ( " %s%d " , i ? " , " : " " ,
( int ) tcp - > u_arg [ i ] ) ;
2016-02-14 18:53:05 +03:00
return RVAL_DECODED ;
2012-02-27 17:18:02 +04:00
}
2015-03-22 21:09:55 +03:00
static void
dumpio ( struct tcb * tcp )
{
2015-07-10 22:24:58 +03:00
int sen ;
2015-03-22 21:09:55 +03:00
if ( syserror ( tcp ) )
return ;
if ( ( unsigned long ) tcp - > u_arg [ 0 ] > = num_quals )
return ;
2015-07-10 22:24:58 +03:00
sen = tcp - > s_ent - > sen ;
if ( SEN_printargs = = sen )
2015-03-22 21:09:55 +03:00
return ;
if ( qual_flags [ tcp - > u_arg [ 0 ] ] & QUAL_READ ) {
2015-07-10 22:24:58 +03:00
switch ( sen ) {
case SEN_read :
case SEN_pread :
case SEN_recv :
case SEN_recvfrom :
2015-03-22 21:09:55 +03:00
dumpstr ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_rval ) ;
return ;
2015-07-10 22:24:58 +03:00
case SEN_readv :
2016-01-20 03:17:02 +03:00
dumpiov_upto ( tcp , tcp - > u_arg [ 2 ] , tcp - > u_arg [ 1 ] ,
tcp - > u_rval ) ;
2015-03-22 21:09:55 +03:00
return ;
2015-07-10 22:24:58 +03:00
case SEN_recvmsg :
2016-01-20 06:26:37 +03:00
dumpiov_in_msghdr ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_rval ) ;
2015-03-22 21:09:55 +03:00
return ;
2015-07-10 22:24:58 +03:00
case SEN_recvmmsg :
2015-03-22 21:09:55 +03:00
dumpiov_in_mmsghdr ( tcp , tcp - > u_arg [ 1 ] ) ;
return ;
}
}
if ( qual_flags [ tcp - > u_arg [ 0 ] ] & QUAL_WRITE ) {
2015-07-10 22:24:58 +03:00
switch ( sen ) {
case SEN_write :
case SEN_pwrite :
case SEN_send :
case SEN_sendto :
2015-03-22 21:09:55 +03:00
dumpstr ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ) ;
2015-07-10 22:24:58 +03:00
break ;
case SEN_writev :
2016-02-14 02:18:15 +03:00
case SEN_vmsplice :
2015-03-22 21:09:55 +03:00
dumpiov ( tcp , tcp - > u_arg [ 2 ] , tcp - > u_arg [ 1 ] ) ;
2015-07-10 22:24:58 +03:00
break ;
case SEN_sendmsg :
2016-01-20 06:26:37 +03:00
dumpiov_in_msghdr ( tcp , tcp - > u_arg [ 1 ] ,
( unsigned long ) - 1L ) ;
2015-07-10 22:24:58 +03:00
break ;
case SEN_sendmmsg :
2015-03-22 21:09:55 +03:00
dumpiov_in_mmsghdr ( tcp , tcp - > u_arg [ 1 ] ) ;
2015-07-10 22:24:58 +03:00
break ;
}
2015-03-22 21:09:55 +03:00
}
}
/*
* Shuffle syscall numbers so that we don ' t have huge gaps in syscall table .
* The shuffling should be an involution : shuffle_scno ( shuffle_scno ( n ) ) = = n .
*/
# if defined(ARM) || defined(AARCH64) /* So far only 32-bit ARM needs this */
static long
shuffle_scno ( unsigned long scno )
{
if ( scno < ARM_FIRST_SHUFFLED_SYSCALL )
return scno ;
/* __ARM_NR_cmpxchg? Swap with LAST_ORDINARY+1 */
if ( scno = = ARM_FIRST_SHUFFLED_SYSCALL )
return 0x000ffff0 ;
if ( scno = = 0x000ffff0 )
return ARM_FIRST_SHUFFLED_SYSCALL ;
# define ARM_SECOND_SHUFFLED_SYSCALL (ARM_FIRST_SHUFFLED_SYSCALL + 1)
/*
* Is it ARM specific syscall ?
* Swap [ 0x000f0000 , 0x000f0000 + LAST_SPECIAL ] range
* with [ SECOND_SHUFFLED , SECOND_SHUFFLED + LAST_SPECIAL ] range .
*/
if ( scno > = 0x000f0000 & &
scno < = 0x000f0000 + ARM_LAST_SPECIAL_SYSCALL ) {
return scno - 0x000f0000 + ARM_SECOND_SHUFFLED_SYSCALL ;
}
if ( scno < = ARM_SECOND_SHUFFLED_SYSCALL + ARM_LAST_SPECIAL_SYSCALL ) {
return scno + 0x000f0000 - ARM_SECOND_SHUFFLED_SYSCALL ;
}
return scno ;
}
# else
# define shuffle_scno(scno) ((long)(scno))
# endif
2015-08-18 10:24:59 +03:00
const char *
syscall_name ( long scno )
2015-03-22 21:09:55 +03:00
{
static char buf [ sizeof ( " syscall_%lu " ) + sizeof ( long ) * 3 ] ;
2015-08-18 10:24:59 +03:00
if ( SCNO_IS_VALID ( scno ) )
return sysent [ scno ] . sys_name ;
else {
sprintf ( buf , " syscall_%lu " , shuffle_scno ( scno ) ) ;
return buf ;
}
2015-03-22 21:09:55 +03:00
}
static long get_regs_error ;
void
clear_regs ( void )
{
get_regs_error = - 1 ;
}
static int get_syscall_args ( struct tcb * ) ;
static int get_syscall_result ( struct tcb * ) ;
2015-11-30 16:57:51 +03:00
static int arch_get_scno ( struct tcb * tcp ) ;
static void get_error ( struct tcb * , const bool ) ;
# if defined X86_64 || defined POWERPC
static int getregs_old ( pid_t ) ;
# endif
2015-03-22 21:09:55 +03:00
static int
trace_syscall_entering ( struct tcb * tcp )
{
int res , scno_good ;
scno_good = res = get_scno ( tcp ) ;
if ( res = = 0 )
return res ;
if ( res = = 1 )
res = get_syscall_args ( tcp ) ;
if ( res ! = 1 ) {
printleader ( tcp ) ;
if ( scno_good ! = 1 )
tprints ( " ???? " /* anti-trigraph gap */ " ( " ) ;
else if ( tcp - > qual_flg & UNDEFINED_SCNO )
2015-08-18 10:24:59 +03:00
tprintf ( " %s( " , syscall_name ( tcp - > scno ) ) ;
2015-03-22 21:09:55 +03:00
else
tprintf ( " %s( " , tcp - > s_ent - > sys_name ) ;
/*
* " <unavailable> " will be added later by the code which
* detects ptrace errors .
*/
goto ret ;
}
2015-04-17 12:14:19 +03:00
# ifdef LINUX_MIPSO32
2015-07-10 22:24:58 +03:00
if ( SEN_syscall = = tcp - > s_ent - > sen )
2015-04-17 12:14:19 +03:00
decode_mips_subcall ( tcp ) ;
# endif
2015-07-10 22:24:58 +03:00
if ( SEN_execve = = tcp - > s_ent - > sen
2015-03-22 21:09:55 +03:00
# if defined(SPARC) || defined(SPARC64)
2015-07-10 22:24:58 +03:00
| | SEN_execv = = tcp - > s_ent - > sen
2015-03-22 21:09:55 +03:00
# endif
) {
hide_log_until_execve = 0 ;
}
# if defined(SYS_socket_subcall) || defined(SYS_ipc_subcall)
2015-07-10 22:24:58 +03:00
switch ( tcp - > s_ent - > sen ) {
2015-03-22 21:09:55 +03:00
# ifdef SYS_socket_subcall
2015-07-10 22:24:58 +03:00
case SEN_socketcall :
2015-03-22 21:09:55 +03:00
decode_socket_subcall ( tcp ) ;
break ;
# endif
# ifdef SYS_ipc_subcall
2015-07-10 22:24:58 +03:00
case SEN_ipc :
2015-03-22 21:09:55 +03:00
decode_ipc_subcall ( tcp ) ;
break ;
# endif
}
# endif
if ( ! ( tcp - > qual_flg & QUAL_TRACE )
| | ( tracing_paths & & ! pathtrace_match ( tcp ) )
) {
tcp - > flags | = TCB_INSYSCALL | TCB_FILTERED ;
2015-07-08 17:10:56 +03:00
tcp - > sys_func_rval = 0 ;
2015-03-22 21:09:55 +03:00
return 0 ;
}
tcp - > flags & = ~ TCB_FILTERED ;
if ( cflag = = CFLAG_ONLY_STATS | | hide_log_until_execve ) {
res = 0 ;
goto ret ;
}
# ifdef USE_LIBUNWIND
if ( stack_trace_enabled ) {
if ( tcp - > s_ent - > sys_flags & STACKTRACE_CAPTURE_ON_ENTER )
unwind_capture_stacktrace ( tcp ) ;
}
# endif
printleader ( tcp ) ;
if ( tcp - > qual_flg & UNDEFINED_SCNO )
2015-08-18 10:24:59 +03:00
tprintf ( " %s( " , syscall_name ( tcp - > scno ) ) ;
2015-03-22 21:09:55 +03:00
else
tprintf ( " %s( " , tcp - > s_ent - > sys_name ) ;
2015-07-10 22:24:58 +03:00
if ( ( tcp - > qual_flg & QUAL_RAW ) & & SEN_exit ! = tcp - > s_ent - > sen )
2015-03-22 21:09:55 +03:00
res = printargs ( tcp ) ;
else
res = tcp - > s_ent - > sys_func ( tcp ) ;
fflush ( tcp - > outf ) ;
ret :
tcp - > flags | = TCB_INSYSCALL ;
2015-07-08 17:10:56 +03:00
tcp - > sys_func_rval = res ;
2015-03-22 21:09:55 +03:00
/* Measure the entrance time as late as possible to avoid errors. */
if ( Tflag | | cflag )
gettimeofday ( & tcp - > etime , NULL ) ;
return res ;
}
static int
trace_syscall_exiting ( struct tcb * tcp )
{
int sys_res ;
struct timeval tv ;
int res ;
long u_error ;
/* Measure the exit time as early as possible to avoid errors. */
if ( Tflag | | cflag )
gettimeofday ( & tv , NULL ) ;
# ifdef USE_LIBUNWIND
if ( stack_trace_enabled ) {
if ( tcp - > s_ent - > sys_flags & STACKTRACE_INVALIDATE_CACHE )
unwind_cache_invalidate ( tcp ) ;
}
# endif
# if SUPPORTED_PERSONALITIES > 1
update_personality ( tcp , tcp - > currpers ) ;
# endif
res = ( get_regs_error ? - 1 : get_syscall_result ( tcp ) ) ;
2015-06-29 14:57:44 +03:00
if ( filtered ( tcp ) | | hide_log_until_execve )
goto ret ;
2015-03-22 21:09:55 +03:00
if ( cflag ) {
count_syscall ( tcp , & tv ) ;
if ( cflag = = CFLAG_ONLY_STATS ) {
goto ret ;
}
}
/* If not in -ff mode, and printing_tcp != tcp,
* then the log currently does not end with output
* of _our syscall entry_ , but with something else .
* We need to say which syscall ' s return is this .
*
* Forced reprinting via TCB_REPRINT is used only by
* " strace -ff -oLOG test/threaded_execve " corner case .
* It ' s the only case when - ff mode needs reprinting .
*/
if ( ( followfork < 2 & & printing_tcp ! = tcp ) | | ( tcp - > flags & TCB_REPRINT ) ) {
tcp - > flags & = ~ TCB_REPRINT ;
printleader ( tcp ) ;
if ( tcp - > qual_flg & UNDEFINED_SCNO )
2015-08-18 10:24:59 +03:00
tprintf ( " <... %s resumed> " , syscall_name ( tcp - > scno ) ) ;
2015-03-22 21:09:55 +03:00
else
tprintf ( " <... %s resumed> " , tcp - > s_ent - > sys_name ) ;
}
printing_tcp = tcp ;
tcp - > s_prev_ent = NULL ;
if ( res ! = 1 ) {
/* There was error in one of prior ptrace ops */
tprints ( " ) " ) ;
tabto ( ) ;
tprints ( " = ? <unavailable> \n " ) ;
line_ended ( ) ;
tcp - > flags & = ~ TCB_INSYSCALL ;
2015-07-08 17:10:56 +03:00
tcp - > sys_func_rval = 0 ;
2015-03-22 21:09:55 +03:00
return res ;
}
tcp - > s_prev_ent = tcp - > s_ent ;
sys_res = 0 ;
if ( tcp - > qual_flg & QUAL_RAW ) {
/* sys_res = printargs(tcp); - but it's nop on sysexit */
} else {
/* FIXME: not_failing_only (IOW, option -z) is broken:
* failure of syscall is known only after syscall return .
* Thus we end up with something like this on , say , ENOENT :
* open ( " doesnt_exist " , O_RDONLY < unfinished . . . >
* { next syscall decode }
* whereas the intended result is that open ( . . . ) line
* is not shown at all .
*/
if ( not_failing_only & & tcp - > u_error )
goto ret ; /* ignore failed syscalls */
2015-07-08 17:10:56 +03:00
if ( tcp - > sys_func_rval & RVAL_DECODED )
sys_res = tcp - > sys_func_rval ;
else
sys_res = tcp - > s_ent - > sys_func ( tcp ) ;
2015-03-22 21:09:55 +03:00
}
tprints ( " ) " ) ;
tabto ( ) ;
u_error = tcp - > u_error ;
if ( tcp - > qual_flg & QUAL_RAW ) {
if ( u_error )
tprintf ( " = -1 (errno %ld) " , u_error ) ;
else
tprintf ( " = %#lx " , tcp - > u_rval ) ;
}
else if ( ! ( sys_res & RVAL_NONE ) & & u_error ) {
switch ( u_error ) {
/* Blocked signals do not interrupt any syscalls.
* In this case syscalls don ' t return ERESTARTfoo codes .
*
* Deadly signals set to SIG_DFL interrupt syscalls
* and kill the process regardless of which of the codes below
* is returned by the interrupted syscall .
* In some cases , kernel forces a kernel - generated deadly
* signal to be unblocked and set to SIG_DFL ( and thus cause
* death ) if it is blocked or SIG_IGNed : for example , SIGSEGV
* or SIGILL . ( The alternative is to leave process spinning
* forever on the faulty instruction - not useful ) .
*
* SIG_IGNed signals and non - deadly signals set to SIG_DFL
* ( for example , SIGCHLD , SIGWINCH ) interrupt syscalls ,
* but kernel will always restart them .
*/
case ERESTARTSYS :
/* Most common type of signal-interrupted syscall exit code.
* The system call will be restarted with the same arguments
* if SA_RESTART is set ; otherwise , it will fail with EINTR .
*/
tprints ( " = ? ERESTARTSYS (To be restarted if SA_RESTART is set) " ) ;
break ;
case ERESTARTNOINTR :
/* Rare. For example, fork() returns this if interrupted.
* SA_RESTART is ignored ( assumed set ) : the restart is unconditional .
*/
tprints ( " = ? ERESTARTNOINTR (To be restarted) " ) ;
break ;
case ERESTARTNOHAND :
/* pause(), rt_sigsuspend() etc use this code.
* SA_RESTART is ignored ( assumed not set ) :
* syscall won ' t restart ( will return EINTR instead )
* even after signal with SA_RESTART set . However ,
* after SIG_IGN or SIG_DFL signal it will restart
* ( thus the name " restart only if has no handler " ) .
*/
tprints ( " = ? ERESTARTNOHAND (To be restarted if no handler) " ) ;
break ;
case ERESTART_RESTARTBLOCK :
/* Syscalls like nanosleep(), poll() which can't be
* restarted with their original arguments use this
* code . Kernel will execute restart_syscall ( ) instead ,
* which changes arguments before restarting syscall .
* SA_RESTART is ignored ( assumed not set ) similarly
* to ERESTARTNOHAND . ( Kernel can ' t honor SA_RESTART
* since restart data is saved in " restart block "
* in task struct , and if signal handler uses a syscall
* which in turn saves another such restart block ,
* old data is lost and restart becomes impossible )
*/
tprints ( " = ? ERESTART_RESTARTBLOCK (Interrupted by signal) " ) ;
break ;
default :
if ( ( unsigned long ) u_error < nerrnos
& & errnoent [ u_error ] )
tprintf ( " = -1 %s (%s) " , errnoent [ u_error ] ,
strerror ( u_error ) ) ;
else
tprintf ( " = -1 ERRNO_%lu (%s) " , u_error ,
strerror ( u_error ) ) ;
break ;
}
if ( ( sys_res & RVAL_STR ) & & tcp - > auxstr )
tprintf ( " (%s) " , tcp - > auxstr ) ;
}
else {
if ( sys_res & RVAL_NONE )
tprints ( " = ? " ) ;
else {
switch ( sys_res & RVAL_MASK ) {
case RVAL_HEX :
# if SUPPORTED_PERSONALITIES > 1
if ( current_wordsize < sizeof ( long ) )
tprintf ( " = %#x " ,
( unsigned int ) tcp - > u_rval ) ;
else
# endif
tprintf ( " = %#lx " , tcp - > u_rval ) ;
break ;
case RVAL_OCTAL :
tprintf ( " = %#lo " , tcp - > u_rval ) ;
break ;
case RVAL_UDECIMAL :
2016-01-07 17:20:17 +03:00
# if SUPPORTED_PERSONALITIES > 1
if ( current_wordsize < sizeof ( long ) )
tprintf ( " = %u " ,
( unsigned int ) tcp - > u_rval ) ;
else
# endif
tprintf ( " = %lu " , tcp - > u_rval ) ;
2015-03-22 21:09:55 +03:00
break ;
case RVAL_DECIMAL :
tprintf ( " = %ld " , tcp - > u_rval ) ;
break ;
case RVAL_FD :
if ( show_fd_path ) {
tprints ( " = " ) ;
printfd ( tcp , tcp - > u_rval ) ;
}
else
tprintf ( " = %ld " , tcp - > u_rval ) ;
break ;
# if defined(LINUX_MIPSN32) || defined(X32)
/*
case RVAL_LHEX :
tprintf ( " = %#llx " , tcp - > u_lrval ) ;
break ;
case RVAL_LOCTAL :
tprintf ( " = %#llo " , tcp - > u_lrval ) ;
break ;
*/
case RVAL_LUDECIMAL :
tprintf ( " = %llu " , tcp - > u_lrval ) ;
break ;
/*
case RVAL_LDECIMAL :
tprintf ( " = %lld " , tcp - > u_lrval ) ;
break ;
*/
# endif
default :
Consistently use error_msg instead of fprintf(stderr)
* linux/alpha/get_scno.c: Use error_msg.
* linux/arm/get_scno.c: Likewise.
* linux/mips/get_scno.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/x86_64/get_scno.c: Likewise.
* exit.c (sys_exit): Likewise.
* pathtrace.c (pathtrace_select, pathtrace_match): Likewise.
* strace.c (alloctcb, droptcb, detach, startup_attach,
test_ptrace_seize, init, cleanup, print_debug_info,
maybe_allocate_tcb, startup_tcb, trace): Likewise.
* syscall.c (update_personality, trace_syscall_exiting,
get_scno): Likewise.
* unwind.c (DPRINTF): Likewise.
* tests/bexecve.test: Update patterns.
* tests/detach-stopped.test: Likewise.
2015-05-26 01:51:19 +03:00
error_msg ( " invalid rval format " ) ;
2015-03-22 21:09:55 +03:00
break ;
}
}
if ( ( sys_res & RVAL_STR ) & & tcp - > auxstr )
tprintf ( " (%s) " , tcp - > auxstr ) ;
}
if ( Tflag ) {
tv_sub ( & tv , & tv , & tcp - > etime ) ;
tprintf ( " <%ld.%06ld> " ,
( long ) tv . tv_sec , ( long ) tv . tv_usec ) ;
}
tprints ( " \n " ) ;
dumpio ( tcp ) ;
line_ended ( ) ;
# ifdef USE_LIBUNWIND
if ( stack_trace_enabled )
unwind_print_stacktrace ( tcp ) ;
# endif
ret :
tcp - > flags & = ~ TCB_INSYSCALL ;
2015-07-08 17:10:56 +03:00
tcp - > sys_func_rval = 0 ;
2015-03-22 21:09:55 +03:00
return 0 ;
}
int
trace_syscall ( struct tcb * tcp )
{
return exiting ( tcp ) ?
trace_syscall_exiting ( tcp ) : trace_syscall_entering ( tcp ) ;
}
2015-09-18 04:54:59 +03:00
bool
is_erestart ( struct tcb * tcp )
{
switch ( tcp - > u_error ) {
case ERESTARTSYS :
case ERESTARTNOINTR :
case ERESTARTNOHAND :
case ERESTART_RESTARTBLOCK :
return true ;
default :
return false ;
}
}
2015-09-18 04:54:59 +03:00
static int saved_u_error ;
void
temporarily_clear_syserror ( struct tcb * tcp )
{
saved_u_error = tcp - > u_error ;
tcp - > u_error = 0 ;
}
void
restore_cleared_syserror ( struct tcb * tcp )
{
tcp - > u_error = saved_u_error ;
}
2015-11-27 04:51:22 +03:00
# include "kernel_types.h"
2015-03-22 21:09:55 +03:00
/*
* Check the syscall return value register value for whether it is
* a negated errno code indicating an error , or a success return value .
*/
static inline bool
is_negated_errno ( kernel_ulong_t val )
{
/* Linux kernel defines MAX_ERRNO to 4095. */
kernel_ulong_t max = - ( kernel_long_t ) 4095 ;
# if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
if ( current_wordsize < sizeof ( val ) ) {
val = ( uint32_t ) val ;
max = ( uint32_t ) max ;
}
# elif defined X32
/*
* current_wordsize is 4 even in personality 0 ( native X32 )
* but truncation _must not_ be done in it .
* can ' t check current_wordsize here !
*/
if ( current_personality ! = 0 ) {
val = ( uint32_t ) val ;
max = ( uint32_t ) max ;
}
# endif
return val > = max ;
}
syscall.c: split arch specific code into separate arch files
Split code that use arch-specific registers to separate arch files.
* syscall.c: Move definitions of variables containing fetched registers
to linux/*/arch_regs.c files.
[HAVE_GETRVAL2] (getrval2): Move arch-specific code
to linux/*/arch_getrval2.c, include "arch_getrval2.c".
(print_pc): Move arch-specific code to linux/*/print_pc.c files,
include "print_pc.c".
[X86_64] (x86_64_getregs_old): Rename to getregs_old, move to
linux/x86_64/getregs_old.c, include "getregs_old.c".
[POWERPC] (powerpc_getregs_old): Rename to getregs_old, move to
linux/powerpc/getregs_old.c, include "getregs_old.c".
(get_regs) [X86_64, POWERPC]: Update callers.
(get_scno): Move arch-specific code to linux/*/get_scno.c,
include "get_scno.c".
(get_syscall_args): Move arch-specific code
to linux/*/get_syscall_args.c, include "get_syscall_args.c".
(get_error): Move arch-specific code to linux/*/get_error.c,
include "get_error.c".
(get_syscall_result): Move arch-specific code
to linux/*/get_syscall_result.c, include "get_syscall_result.c".
* Makefile.am (EXTRA_DIST): Add new linux/*/*.c files.
2015-03-23 01:13:55 +03:00
# include "arch_regs.c"
2000-04-11 02:22:31 +04:00
2015-03-23 03:04:27 +03:00
# ifdef HAVE_GETRVAL2
syscall.c: split arch specific code into separate arch files
Split code that use arch-specific registers to separate arch files.
* syscall.c: Move definitions of variables containing fetched registers
to linux/*/arch_regs.c files.
[HAVE_GETRVAL2] (getrval2): Move arch-specific code
to linux/*/arch_getrval2.c, include "arch_getrval2.c".
(print_pc): Move arch-specific code to linux/*/print_pc.c files,
include "print_pc.c".
[X86_64] (x86_64_getregs_old): Rename to getregs_old, move to
linux/x86_64/getregs_old.c, include "getregs_old.c".
[POWERPC] (powerpc_getregs_old): Rename to getregs_old, move to
linux/powerpc/getregs_old.c, include "getregs_old.c".
(get_regs) [X86_64, POWERPC]: Update callers.
(get_scno): Move arch-specific code to linux/*/get_scno.c,
include "get_scno.c".
(get_syscall_args): Move arch-specific code
to linux/*/get_syscall_args.c, include "get_syscall_args.c".
(get_error): Move arch-specific code to linux/*/get_error.c,
include "get_error.c".
(get_syscall_result): Move arch-specific code
to linux/*/get_syscall_result.c, include "get_syscall_result.c".
* Makefile.am (EXTRA_DIST): Add new linux/*/*.c files.
2015-03-23 01:13:55 +03:00
# include "arch_getrval2.c"
2015-03-06 02:30:02 +03:00
# endif
Optimize out PTRACE_PEEKUSER with -i
strace -i was fetching PC with a separate PEEKUSER
despite having GETREGS data:
ptrace(PTRACE_GETREGS, 22331, 0, 0x8087f00) = 0
ptrace(PTRACE_PEEKUSER, 22331, 4*EIP, [0x80dd7b7]) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22331, 0, SIG_0) = 0
Now it does this:
ptrace(PTRACE_GETREGS, 22549, 0, 0x8087ea0) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22549, 0, SIG_0) = 0
Analogous improvement in sys_sigreturn() is also implemented.
* defs.h: Declare extern struct pt_regs regs for SPARC[64] and ARM.
Declare clear_regs(), get_regs() and get_regs_error flag variable.
* strace.c (trace): Call get_regs(pid) as soon as we know the tcb
and that it is stopped.
* syscall.c (get_regs): New function. Used to fetch registers early,
just after tracee has stopped.
(printcall): Move it here from util.c. Use global regs.REG data,
if available on the arch, instead of re-fetching it.
(get_scno): Use global regs.REG data.
(get_syscall_result): Likewise.
* signal.c (sys_sigreturn): Likewise.
* util.c (printcall): Moved to syscall.c.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-05 19:36:13 +04:00
void
2013-07-01 14:49:14 +04:00
print_pc ( struct tcb * tcp )
Optimize out PTRACE_PEEKUSER with -i
strace -i was fetching PC with a separate PEEKUSER
despite having GETREGS data:
ptrace(PTRACE_GETREGS, 22331, 0, 0x8087f00) = 0
ptrace(PTRACE_PEEKUSER, 22331, 4*EIP, [0x80dd7b7]) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22331, 0, SIG_0) = 0
Now it does this:
ptrace(PTRACE_GETREGS, 22549, 0, 0x8087ea0) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22549, 0, SIG_0) = 0
Analogous improvement in sys_sigreturn() is also implemented.
* defs.h: Declare extern struct pt_regs regs for SPARC[64] and ARM.
Declare clear_regs(), get_regs() and get_regs_error flag variable.
* strace.c (trace): Call get_regs(pid) as soon as we know the tcb
and that it is stopped.
* syscall.c (get_regs): New function. Used to fetch registers early,
just after tracee has stopped.
(printcall): Move it here from util.c. Use global regs.REG data,
if available on the arch, instead of re-fetching it.
(get_scno): Use global regs.REG data.
(get_syscall_result): Likewise.
* signal.c (sys_sigreturn): Likewise.
* util.c (printcall): Moved to syscall.c.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-05 19:36:13 +04:00
{
2015-11-30 06:30:51 +03:00
# if defined ARCH_PC_REG
# define ARCH_GET_PC 0
# elif defined ARCH_PC_PEEK_ADDR
long pc ;
# define ARCH_PC_REG pc
# define ARCH_GET_PC upeek(tcp->pid, ARCH_PC_PEEK_ADDR, &pc)
2015-02-23 16:43:20 +03:00
# else
2015-11-30 06:30:51 +03:00
# error Neither ARCH_PC_REG nor ARCH_PC_PEEK_ADDR is defined
2015-02-15 18:52:02 +03:00
# endif
2015-11-30 06:30:51 +03:00
if ( get_regs_error | | ARCH_GET_PC )
tprints ( current_wordsize = = 4 ? " [????????] "
: " [????????????????] " ) ;
else
tprintf ( current_wordsize = = 4 ? " [%08lx] " : " [%016lx] " ,
( unsigned long ) ARCH_PC_REG ) ;
2013-02-21 18:46:34 +04:00
}
2015-02-14 02:41:04 +03:00
# if defined ARCH_REGS_FOR_GETREGSET
static long
get_regset ( pid_t pid )
2013-03-18 03:48:45 +04:00
{
2015-02-14 02:41:04 +03:00
# ifdef ARCH_IOVEC_FOR_GETREGSET
/* variable iovec */
ARCH_IOVEC_FOR_GETREGSET . iov_len = sizeof ( ARCH_REGS_FOR_GETREGSET ) ;
return ptrace ( PTRACE_GETREGSET , pid , NT_PRSTATUS ,
& ARCH_IOVEC_FOR_GETREGSET ) ;
# else
/* constant iovec */
2013-03-18 14:17:14 +04:00
static struct iovec io = {
. iov_base = & ARCH_REGS_FOR_GETREGSET ,
. iov_len = sizeof ( ARCH_REGS_FOR_GETREGSET )
2013-03-18 03:48:45 +04:00
} ;
2015-02-14 02:41:04 +03:00
return ptrace ( PTRACE_GETREGSET , pid , NT_PRSTATUS , & io ) ;
2013-03-18 14:17:14 +04:00
2013-03-18 03:48:45 +04:00
# endif
2013-03-18 14:17:14 +04:00
}
2015-02-14 02:41:04 +03:00
# endif /* ARCH_REGS_FOR_GETREGSET */
2013-03-18 14:17:14 +04:00
2013-02-16 11:23:40 +04:00
void
get_regs ( pid_t pid )
Optimize out PTRACE_PEEKUSER with -i
strace -i was fetching PC with a separate PEEKUSER
despite having GETREGS data:
ptrace(PTRACE_GETREGS, 22331, 0, 0x8087f00) = 0
ptrace(PTRACE_PEEKUSER, 22331, 4*EIP, [0x80dd7b7]) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22331, 0, SIG_0) = 0
Now it does this:
ptrace(PTRACE_GETREGS, 22549, 0, 0x8087ea0) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22549, 0, SIG_0) = 0
Analogous improvement in sys_sigreturn() is also implemented.
* defs.h: Declare extern struct pt_regs regs for SPARC[64] and ARM.
Declare clear_regs(), get_regs() and get_regs_error flag variable.
* strace.c (trace): Call get_regs(pid) as soon as we know the tcb
and that it is stopped.
* syscall.c (get_regs): New function. Used to fetch registers early,
just after tracee has stopped.
(printcall): Move it here from util.c. Use global regs.REG data,
if available on the arch, instead of re-fetching it.
(get_scno): Use global regs.REG data.
(get_syscall_result): Likewise.
* signal.c (sys_sigreturn): Likewise.
* util.c (printcall): Moved to syscall.c.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-05 19:36:13 +04:00
{
2015-11-30 03:01:01 +03:00
# undef USE_GET_SYSCALL_RESULT_REGS
2015-02-14 02:56:54 +03:00
# ifdef ARCH_REGS_FOR_GETREGSET
# ifdef X86_64
/* Try PTRACE_GETREGSET first, fallback to PTRACE_GETREGS. */
2013-03-18 03:18:35 +04:00
static int getregset_support ;
if ( getregset_support > = 0 ) {
2015-02-14 02:41:04 +03:00
get_regs_error = get_regset ( pid ) ;
2013-03-18 03:18:35 +04:00
if ( getregset_support > 0 )
return ;
if ( get_regs_error > = 0 ) {
getregset_support = 1 ;
return ;
2013-02-14 06:29:48 +04:00
}
2013-03-18 03:18:35 +04:00
if ( errno = = EPERM | | errno = = ESRCH )
return ;
getregset_support = - 1 ;
}
2015-11-30 18:30:05 +03:00
get_regs_error = getregs_old ( pid ) ;
2015-02-14 02:56:54 +03:00
# else /* !X86_64 */
/* Assume that PTRACE_GETREGSET works. */
get_regs_error = get_regset ( pid ) ;
Optimize out PTRACE_PEEKUSER with -i
strace -i was fetching PC with a separate PEEKUSER
despite having GETREGS data:
ptrace(PTRACE_GETREGS, 22331, 0, 0x8087f00) = 0
ptrace(PTRACE_PEEKUSER, 22331, 4*EIP, [0x80dd7b7]) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22331, 0, SIG_0) = 0
Now it does this:
ptrace(PTRACE_GETREGS, 22549, 0, 0x8087ea0) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22549, 0, SIG_0) = 0
Analogous improvement in sys_sigreturn() is also implemented.
* defs.h: Declare extern struct pt_regs regs for SPARC[64] and ARM.
Declare clear_regs(), get_regs() and get_regs_error flag variable.
* strace.c (trace): Call get_regs(pid) as soon as we know the tcb
and that it is stopped.
* syscall.c (get_regs): New function. Used to fetch registers early,
just after tracee has stopped.
(printcall): Move it here from util.c. Use global regs.REG data,
if available on the arch, instead of re-fetching it.
(get_scno): Use global regs.REG data.
(get_syscall_result): Likewise.
* signal.c (sys_sigreturn): Likewise.
* util.c (printcall): Moved to syscall.c.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-05 19:36:13 +04:00
# endif
2015-02-14 02:56:54 +03:00
# elif defined ARCH_REGS_FOR_GETREGS
# if defined SPARC || defined SPARC64
/* SPARC systems have the meaning of data and addr reversed */
get_regs_error = ptrace ( PTRACE_GETREGS , pid , ( char * ) & ARCH_REGS_FOR_GETREGS , 0 ) ;
# elif defined POWERPC
static bool old_kernel = 0 ;
if ( old_kernel )
goto old ;
get_regs_error = ptrace ( PTRACE_GETREGS , pid , NULL , & ARCH_REGS_FOR_GETREGS ) ;
if ( get_regs_error & & errno = = EIO ) {
old_kernel = 1 ;
old :
syscall.c: split arch specific code into separate arch files
Split code that use arch-specific registers to separate arch files.
* syscall.c: Move definitions of variables containing fetched registers
to linux/*/arch_regs.c files.
[HAVE_GETRVAL2] (getrval2): Move arch-specific code
to linux/*/arch_getrval2.c, include "arch_getrval2.c".
(print_pc): Move arch-specific code to linux/*/print_pc.c files,
include "print_pc.c".
[X86_64] (x86_64_getregs_old): Rename to getregs_old, move to
linux/x86_64/getregs_old.c, include "getregs_old.c".
[POWERPC] (powerpc_getregs_old): Rename to getregs_old, move to
linux/powerpc/getregs_old.c, include "getregs_old.c".
(get_regs) [X86_64, POWERPC]: Update callers.
(get_scno): Move arch-specific code to linux/*/get_scno.c,
include "get_scno.c".
(get_syscall_args): Move arch-specific code
to linux/*/get_syscall_args.c, include "get_syscall_args.c".
(get_error): Move arch-specific code to linux/*/get_error.c,
include "get_error.c".
(get_syscall_result): Move arch-specific code
to linux/*/get_syscall_result.c, include "get_syscall_result.c".
* Makefile.am (EXTRA_DIST): Add new linux/*/*.c files.
2015-03-23 01:13:55 +03:00
get_regs_error = getregs_old ( pid ) ;
2015-02-14 02:56:54 +03:00
}
# else
/* Assume that PTRACE_GETREGS works. */
get_regs_error = ptrace ( PTRACE_GETREGS , pid , NULL , & ARCH_REGS_FOR_GETREGS ) ;
# endif
# else /* !ARCH_REGS_FOR_GETREGSET && !ARCH_REGS_FOR_GETREGS */
2015-11-30 03:01:01 +03:00
# define USE_GET_SYSCALL_RESULT_REGS 1
# warning get_regs is not implemented for this architecture yet
2015-02-14 02:56:54 +03:00
get_regs_error = 0 ;
# endif
Optimize out PTRACE_PEEKUSER with -i
strace -i was fetching PC with a separate PEEKUSER
despite having GETREGS data:
ptrace(PTRACE_GETREGS, 22331, 0, 0x8087f00) = 0
ptrace(PTRACE_PEEKUSER, 22331, 4*EIP, [0x80dd7b7]) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22331, 0, SIG_0) = 0
Now it does this:
ptrace(PTRACE_GETREGS, 22549, 0, 0x8087ea0) = 0
write(3, "[080dd7b7] ioctl(0, SNDCTL_TMR_T"..., 82) = 82
ptrace(PTRACE_SYSCALL, 22549, 0, SIG_0) = 0
Analogous improvement in sys_sigreturn() is also implemented.
* defs.h: Declare extern struct pt_regs regs for SPARC[64] and ARM.
Declare clear_regs(), get_regs() and get_regs_error flag variable.
* strace.c (trace): Call get_regs(pid) as soon as we know the tcb
and that it is stopped.
* syscall.c (get_regs): New function. Used to fetch registers early,
just after tracee has stopped.
(printcall): Move it here from util.c. Use global regs.REG data,
if available on the arch, instead of re-fetching it.
(get_scno): Use global regs.REG data.
(get_syscall_result): Likewise.
* signal.c (sys_sigreturn): Likewise.
* util.c (printcall): Moved to syscall.c.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-05 19:36:13 +04:00
}
2015-11-30 04:46:52 +03:00
/*
* Returns :
2012-03-21 03:23:16 +04:00
* 0 : " ignore this ptrace stop " , bail out of trace_syscall_entering ( ) silently .
* 1 : ok , continue in trace_syscall_entering ( ) .
* other : error , trace_syscall_entering ( ) should print error indicator
2011-08-21 20:03:23 +04:00
* ( " ???? " etc ) and bail out .
*/
2015-03-21 19:51:52 +03:00
int
2011-08-24 19:53:52 +04:00
get_scno ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
2015-03-23 21:48:32 +03:00
if ( get_regs_error )
return - 1 ;
2015-11-30 04:46:52 +03:00
int rc = arch_get_scno ( tcp ) ;
if ( rc ! = 1 )
return rc ;
2009-02-25 20:08:40 +03:00
2013-02-21 19:13:47 +04:00
if ( SCNO_IS_VALID ( tcp - > scno ) ) {
2015-11-30 04:46:52 +03:00
tcp - > s_ent = & sysent [ tcp - > scno ] ;
tcp - > qual_flg = qual_flags [ tcp - > scno ] ;
2013-02-21 19:13:47 +04:00
} else {
2013-02-22 16:26:10 +04:00
static const struct_sysent unknown = {
2013-02-21 19:13:47 +04:00
. nargs = MAX_ARGS ,
. sys_flags = 0 ,
. sys_func = printargs ,
2015-04-07 13:46:59 +03:00
. sys_name = " system call " ,
2013-02-21 19:13:47 +04:00
} ;
tcp - > s_ent = & unknown ;
tcp - > qual_flg = UNDEFINED_SCNO | QUAL_RAW | DEFAULT_QUAL_FLAGS ;
2015-03-24 04:59:07 +03:00
if ( debug_flag )
2015-11-30 04:46:52 +03:00
error_msg ( " pid %d invalid syscall %ld " , tcp - > pid , tcp - > scno ) ;
2013-02-21 19:13:47 +04:00
}
2000-02-01 20:58:41 +03:00
return 1 ;
}
2015-11-30 03:01:01 +03:00
# ifdef USE_GET_SYSCALL_RESULT_REGS
2015-11-30 16:57:51 +03:00
static int get_syscall_result_regs ( struct tcb * ) ;
2015-11-30 03:01:01 +03:00
# endif
2010-03-29 21:51:02 +04:00
2015-03-22 21:09:55 +03:00
/* Returns:
* 1 : ok , continue in trace_syscall_exiting ( ) .
* - 1 : error , trace_syscall_exiting ( ) should print error indicator
* ( " ???? " etc ) and bail out .
*/
static int
get_syscall_result ( struct tcb * tcp )
2010-03-29 21:51:02 +04:00
{
2015-11-30 03:01:01 +03:00
# ifdef USE_GET_SYSCALL_RESULT_REGS
if ( get_syscall_result_regs ( tcp ) )
return - 1 ;
2015-03-22 21:09:55 +03:00
# endif
2015-11-29 03:06:45 +03:00
tcp - > u_error = 0 ;
get_error ( tcp , ! ( tcp - > s_ent - > sys_flags & SYSCALL_NEVER_FAILS ) ) ;
2015-03-22 21:09:55 +03:00
return 1 ;
2010-03-29 21:51:02 +04:00
}
2015-11-30 16:57:51 +03:00
# include "get_scno.c"
# include "get_syscall_args.c"
# ifdef USE_GET_SYSCALL_RESULT_REGS
# include "get_syscall_result.c"
# endif
# include "get_error.c"
# if defined X86_64 || defined POWERPC
# include "getregs_old.c"
# endif