Commit Graph

1510 Commits

Author SHA1 Message Date
Wang Chao
ca8ab8d295 Handle followfork using ptrace_setoptions if available
If PTRACE_O_TRACECLONE et al options are supported by kernel,
use them to do followfork rather than the original setbpt
method that changes registers ourselves.

* defs.h [LINUX] (handle_new_child): New function prototype.
* process.c [LINUX] (handle_new_child): New function based on the
code from internal_fork(), with a trivial change: do reparent only
for sys_clone.
[LINUX] (internal_fork): Use handle_new_child().  Do nothing if
ptrace_setoptions is in effect.
* strace.c [LINUX] (handle_ptrace_event): New function.
[LINUX] (trace): If ptrace_setoptions is in effect, then
call the new function to handle PTRACE_EVENT_* status, and
set PTRACE_SETOPTIONS when we see the initial stop of tracee.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
2010-11-30 17:19:09 +00:00
Wang Chao
b13c0de058 Test how PTRACE_SETOPTIONS support works
Currently test fork related options only.  Fork a child that uses
PTRACE_TRACEME at startup and then does a fork so strace can test
how the PTRACE_SETOPTIONS support works before it handles any real
tracee.  Since PTRACE_O_TRACECLONE/*FORK were introduced to kernel
at the same time, this test seems to be enough for these 3 options.

* defs.h [LINUX]: Define PTRACE_O_TRACECLONE et al macros here.
(ptrace_setoptions): New variable declaration.
* strace.c [LINUX] (test_ptrace_setoptions): New function, tests
whether kernel supports PTRACE_O_CLONE/*FORK, the result is stored
in the new variable ptrace_setoptions for later use.
(main): Call test_ptrace_setoptions() if followfork option is set.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
2010-11-30 17:19:09 +00:00
09fa7f8765 Enable support for less verbose build rules
* configure.ac (AM_INIT_AUTOMAKE): Add silent-rules.
2010-09-17 23:40:01 +04:00
Wang Chao
e636c85165 Do not trace children cloned with CLONE_UNTRACED flag
If clone is called with flag CLONE_UNTRACED, to be consistent with
option PTRACE_O_TRACECLONE, we should not set CLONE_PTRACE flag on
its arguments.

* process.c [LINUX] (internal_fork): Check the syscall and arguments.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
2010-09-17 16:54:52 +00:00
cbaaf79911 Update the list of CLOCK_* constants to match Linux kernel v2.6.32+
* time.c (struct xlat clocknames[]): Add more RT clock IDs.
Reported by Tommi Rantala.
2010-09-17 09:19:49 +00:00
336a35fd43 Update linux/hppa/syscallent.h to match Linux kernel v2.6.35
* linux/hppa/syscallent.h: Add hooks for recvmmsg and accept4.
2010-09-16 16:48:45 +00:00
35d0572a12 Pass less information to qualify_one and qual_*
* syscall.c (qualify_one, qual_syscall, qual_signal, qual_fault,
qual_desc): Take just a bitflag argument instead of pointer to the whole
qual_options structure.
(struct qual_options): Update prototype of "qualify" field.
(qualify): Update use of qualify_one and qual_options->qualify.
2010-09-15 16:34:53 +00:00
Wang Chao
0ef43b8189 Fix -e option with only one value in qualifier statement
Fix regression introduced by commit v4.5.20-19-g30145dd:
if -e option is used with only one value in qualifier statement,
e.g. 'strace -e trace=open ls', syscall information would not be
printed properly.

* syscall.c (qualify): Remove faulty optimization.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2010-09-15 16:32:02 +00:00
Mike Frysinger
584ba2d31d Fix off_t/rlim_t size checks when cross-compiling
The current off_t/rlim_t size checks (wrt size of long long) use AC_RUN
which obviously doesn't work when cross-compiling.  While we don't hit
any configure errors, the fall back code is pretty dumb (which is to say
there isn't any).  Considering the code in question though, we can use
some fun compiler tricks with sizeof and array lengths to turn it into
a pure build test and avoid the RUN issue completely.

* m4/long_long.m4 (AC_OFF_T_IS_LONG_LONG, AC_RLIM_T_IS_LONG_LONG):
Convert from AC_RUN_IFELSE to AC_COMPILE_IFELSE.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-09-15 15:36:00 +00:00
Mike Frysinger
6d12afdac4 Fix long long little endian detection when cross-compiling
The long long endian detection code does an AC_TRY_RUN() and since that
doesn't work when cross-compiling, it sets a fallback value.  However,
rather than do any sort of default endian detection, the code simply
sets it to "no".  This probably breaks most little endian systems out
there when cross-compiling for them.  It certainly breaks Blackfin
systems.  So use the common endian detection code provided by autoconf
and key off of that when cross-compiling.

* configure.ac: Call AC_C_BIGENDIAN.
* m4/long_long.m4 (AC_LITTLE_ENDIAN_LONG_LONG): Set cross-compiling
logic based on ac_cv_c_bigendian.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-09-15 15:36:00 +00:00
Mike Frysinger
260e571343 Blackfin: decode new syscalls
* linux/bfin/syscallent.h: Add fanotify/prlimit/cacheflush syscalls.
* linux/syscall.h: Add sys_cacheflush() decl.
* system.c: Decode Blackfin's cacheflush syscall.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-09-15 15:36:00 +00:00
Mike Frysinger
1b30f4b7b7 * linux/ioctlent.sh: Search a few non-exported paths.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-09-15 15:36:00 +00:00
Roland McGrath
54e931fb85 Clean up pid2tcb usage
* strace.c (pid2tcb): Always match pid.  Fail for argument <= 0.
[USE_PROCFS] (first_used_tcb): New function.
[USE_PROCFS] (trace): Use that instead of pid2tcb(0).
2010-09-14 19:03:37 -07:00
1ed5d80ed8 Turn on more compiler warnings
* configure.ac: Enable gcc -Wwrite-strings.
2010-09-09 23:20:27 +00:00
918e49bac7 Import warnings.m4 from gnulib
* m4/warnings.m4: Replace with warnings.m4 from gnulib.
* configure.ac: Use gl_WARN_ADD from new warnings.m4.
* Makefile.am (AM_CFLAGS): Update for new warnings.m4.
2010-09-09 23:20:25 +00:00
916adeda63 Split acinclude.m4
* Makefile.am (ACLOCAL_AMFLAGS): Add "-I m4".
* acinclude.m4: Remove.
* m4/includedir.m4: New file, with definition of AC_INCLUDEDIR from
acinclude.m4.
* m4/long_long.m4: New file, with definitions of AC_OFF_T_IS_LONG_LONG,
AC_RLIM_T_IS_LONG_LONG and AC_LITTLE_ENDIAN_LONG_LONG from acinclude.m4.
* m4/procfs.m4: New file, with definitions of AC_MP_PROCFS,
AC_POLLABLE_PROCFS and AC_STRUCT_PR_SYSCALL from acinclude.m4.
* m4/stat.m4: New file, with definition of AC_STAT64 from acinclude.m4.
* m4/statfs.m4: New file, with definition of AC_STATFS64 from
acinclude.m4.
* m4/warnings.m4: New file, with definition of AC_WARNFLAGS from
acinclude.m4.
2010-09-09 23:20:24 +00:00
3eb9491673 * process.c (sys_waitid): Remove unused variable. 2010-09-09 23:20:10 +00:00
30145dda9d Fix const-correctness issues uncovered by gcc -Wwrite-strings
* defs.h (struct xlat): Add const qualifier to the field of
type "char *".
(set_sortby, qualify, printnum, printnum_int): Add const qualifier to
arguments of type "char *".
* count.c (set_sortby): Add const qualifier to the argument and
automatic variable of type "char *".
* desc.c (decode_select): Add const qualifier to automatic variables of
type "char *".
* ioctlsort.c (struct ioctlent): Add const qualifier to fields of
type "char *".
(main):  Add const qualifier to argv.
* process.c (printargv): Add const qualifier to the argument and
automatic variable of type "char *".
(printargc) Add const qualifier to argument of type "char *".
* signal.c (sprintsigmask, parse_sigset_t): Add const qualifier to
arguments of type "char *".
* strace.c (progname): Add const qualifier.
(detach): Add const qualifier to automatic variable of type "char *".
* stream.c (struct strbuf): Add const qualifier to the field of
type "char *".
* syscall.c (struct qual_options): Add const qualifier to fields of
type "char *".
(qual_syscall, qual_fault, qual_desc, lookup_class): Add const qualifier
to arguments of type "char *".
(qual_signal): Add const qualifier to the argument of type "char *",
avoid modification of constant argument.
(qualify): Likewise.
* util.c (printflags): Add const qualifier to automatic variable of
type "char *".
(printnum, printnum_int): Add const qualifier to arguments of
type "char *".
2010-09-07 00:59:18 +00:00
Wang Chao
cbdd1900a1 Fix printing clone flags
When we trace clone() syscall with only exit signal as clone
flags, strace would print an unnecessary OR operator.

* process.c (sys_clone): Fix this.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
2010-09-04 11:05:45 +00:00
Wang Chao
21b8db4eb9 Drop nclone_detached and related flags
Remove nclone_detached since CLONE_DETACHED flag was no-op for a very
long time in kernel.

* defs.h (struct tcb): Remove nclone_detached field.
Remove TCB_CLONE_DETACHED flag.
* process.c: Remove CLONE_DETACHED flag.
(clone_flags): Remove CLONE_DETACHED entry.
(internal_fork, internal_wait): Remove code dealing with CLONE_DETACHED
flag and nclone_detached.
* strace.c (startup_attach, alloc_tcb, droptcb, handle_group_exit):
Likewise.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
2010-08-28 22:36:54 +00:00
Neil Campbell
ffd2b30926 Correct get/set_robust_list syscall numbers for powerpc
* linux/powerpc/syscallent.h: Swap positions of get_ and set_robust_list.
2010-08-09 21:29:01 +00:00
Wang Chao
5a22b31a60 Handle CLONE_PARENT flag
* process.c (internal_fork): The parent of new cloned process is the
same of the calling process when CLONE_PARENT is set.
2010-08-09 21:29:00 +00:00
Wang Chao
304ea5f067 Fix error when judging if process has children
* process.c (internal_wait): Processes counted in tcp->nclone_threads
are tcp's threads, rather than tcp's children.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
2010-08-09 21:29:00 +00:00
Wang Chao
d322a4bbe1 Forbid using mutually exclusive options -D and -p together
If we use -D and -p option together to trace a multi-thread program, in
addition to the main thread, other threads could not be traced even if we
present -f option. Moreover, when executing 'strace -D -p <non-exist pid>',
strace could not terminate normally.

* strace.c (main): Check it.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
2010-08-09 21:28:35 +00:00
David Daney
670f51126a Update Linux MIPS syscalls to match 2.6.35-rc6+
* linux/mips/syscallent.h: Add and update 405 hooks.
2010-08-05 20:12:53 +00:00
Edgar E. Iglesias
939caba68e Add support for the MicroBlaze architecture
* configure.ac: Recognize MicroBlaze.
* linux/microblaze/syscallent.h: New file.
* Makefile.am (EXTRA_DIST): Add linux/microblaze/syscallent.h
* process.c (change_syscall, struct_user_offsets): Add MicroBlaze
support.
* signal.c (sys_sigreturn): Likewise.
* syscall.c (internal_syscall, get_scno, syscall_fixup, get_error,
syscall_enter): Likewise.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-05 20:04:50 +00:00
Frederik Schüler
b7915d15b8 linux/sparc: add missing syscall declarations
* linux/sparc/syscall.h: Sync with linux/syscall.h

Signed-off-by: Frederik Schüler <fs@debian.org>
2010-08-05 23:48:49 +04:00
Andreas Schwab
ee81c8a571 Handle biarch get/setrlimit
* resource.c (print_rlimit32) [POWERPC64 || X86_64]: Define.
(sys_getrlimit, sys_setrlimit) [POWERPC64 || X86_64]: Use it.
2010-07-17 17:46:28 +02:00
Andreas Schwab
d69fa497f4 Add biarch support for powerpc64
* acinclude.m4 (AC_LITTLE_ENDIAN_LONG_LONG): Use int instead of
long.
* configure.ac [$host_cpu = powerpc*]: Also define POWERPC64 if
$host_cpu = powerpc64.
* defs.h (SUPPORTED_PERSONALITIES, PERSONALITY0_WORDSIZE)
(PERSONALITY1_WORDSIZE) [POWERPC64]: Define.
* file.c: (struct stat_powerpc32, printstat_powerpc32) [POWERPC64]:
Define.
(printstat) [LINUX && POWERPC64]: Use printstat_powerpc32 in
32-bit personality.
(sys_newfstatat) [POWERPC64]: Handle personalities.
* signal.c (sys_sigreturn) [POWERPC64]: Likewise.
* util.c (printllval) [POWERPC64]: Likewise.
(printcall) [POWERPC64]: Use wider format for IP prefix.
* syscall.c (get_scno) [POWERPC64]: Check for 64/32 bit mode.
* linux/powerpc/errnoent1.h: New file.
* linux/powerpc/ioctlent1.h: New file.
* linux/powerpc/signalent1.h: New file.
* linux/powerpc/syscallent1.h: New file.
2010-07-13 19:13:03 +02:00
Andreas Schwab
372cc84c97 Balance braces
* strace.c (proc_open): Avoid unbalanced braces.
(trace): Likewise.
2010-07-09 12:01:17 +02:00
Andreas Schwab
102e69a3ea Remove extern declaration at file scope
* defs.h (force_result): Declare.
* process.c (internal_wait): Don't declare force_result.
2010-07-06 19:40:25 +02:00
Andreas Schwab
b87d30c785 Document -C/-D
* strace.c (usage): Document -C.
* strace.1: Document -D.
2010-06-24 17:14:01 +02:00
Roland McGrath
f47fa96b2b Fix sourceforge download URL. 2010-06-13 03:12:18 -07:00
Andreas Schwab
246888d239 M68K: Fix fetching syscall arguments
* syscall.c (syscall_enter) [M68K]: Properly handle more than five
syscall arguments.
2010-06-05 21:50:30 +02:00
Andreas Schwab
5874322739 Decode TLS syscalls on m68k
* linux/m68k/syscallent.h: Add entries for get_thread_area,
set_thread_area, atomic_comxchg_32, atomic_barrier.
* linux/dummy.h (sys_get_thread_area, sys_set_thread_area) [M68K]:
Don't redefine.
* mem.c (sys_get_thread_area, sys_set_thread_area) [LINUX && M68K]: New.
2010-05-28 22:28:51 +02:00
Andreas Schwab
ffca9e30d6 Fix warning when compiling for m68k
* syscall.c (d0): Define as long.
2010-05-28 20:53:14 +02:00
acbe51899a Prepare for 4.5.20 release
* NEWS: Update for 4.5.20 release.
* configure.ac: Version 4.5.20.
* debian/changelog: 4.5.20-1.
* strace.spec: 4.5.20-1.
2010-04-13 16:09:23 +00:00
Frederik Schüler
0c56f62207 Update debian/* files for the upcoming release
* debian/control: update standards-version to 3.8.4.
* debian/rules: allow parallel building.
* debian/rules: comment out verbose build, only needed for debugging.
* debian/rules: clean up clean: target, dh_clean does most of the work
  already.
* debian/rules: use *-stamp instead of stamp-*, so dh_clean can tidy
  up for us.

Signed-off-by: Frederik Schüler <fs@debian.org>
2010-04-13 16:07:31 +00:00
Heiko Carstens
394f60c07e Fix s390 system call table list
* linux/s390/syscallent.h: Add the missing entries for preadv and
pwritev to the system call table list.
* linux/s390x/syscallent.h: Likewise.
2010-04-13 15:15:47 +00:00
ae4db5e1bb Update linux/ioctlent.h
* linux/ioctlent.sh: Search in asm-generic directory as well.
* linux/ioctlent.h: Regenerated.
2010-04-07 11:34:29 +00:00
623003918a Update linux/*/syscallent.h files to match Linux kernel v2.6.33
* linux/alpha/syscallent.h: Add 47 hooks.
* linux/arm/syscallent.h: Update hooks for pselect6, ppoll,
epoll_pwait.  Add 11 hooks.
* linux/bfin/syscallent.h: Update hooks for prctl, fallocate,
signalfd4, eventfd2, epoll_create1, dup3, pipe2, perf_event_open.
Hook up recvmmsg.
* linux/hppa/syscallent.h: Update hooks for signalfd4, eventfd2,
epoll_create1, dup3, pipe2, perf_event_open.
* linux/i386/syscallent.h: Fix syscall name for the kexec_load hook.
Add 5 hooks.
* linux/ia64/syscallent.h: Fix syscall name for the kexec_load hook.
Add 4 hooks.
* linux/m68k/syscallent.h: Add 50 hooks.
* linux/powerpc/syscallent.h: Fix hook for timerfd_create.  Fix
6 syscall names to match the kernel.  Use sys_semop to parse semop.
Add 14 hooks.
* linux/s390/syscallent.h: Fix syscall name for the kexec_load hook.
Add 14 hooks.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Add 13 hooks.
* linux/sh64/syscallent.h: Add 15 hooks.
* linux/sparc/syscallent.h: Add 22 hooks.
* linux/x86_64/syscallent.h: Add 5 hooks.
2010-04-07 10:19:27 +00:00
e659103147 Enhance recvmmsg parser
* net.c (sys_recvmmsg): Decode mmsghdr structure on exit from the
syscall.  Decode timespec structure both on entrance and on exit.
2010-04-07 10:19:27 +00:00
Andreas Schwab
0873f29af4 Decode recvmmsg syscall
* net.c (do_msghr): New function to print struct msghdr.
(printmsghdr): Use it.
(printmmsghdr, sys_recvmmsg): New.
* linux/syscall.h: Declare sys_recvmmsg.
(SYS_sub_recvmmsg): Define.
(SYS_socket_nsubcalls): Bump.
* linux/sparc/syscall.h: Likewise.
* linux/arm/syscallent.h: Add sys_recvmmsg.
* linux/bfin/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/m68k/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/ia64/syscallent.h: Adjust.
2010-04-07 10:19:27 +00:00
a7835e631a * strace.1: Fix quoting of hyphens and formatting of strace options. 2010-04-07 10:19:26 +00:00
7d7c963d79 Split trace_syscall() for better readability
* syscall.c (trace_syscall): Split into trace_syscall_exiting() and
trace_syscall_entering().
2010-04-07 10:19:26 +00:00
e3a7ef5a2a Implement -C option to combine regular and -c output
* defs.h (cflag_t): New enum.
* strace.1: Document -C option.
* strace.c (cflag): Update type.
(main): Handle -C option.
(trace): Update use of cflag.
* count.c (count_syscall): Move clearing of TCB_INSYSCALL to ...
* syscall.c (trace_syscall): ... here.  Update use of cflag.
Based on patch by Adrien Kunysz.
2010-04-07 10:19:26 +00:00
c94a774a3b Fix "make dist" regression introduced by commit v4.5.19-12-g5078770
* Makefile.am (EXTRA_DIST): Rename linux/syscallent.h to linux/i386/syscallent.h
2010-04-07 10:17:50 +00:00
9676499f89 * desc.c (sys_epoll_pwait): Fix output formatting bug. 2010-04-07 00:05:04 +00:00
6e63375495 * desc.c (decode_select): Fix potential stack buffer overflow. 2010-04-07 00:05:01 +00:00
4310a375e9 Fix msgsnd indirect ipccall decoding
This regression was introduced by commit v4.5.18-136-g783f5bc.
* ipc.c (tprint_msgsnd): Add and use "flags" argument.
(sys_msgsnd): Pass "flags" argument to tprint_msgsnd().
Patch by Anton Blanchard.
2010-03-31 22:22:01 +00:00