Dmitry V. Levin [Tue, 18 Jan 2011 17:36:20 +0000 (17:36 +0000)]
Fix decoding of get[ug]id, gete[ug]id and setfs[ug]id return values
* defs.h (SYSCALL_NEVER_FAILS): New syscall flag.
* linux/dummy.h: Change redirection for sys_get[ug]id, sys_gete[ug]id
and setfs[ug]id.
* linux/*/syscallent.h: Set SYSCALL_NEVER_FAILS flag for get[ug]id,
gete[ug]id and setfs[ug]id syscalls.
* process.c [LINUX] (sys_getuid, sys_setfsuid): New functions.
* syscall.c (NF): New shorthand macro for use in syscallent.h files.
(get_error): Check SYSCALL_NEVER_FAILS flag.
Reported by Марк Коренберг <socketpair@gmail.com>.
Dmitry V. Levin [Sun, 16 Jan 2011 23:07:51 +0000 (23:07 +0000)]
block.c: cleanup
* block.c: Include <inttypes.h>.
(print_blkpg_req): Always decode struct blkpg_ioctl_arg.
Robustify decoding of strings.
(block_ioctl): Do not decode return values passed by pointers on exit
from failed syscalls.
Use format macros from inttypes.h to print values of type uint64_t.
Dmitry V. Levin [Sat, 15 Jan 2011 20:15:31 +0000 (20:15 +0000)]
Add block ioctl support
* block.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h [LINUX] (block_ioctl): New function.
* ioctl.c (ioctl_decode) [LINUX]: Use it to decode HDIO_* and BLK*
ioctls.
Patch by Jeff Mahoney <jeffm@suse.com>
Dmitry V. Levin [Thu, 13 Jan 2011 14:49:39 +0000 (14:49 +0000)]
Test PTRACE_O_TRACECLONE and PTRACE_O_TRACEVFORK along with PTRACE_O_TRACEFORK
* strace.c (test_ptrace_setoptions): Add PTRACE_O_TRACECLONE and
PTRACE_O_TRACEVFORK to PTRACE_SETOPTIONS call, to test exactly
the same set of options that is going to be used later in trace().
Carmelo AMOROSO [Tue, 4 Jan 2011 15:30:40 +0000 (16:30 +0100)]
sh: Add entry for not-multiplexed accept4
* linux/sh/syscallent.h: Add specific entry for not-multiplexed accept4
available in kernel mainline since v2.6.37-rc6, see
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=21b6e4c7106b2d68a6710506d8706608272fd78b
Carmelo AMOROSO [Mon, 13 Dec 2010 07:48:28 +0000 (08:48 +0100)]
sh: Fix compilation warning in do_pipe due to missing prototype
* defs.h [SH]: Make getrval2 prototype visible to do_pipe
and fix the following compiler warning:
.../net.c: In function 'do_pipe':
.../net.c:1632: warning: implicit declaration of function 'getrval2'
.../net.c:1632: warning: format '%lu' expects type 'long unsigned int',
but argument 3 has type 'int'
Dmitry V. Levin [Tue, 7 Dec 2010 12:50:49 +0000 (12:50 +0000)]
Fix strace -f -o '|command' hangup
* strace.c (main): Call test_ptrace_setoptions() before parsing
-o option, otherwise a forked command will cause a hangup inside
test_ptrace_setoptions().
Wang Chao [Fri, 12 Nov 2010 09:26:08 +0000 (17:26 +0800)]
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>
Wang Chao [Fri, 12 Nov 2010 09:25:19 +0000 (17:25 +0800)]
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>
* 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.
Wang Chao [Wed, 15 Sep 2010 03:37:38 +0000 (11:37 +0800)]
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.
Mike Frysinger [Sun, 12 Sep 2010 08:01:47 +0000 (04:01 -0400)]
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.
Mike Frysinger [Sun, 12 Sep 2010 07:39:55 +0000 (03:39 -0400)]
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.
Roland McGrath [Wed, 15 Sep 2010 01:59:20 +0000 (18:59 -0700)]
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).
* 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.
* 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.
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 *".
Wang Chao [Thu, 5 Aug 2010 06:30:11 +0000 (14:30 +0800)]
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>
Frederik Schüler [Tue, 13 Apr 2010 11:04:00 +0000 (13:04 +0200)]
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.
Dmitry V. Levin [Sun, 28 Mar 2010 19:24:54 +0000 (19:24 +0000)]
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.
Dmitry V. Levin [Wed, 31 Mar 2010 22:22:01 +0000 (22:22 +0000)]
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.