History log of /external/strace/strace.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d35df493b4e7684c50d2d2fa032ee3a7ac228009 16-Feb-2017 Elliott Hughes <enh@google.com> Upgrade strace to 4.16 from 4.14.

Noteworthy changes in release 4.16 (2017-02-14)

* Improvements
* Implemented syscall return value injection (-e inject=SET:retval= option).
* Implemented signal injection (-e inject=SET:signal= option).
* Implemented decoding of SUID_DUMP_* constants in PR_[GS]ET_DUMPABLE.
* Implemented decoding of all SG_* ioctl commands.
* Implemented decoding of ustat syscall.
* Implemented decoding of BPF_OBJ_PIN, BPF_OBJ_GET, BPF_PROG_ATTACH,
and BPF_PROG_DETACH commands of bpf syscall.
* Enhanced decoding of sg_io_hdr and sg_io_v4 structures.
* Enhanced decoding of get_robust_list, getrandom, io_submit, set_robust_list
syscalls.
* Enhanced decoding of entities of kernel long type on x32 and mips n32 ABIs.
* Updated lists of IP_*, IPV6_*, and LOOP_* constants.
* Updated lists of ioctl commands from Linux 4.10.
* Added decoding of recently added syscalls on avr32, microblaze, ppc,
and ppc64.

* Bug fixes
* Fixed pathmatch of oldselect syscall on 64-bit architectures.
* Fixed decoding of mmap2 syscall on s390 when arguments are not available.
* Fixed decoding of kexec_file_load, mprotect, pkey_mprotect, prctl, preadv*,
and pwritev* syscalls on x32.
* Fixed printing of string arguments of getxattr and setxattr syscalls
when -s option is used to limit the printed string size.
* Fixed decoding of ifconf, ifreq, and loop_info structures on non-native
personalities.
* Fixed decoding of SG_* and LOOP_* ioctl commands.
* Fixed build on mips with musl libc.
* Fixed cross-building of ioctlsort.
* Applied minor formatting fixes to the manual page.

Noteworthy changes in release 4.15 (2016-12-14)

* Changes in behavior
* Time stamps are now printed according to ISO 8601.
* Changed output format of val3 parameter of futex FUTEX_WAKE_OP operation.
* The last argument of mincore, sched_getaffinity, and sched_setaffinity
syscalls is now formatted as an array.

* Improvements
* Implemented syscall fault injection (-e fault=... option).
* Implemented decoding of DM_* ioctl commands.
* Implemented decoding of attr parameter of perf_event_open syscall.
* Implemented decoding of pkey_alloc, pkey_free, and pkey_mprotect syscalls.
* Implemented dumping of mq_timedsend and mq_timedreceive syscalls.
* Implemented decoding of PR_SET_FP_MODE and PR_GET_FP_MODE operations
of prctl syscall.
* Implemented PTRACE_GETREGS API support on m68k.
* Updated lists of ARCH_*, BPF_*, BTRFS_*, FALLOC_*, MS_*, *_MAGIC,
and V4L2_* constants.
* Updated lists of ioctl commands from Linux 4.9.
* Added decoding of recently added syscalls on arc, x32, and xtensa.
* Enhanced manual page.

* Bug fixes
* Fixed corner cases in decoding of exit, exit_group, futimesat, getgroups,
getresuid, init_module, inotify_init1, kcmp, kexec_load, lookup_dcookie,
mq_getsetattr, mq_notify, mq_open, mq_timedreceive, mq_timedsend,
name_to_handle_at, prctl, process_vm_readv, process_vm_writev, setfsuid,
setgroups, setns, unshare, and utimes syscalls.
* Fixed handling of verbose flag in printing of controls array
of struct v4l2_ext_controls.
* Fixed omission of field names in the output of capability, sigaction,
sigevent, statfs, timespec, timeval, and utimbuf structures.
* Fixed printing of unknown syscalls in siginfo structure.
* Fixed decoding of ioctl constants on m68k.
* Fixed cris architecture support.
* Fixed cross build when host compiler does not support the same
set of warning flags as the cross compiler.
* Fixed build on SLE10 and SLE11.

Bug: N/A
Test: manual
Change-Id: I590bf5db1652aa1dfdc0eb16e30fd97c82af2261
/external/strace/strace.c
ae914db459696e385f4af380fae0652793d6178a 30-Aug-2016 Dmitry V. Levin <ldv@altlinux.org> Remove redundant check for PTRACE_LISTEN availability

As ptrace.h already ensures that PTRACE_LISTEN is defined,
there is no need to check this fact in other places.

* strace.c (ptrace_restart): Do not check that PTRACE_LISTEN is defined.
/external/strace/strace.c
b4a32f9e57b0009a36bf0eaf9cc9be4457020276 30-Aug-2016 James Clarke <jrtc27@jrtc27.com> Use PTRACE_SUNDETACH everywhere on SPARC and SPARC64

SPARC has a different PTRACE_DETACH value correctly defined in
sys/ptrace.h, but linux/ptrace.h clobbers it with the standard one.
PTRACE_SUNDETACH is also defined to the correct value by sys/ptrace.h,
so use that instead.

* strace.c (detach) [SPARC]: Move redefinition of PTRACE_DETACH
to PTRACE_SUNDETACH ...
* ptrace.h [SPARC || SPARC64]: ... here.
/external/strace/strace.c
559ec3e06db4e20ade6f38dcf54c3312ee22616d 14-Aug-2016 Dmitry V. Levin <ldv@altlinux.org> Fix leakage of placeholder descriptors to tracees

As a side effect of commit v4.11-211-g0736d4e, strace used to leak
placeholders for standard descriptors to tracees thus affecting their
behaviour. Fix this by setting close-on-exec flag on placeholder
descriptors.

* strace.c (open_dummy_desc): Set close-on-exec flag on the descriptor
that is going to be returned to the caller.
(fd_is_placeholder): New array.
(ensure_standard_fds_opened, redirect_standard_fds): New functions.
(startup_child): Use redirect_standard_fds.
(init): Use ensure_standard_fds_opened.
/external/strace/strace.c
b9bc216fddd7bf714c495031d6abd407fe381705 29-Jul-2016 Dmitry V. Levin <ldv@altlinux.org> Set exit status to 1 if strace has not traced any processes

* strace.c (main): Initialize exit_code with 1 when no processes
has been attached.
* strace.1: Document it.
* NEWS: Mention this change.
/external/strace/strace.c
2ddb73ddd3ce1b3dabbe4dcafeaabbb04dd90d06 25-Jul-2016 Dmitry V. Levin <ldv@altlinux.org> Attach to the target process before attempting to attach to its siblings

* strace.c (attach_tcb): Attach to tcp->pid first.
/external/strace/strace.c
c9251518b005cc5adb3cc2ba1d68856ec8e94ad2 25-Jul-2016 Dmitry V. Levin <ldv@altlinux.org> Report the name of ptrace command when ptrace_attach_or_seize fails.

* strace.c (ptrace_attach_cmd): New variable.
(ptrace_attach_or_seize): Save last ptrace command's name
to ptrace_attach_cmd.
(attach_tcb, startup_child): Use it in error diagnostics.
/external/strace/strace.c
795795ae995bf7dde1d2b6dff611097a632eb1bc 25-Jul-2016 Dmitry V. Levin <ldv@altlinux.org> strace.c: refactor startup_attach

* strace.c (startup_attach): Move the inner part of the big loop
over tcbtab elements ...
(attach_tcb): ... to this new function.
/external/strace/strace.c
bbfeea269e07acbea973e22d9ea5f4dcb5f34948 29-Jul-2016 Dmitry V. Levin <ldv@altlinux.org> startup_attach: do not use atoi

* strace.c (startup_attach): Replace atoi with string_to_uint.
/external/strace/strace.c
82ffa78acd7ce9b593b5bbb3e89a519a1edff297 26-Jul-2016 Dmitry V. Levin <ldv@altlinux.org> Fix casts of ptrace's third argument

* strace.c (maybe_allocate_tcb): Replace "(char *) 0" with NULL
as ptrace's third argument.
* linux/sparc64/get_scno.c (arch_get_scno): Cast third argument
of ptrace to "void *'.
* syscall.c (get_regs): Likewise.
* upeek.c (upeek): Likewise.
* util.c (umoven): Likewise.
/external/strace/strace.c
a1546a9550bb46bc8847da7d6432c8de0c3352c3 24-Aug-2015 Patrik Jakobsson <patrik.jakobsson@linux.intel.com> Add private data field to struct tcb

We need to be able to store private data in the struct tcb across it's
lifetime. To ensure proper deallocation of this stored data a callback
must be provided along with the data. The callback is executed
automatically on exiting syscall, and when the life of the tcb ends.

* defs.h (struct tcb): Add _priv_data and _free_priv_data fields.
(get_tcb_priv_data, set_tcb_priv_data, free_tcb_priv_data):
New prototypes.
(get_tcb_priv_ulong, set_tcb_priv_ulong): New static inline functions.
* strace.c (get_tcb_priv_data, set_tcb_priv_data, free_tcb_priv_data):
New functions.
(droptcb): Call free_tcb_priv_data.
* syscall.c (trace_syscall_exiting): Call free_tcb_priv_data
when clearing TCB_INSYSCALL flag.

Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
/external/strace/strace.c
7429dcab47043db995615c2b45f75e29218a9d01 13-Jun-2016 Elvira Khabirova <lineprinter0@gmail.com> strace.c: fix style in function definition

* strace.c (kill_save_errno): Move the type of return value
to another line.
/external/strace/strace.c
45a5a623183afc72092d21f2814424d67de2a695 13-Jun-2016 Elvira Khabirova <lineprinter0@gmail.com> strace.c: fix a warning reported by -Wold-style-definition

* strace.c (usage): Add void to the list of function argments.
/external/strace/strace.c
e6d2b566aaccd93d426abf6207855fb8da88aed9 26-May-2016 Fabien Siron <fabien.siron@epita.fr> Fix -yy documentation

* strace.c (usage): Fix description of -yy option.
* strace.1: Likewise.
/external/strace/strace.c
f9199ab081b2eb22f2fd73c372d65eb2451ede37 13-May-2016 Dmitry V. Levin <ldv@altlinux.org> printsiginfo: remove "verbose" argument

Remove erroneous use of verbose(tcp) as a printing limit
for already fetched members of siginfo_t structure.

* printsiginfo.h (printsiginfo): Remove boolean argument.
* printsiginfo.c (printsigval): Remove boolean argument, print
si_int and si_ptr members unconditionally. All callers changed.
(print_si_info): Remove boolean argument, print si_utime and si_stime
members unconditionally. All callers changed.
(printsiginfo): Remove boolean argument. All callers changed.
/external/strace/strace.c
c811fa61155576b21fe17f00445ba764f3ff6674 05-Mar-2016 Nahim El Atmani <naam@lse.epita.fr> Reduce memory usage while managing tcbs allocation.

* strace.c (init): Remove initial memory allocation for tcbtab.
(expand_tcbtab): Do initial memory allocation when tcbtabsize == 0.

Signed-off-by: Nahim El Atmani <nahim+dev@naam.me>
Reviewed-By: Gabriel Laskar <gabriel@lse.epita.fr>
Reported-by: haris iqbal <haris.phnx@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
/external/strace/strace.c
6aedd422065afebfaa850dbbec0db7940f52e193 08-Feb-2016 Dmitry V. Levin <ldv@altlinux.org> Create a dummy pipe descriptor instead of opening /dev/null

* strace.c (open_dev_null): Rename to open_dummy_desc. All callers
changed. Create a pipe and return its first descriptor instead of
opening /dev/null.
/external/strace/strace.c
0736d4e1a31d5cf04fb6cb4b73b6e0a70b13df45 08-Feb-2016 Denys Vlasenko <dvlasenk@redhat.com> If stdin/stdout aren't open on startup, open them to /dev/null

Otherwise, -oLOGFILE may end up using one of them. This conflicts
with the previous change, which closes stdin/out in strace.

* strace.c (init): If fcntl(F_GETFD) fails on stdin or stdout,
sanitize them: open /dev/null and dup it until fds 0,1,2
are all used up.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
c9f85b38766a0e14f4f035f6d702fe57b6b9110c 08-Feb-2016 Denys Vlasenko <dvlasenk@redhat.com> Close stdin/out after child is forked

Testcase:

{ sleep 1; yes | head -n99999; } | strace -o/dev/null sh -c 'exec <&-; sleep 9'

The writer (head) will be able to perform writes to write end of the pipe.
With strace call removed, head will immediately get SIGPIPE.

This change fixes this: now writer immediately gets SIGPIPE with strace too.

* strace.c (startup_child): Close stdin/out and reopen them to /dev/null.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
fa8c286d50d83ae86d2ca8df52f7aba8b6c5bae1 22-Jan-2016 Dmitry V. Levin <ldv@altlinux.org> Implement simultaneous use of -p option and tracing of a command

* strace.c (init): Allow -p option along with a command.
(startup_child): In -D mode, record the parent of the tracer process
as strace_child.
(startup_attach): Save trace_tracer_pid before -D mode fork.
When tracing a command in -f mode, do not check for the command's
threads as it has no threads at this moment.
Never attach to the tracer process.
In -D mode, never attach to the parent of the tracer process,
terminate that process only once at the end of startup_attach,
and reset strace_child.
* strace.1: Document that -p option can be used along with tracing
of a command.
* NEWS: Mention it.
* tests/attach-p-cmd-cmd.c: New file.
* tests/attach-p-cmd-p.c: Likewise.
* tests/attach-p-cmd.test: New test.
* tests/.gitignore: Add attach-p-cmd-cmd and attach-p-cmd-p.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add attach-p-cmd.test.

This fixes Debian bug #549942.
/external/strace/strace.c
a2fdfe96d517b2187b6707c09cde3d1ffcf3ee9c 26-Nov-2015 Elvira Khabirova <lineprinter0@gmail.com> Refer to -h on incorrect usage

* defs.h (error_msg_and_help): New prototype.
* strace.c (error_msg_and_help): New function.
(error_opt_arg, init): Use it.
(usage): Remove unnecessary arguments.
* count.c: Use the new function.
/external/strace/strace.c
3272d2902c6f3e64d26cf459ca0a5ee17181f792 26-Nov-2015 Elvira Khabirova <lineprinter0@gmail.com> Rearrange flags descriptions in the usage text

* strace.c (usage): Rearrange descriptions.
* tests/strace-k.test: Change the option detecting regexp accordingly.
/external/strace/strace.c
bb746ff8035119abc2f98a9fc88741124d1d9f39 26-Nov-2015 Dmitry V. Levin <ldv@altlinux.org> startup_attach: fix compilation warning

* strace.c (startup_attach): Split single error_msg statement with
variable number of arguments to silence a compilation warning.
/external/strace/strace.c
135f5cf634b2fbf3b10f3f5c9c596418fbd07273 18-Sep-2015 Dmitry V. Levin <ldv@altlinux.org> Properly initialize siginfo_t object passed to print_stopped function

* strace.c (trace): Clear the whole siginfo_t variable before passing it
to ptrace(PTRACE_GETSIGINFO) because the latter may initialize only a
part of the structure.
/external/strace/strace.c
0e946ab2c26f3cb6f27cb99ddf0f5581bef16781 18-Jul-2015 Dmitry V. Levin <ldv@altlinux.org> defs.h: do not include <signal.h>

* printsiginfo.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h: Do not include <signal.h>.
(printsiginfo): Remove.
* printsiginfo.c: Include <signal.h> and "printsiginfo.h".
* strace.c: Likewise.
* sigaltstack.c: Include <signal.h>.
* signal.c: Likewise.
* sigreturn.c: Likewise.
* time.c: Likewise.
/external/strace/strace.c
de4a680206b0a811c3b5b3c17b74a6a3cc3f273f 29-Jun-2015 Dmitry V. Levin <ldv@altlinux.org> Fix -qq option in conjunction with -o option

This change makes -qq option work in conjunction with -o option,
thus complementing commit v4.7-222-g01997cf.

* strace.c (init): Do not reset qflag.
/external/strace/strace.c
6c8ef051f726138b07f6d1ac50c32ffcd6f7996a 26-May-2015 Dmitry V. Levin <ldv@altlinux.org> 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.
/external/strace/strace.c
3e9d71feaad428f0f8e335f83b86e9f2a16781fb 25-May-2015 Dmitry V. Levin <ldv@altlinux.org> 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.
/external/strace/strace.c
5647cf86fc511fc365675826ab4ff56775d1206b 30-Mar-2015 Dmitry V. Levin <ldv@altlinux.org> Use macros for gcc attributes

* defs.h (error_msg, perror_msg, error_msg_and_die, perror_msg_and_die,
die_out_of_memory, printllval, printnum_int, printnum_long, tprintf):
Use ATTRIBUTE_* macros for gcc attributes.
* file.c (struct stat64): Likewise.
* statfs.c (struct compat_statfs64): Likewise.
* strace.c (die, exec_or_die, init): Likewise.
* linux/sparc/arch_sigreturn.c: Likewise.
* linux/ubi-user.h: Likewise.
/external/strace/strace.c
364728dba0faa53e14666830f9c4f2cf99893b83 21-Mar-2015 Denys Vlasenko <dvlasenk@redhat.com> Move the comment about termination logic where it belongs

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
4bb2ffd46445416f99dc673de5ba3da5fc23baf7 21-Mar-2015 Denys Vlasenko <dvlasenk@redhat.com> startup_tcb() never fails, remove code which checks for failures

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
8497b6222ed8ef606996d0ceb2bae260d82f95e2 21-Mar-2015 Denys Vlasenko <dvlasenk@redhat.com> Show the syscall name in "resuming interrupted call" message

When signal is received, or if we have attached to a process,
current syscall (if process is in one) gets restarted.

Some syscalls are restarted via "restart_syscall()" mechanism.
On such sycalls, we don't show _which_ syscall gets restarted.

IOW: users want to see "resuming interrupted nanosleep"
instead of "resuming interrupted call" when they attach to "sleep 999".

Kernel does expose this information. The only thing we need is
to fetch syscall# on attach, and save it.

This patch does this. It adds tcp->s_prev_ent, which is
a pointer to struct_sysent of the previous syscall of this tracee.
It can be NULL.

sys_restart_syscall() is made to use it when the message is generated.

To similarly handle restart_syscall() *after signals*, not just
on attach, on each syscall exit patch saves exited syscall's data
in the same member (tcp->s_prev_ent).

Example:

$ sleep 3 & strace -p $!
Process 8728 attached
restart_syscall(<... resuming interrupted nanosleep ...>) = 0
_exit(0) = ?
+++ exited with 0 +++

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
1dbd39e85f567740dc00bae126741bdb9c2d777a 28-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> Fix stack buffer overflow when specified command is too long

* strace.c (startup_child): Check that the length of the command strace
is going to execute does not exceed PATH_MAX limit.

Reported-by: Cheolung Lee <chpie@grayhash.com>
/external/strace/strace.c
23ce9e48b54bd8bfec5b8768c85173fe4038ebac 08-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> Remove support for systems without PTRACE_SETOPTIONS

Assume that the kernel is v2.5.46 or newer, i.e. PTRACE_SETOPTIONS
and PTRACE_O_TRACESYSGOOD|PTRACE_O_TRACEEXEC|PTRACE_O_TRACECLONE
are universally available.

This change removes all code that implemented post-execve SIGTRAP
handling and fork/vfork/clone->CLONE_PTRACE substitution.

* defs.h (TCB_BPTSET, TCB_WAITEXECVE): Remove macros.
(need_fork_exec_workarounds, setbpt, clearbpt): Remove declarations.
* strace.c (need_fork_exec_workarounds,
test_ptrace_setoptions_followfork, test_ptrace_setoptions_for_all):
Remove.
(syscall_trap_sig): Set to (SIGTRAP | 0x80).
(ptrace_setoptions): Set to (PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEEXEC).
(detach): Do not test for TCB_BPTSET.
(init): Do not call test_ptrace_setoptions_followfork and
test_ptrace_setoptions_for_all. Do not test for TCB_BPTSET.
* syscall.c (syscall_fixup_on_sysenter, internal_fork, internal_exec,
syscall_fixup_for_fork_exec, syscall_fixup_on_sysexit): Remove.
(trace_syscall_entering): Do not test for TCB_WAITEXECVE. Do not call
syscall_fixup_on_sysenter and syscall_fixup_for_fork_exec.
(trace_syscall_exiting): Do not call syscall_fixup_on_sysexit and
syscall_fixup_for_fork_exec.
[IA64] (ia64_ia32mode): Make static.
* linux/ia64/arch_regs.h (ia64_ia32mode): Remove declaration.
* util.c: Do not include "syscall.h".
(arg_setup, get_arg0, get_arg1, set_arg0, set_arg1, restore_arg0,
restore_arg1, arg_finish_change, change_syscall, setbpt, clearbpt):
Remove.
* tests/ptrace_setoptions.test: Remove.
* tests/Makefile.am (TESTS): Remove it.
/external/strace/strace.c
0f4ad30bdcb284a8e874b3d9345cb203c8cc5209 22-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> Fix build with old kernel headers

* strace.c (print_debug_info, maybe_allocate_tcb, print_signalled,
print_exited): Remove "const" qualifier from status variable to
workaround some old implementations of WIFSIGNALED/WIFSTOPPED/WIFEXITED
macros.
* v4l2.c: Include <linux/types.h>.
(v4l2_ioctl): Check that V4L2_CTRL_FLAG_NEXT_CTRL and VIDIOC_S_EXT_CTRLS
macros are defined.
* tests/Makefile.am (AM_CPPFLAGS): Define.
/external/strace/strace.c
e9bfff6de6f30aa7c84a4636dd7c5e4938c19b3a 13-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> Do not reset get_regs_error unnecessarily

As get_regs() is now guaranteed to set get_regs_error,
there is no need to reset get_regs_error before get_regs() call.

* strace.c (trace): Call clear_regs() iff !WIFSTOPPED.
/external/strace/strace.c
5503dd28c6cab61af949f592e8bfcdaf1380cfef 13-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> Move regs-related macros and declarations from defs.h to regs.h

* regs.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/arch_regs.h: New file.
* linux/alpha/arch_regs.h: Likewise.
* linux/arm/arch_regs.h: Likewise.
* linux/hppa/arch_regs.h: Likewise.
* linux/i386/arch_regs.h: Likewise.
* linux/ia64/arch_regs.h: Likewise.
* linux/mips/arch_regs.h: Likewise.
* linux/powerpc/arch_regs.h: Likewise.
* linux/sh64/arch_regs.h: Likewise.
* linux/sparc/arch_regs.h: Likewise.
* linux/sparc64/arch_regs.h: Likewise.
* linux/tile/arch_regs.h: Likewise.
* linux/x86_64/arch_regs.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.
* defs.h: Remove definitions of PTRACE_*, REG_*, PT_*, U_REG_*,
and ARM_* macros.
Remove declarations of struct pt_regs variables.
[SPARC]: Do not include <asm/psr.h>.
[SPARC64]: Do not include <asm/psrcompat.h>.
* bjm.c: Do not include <sys/user.h>.
* process.c: Include "regs.h".
Do not include <sys/user.h> and <sys/reg.h>.
[IA64]: Do not include <asm/ptrace_offsets.h> and <asm/rse.h>.
* util.c: Likewise.
* syscall.c: Likewise.
[AARCH64]: Define struct arm_pt_regs and ARM_* macros.
[SPARC]: Include <asm/psr.h>.
[SPARC64]: Include <asm/psrcompat.h>.
* signal.c: Include "regs.h".
Do not include <sys/user.h> and <sys/reg.h>.
[IA64]: Do not include <asm/ptrace_offsets.h>.
* strace.c [IA64]: Do not include <asm/ptrace_offsets.h>.
/external/strace/strace.c
fadf379b8e3618585cecad447867af27930ac5e3 13-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> Move all ptrace-related macros and declarations from defs.h to ptrace.h

* ptrace.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* configure.ac (AC_CHECK_HEADERS): Remove linux/ptrace.h and sys/ptrace.h.
* defs.h: Do not include <sys/ptrace.h> and <asm/ptrace.h>.
Remove definitions of PTRACE_* macros.
* process.c: Remove <linux/ptrace.h> workarounds, include "ptrace.h".
* signal.c: Likewise.
* syscall.c: Likewise.
* util.c: Likewise.
* strace.c: Include "ptrace.h".
* wait.c: Likewise.
/external/strace/strace.c
2cd488b2590dc695d98260cb13bf8188420c3a8a 07-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> When the process stared by strace exits/terminates, forget its pid

The process stared by strace can exit/terminate only once. When this
happens, forget its pid, so that any other event or action related to a
process with the same pid as the pid of that first process would not be
confused with that first process.

* strace.c (print_signalled, print_exited): Clear strace_child when it
equals to the given pid.
/external/strace/strace.c
aa80192e79b2f49e104461148bbd745a49c74d2d 07-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> -b execve: avoid misleading warning about unknown pid

* strace.c (maybe_allocate_tcb): If detach_on_execve is set, do not warn
about !WIFSTOPPED process with pid == strace_child.
* tests/bexecve.test: New test.
* tests/Makefile.am (TESTS): Add it.
/external/strace/strace.c
e69081359a7d22a951683ad42e3f1dbbc91fd8de 07-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> -b execve: do not use struct tcb after detach

* strace.c (trace): Do not proceed after detach.
/external/strace/strace.c
4b4ec120875a8884f7d1b4a86c1639df1bb9cdbe 07-Feb-2015 Dmitry V. Levin <ldv@altlinux.org> trace: split into several functions

This change moves the main loop back to main() and splits trace()
into several functions. There are no algorithmic changes.

* strace.c (print_debug_info, maybe_allocate_tcb, maybe_switch_tcbs,
print_signalled, print_exited, print_stopped, startup_tcb): New
functions.
(trace) Use them. Move the main loop ...
(main): ... here.
/external/strace/strace.c
025b3581ae241150dfc8e24f6a7bae413f8c72b2 21-Nov-2014 Dmitry V. Levin <ldv@altlinux.org> Replace MAXPATHLEN with PATH_MAX

MAXPATHLEN is defined to PATH_MAX, so replace the former with the latter.

* strace.c (startup_child): Replace MAXPATHLEN with PATH_MAX.
* util.c (printpathn, printpath): Likewise.
/external/strace/strace.c
2f6510c8a6a358ec00f56a491318181bc068a1fc 21-Aug-2014 Dmitry V. Levin <ldv@altlinux.org> Add -yy option: print ip and port associated with socket descriptors

When two ore more -y options are given, print local and remote ip:port
pairs associated with socket descriptors. This implementation uses
NETLINK_INET_DIAG for sockaddr lookup; it's based on the patch
prepared by Zubin Mithra as a part of his GSoC 2014 strace project.

* Makefile.am (strace_SOURCES): Add socketutils.c
(EXTRA_DIST): Add linux/inet_diag.h and linux/sock_diag.h.
* defs.h (print_sockaddr_by_inode): New prototype.
* linux/inet_diag.h: New file.
* linux/sock_diag.h: Likewise.
* socketutils.c: Likewise.
* strace.1: Document -yy option.
* strace.c (usage): Likewise.
* util.c (printfd): Use print_sockaddr_by_inode.
/external/strace/strace.c
3ed5d021837768405d9f9c9e7d2b05dc6a110d94 10-Sep-2014 Dmitry V. Levin <ldv@altlinux.org> Fix compilation warnings reported by gcc -Wsign-compare

* configure.ac (gl_WARN_ADD): Add -Wsign-compare.
* defs.h (struct tcb): Change 'currpers' type to unsigned.
(struct xlat): Change 'val' type to unsigned
(signame): Add 'const' qualifier to its argument.
(xlookup, printxval): Add 'const' qualifier to the 2nd argument and
change its type to unsigned.
(printpathn): Change the 3rd argument type to unsigned.
(ioctl_lookup): Change 1st argument type to unsigned.
* count.c (call_summary_pers, call_summary): Change 'i' type to unsigned.
* file.c (print_xattr_list): Fix comparisons between signed and unsigned
long values.
* ioctl.c (compare): Fix cast.
(ioctl_lookup): Change 1st argument type to to unsigned.
(ioctl_next_match): Change 'code' type to unsigned.
* mem.c (sys_move_pages): Change 'i' type to unsigned.
* mtd.c (mtd_ioctl): Change 'i' and 'j' types to unsigned.
Print 'i' using %u format string.
* process.c (sys_prctl): Change 'i' type to unsigned.
(printargv): Change 'n' type to unsigned.
(sys_ptrace): Change 'addr' type to unsigned.
* scsi.c (print_sg_io_buffer): Add 'const' qualifier to 'len' argument
and change its type to unsigned. Change 'i' and 'allocated' types
to unsigned.
* signal.c (signame): Add 'const' qualifier to its argument.
Fix comparisons between signed and unsigned values.
(sprintsigmask_n, printsiginfo): Fix comparisons between signed and
unsigned values.
* sock.c (sock_ioctl): Change 'i' and 'nifra' types to unsigned.
* strace.c (expand_tcbtab, alloctcb): Change 'i' type to unsigned.
(detach): Change 'sig' type to unsigned.
(startup_attach): Change 'tcbi' type to unsigned.
(startup_child): Change 'm', 'n', and 'len' types to unsigned.
(init): Use new variable to iterate 'tcbtab'.
(pid2tcb): Change 'i' type to unsigned.
(cleanup): Change 'i' and 'sig' types to unsigned.
* syscall.c (update_personality): Change 'personality' argument type
to unsigned.
(struct qual_options): Change 'bitflag' type to unsigned.
(reallocate_qual): Add 'const' qualifier to its argument and change its
type to unsigned.
(qualify_one): Change 'n' and 'bitflag' arguments types to unsigned.
Add 'const' qualifier to 'n', 'not', and 'pers' arguments.
Change 'p' type to signed int.
(qual_syscall): Change 'bitflag' argument type to unsigned.
Add 'const' qualifier to 'bitflag' and 'not' arguments.
Change 'p' type to signed int.
(qual_signal): Change 'bitflag' argument type to unsigned.
Add 'const' qualifier to 'bitflag' and 'not' arguments.
Change 'i' type to unsigned.
(qual_desc): Change 'bitflag' argument type to unsigned.
Add 'const' qualifier to 'bitflag' and 'not' arguments.
(qualify): Change 'i' type to unsigned.
(get_scno): Change 'currpers' type to unsigned.
Fix a comparison between signed and unsigned values.
* system.c (sys_sysctl): Change 'cnt' and 'max_cnt' types to unsigned.
Fix comparisons between signed and unsigned values.
* util.c (xlookup, printxval): Add 'const' qualifier to 'val' argument
and change its type to unsigned.
(printuid): Fix a comparison between signed and unsigned values.
(printpathn): Change 'n' argument type to unsigned.
(printstr): Change 'size' type to unsigned.
Fix a comparison between signed and unsigned values.
(setbpt): Change 'i' type to unsigned.
* net.c (printsock): Silence a compilation warning.
* reboot.c (sys_reboot): Likewise.
/external/strace/strace.c
45e7b189e2aeae06bcd1807453bde99463d8e589 09-Aug-2014 Dmitry V. Levin <ldv@altlinux.org> Prepare for -yy option support

* defs.h (show_fd_path): Change type to unsigned int.
* strace.c (show_fd_path): Likewise.
(init): Handle repeated -y option.
/external/strace/strace.c
2734a7010fb24dbcad3c55565d08c5c9b81f8624 18-Jun-2014 Dmitry V. Levin <ldv@altlinux.org> Document -k option as experimental

strace -k does not produce a reliable output on all supported
configurations yet, even basic strace-k.test is known to fail
on some of them.

* strace.c (usage): Document -k option as experimental.
* strace.1: Likewise.
* NEWS: Likewise.
/external/strace/strace.c
2727aae37c56eb2620699388513ef5bbb0af2b7e 03-Jun-2014 Dmitry V. Levin <ldv@altlinux.org> Warn about flags that have no effect with -c

* strace.c (init): Issue a warning if -i, -k, -r, -t, -T, or -y is used
along with -c.
This fixes Debian bug #443895.
/external/strace/strace.c
2b09df9731f97685b4c06e34ce4ff5f1686eb4c1 16-Apr-2014 Masatake YAMATO <yamato@redhat.com> unwind: call unwind_tcb_fin before printing detached message

captured stacktrace is printed in unwind_tcb_fin if tcp->queue is not
empty. This should happen before printing detached message, so
unwind_tcb_fin is moved to the top of droptcb.

This is implicitly suggested by Dmitry Levin in patch review process.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
/external/strace/strace.c
6141392856a170c9297783e6bfbd9fd970f76fdf 16-Apr-2014 Masatake YAMATO <yamato@redhat.com> unwind: give all exported functions "unwind_" prefix

* unwind.c (init_unwind_addr_space): Rename to unwind_init.
(init_libunwind_ui): Rename to unwind_tcb_init.
(free_libunwind_ui): Rename to unwind_tcb_fin.
(delete_mmap_cache): Rename to unwind_cache_invalidate.
(print_stacktrace): Rename to unwind_print_stacktrace.
* defs.h: Update prototypes.
* mem.c: All callers updated.
* process.c: Likewise.
* strace.c: Likewise.
* syscall.c: Likewise.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
/external/strace/strace.c
7721499fc7ea15cbf2f7d4f89c9502e325b451fc 16-Apr-2014 Masatake YAMATO <yamato@redhat.com> unwind: delete mmap cache in free_libunwind_ui

free_libunwind_ui is expected to release all unwind related resources
attached to tcp.

* strace.c (droptcb): Move delete_mmap_cache call ...
* unwind.c (free_libunwind_ui): ... to here.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
/external/strace/strace.c
327064b63722a4400058e0e7e9b39d9e34b14b57 23-Jul-2013 Luca Clementi <luca.clementi@gmail.com> Add -k option to print stack trace after each syscall

Print the stack trace of the traced process after each system call when
-k option is specified. It is implemented using libunwind to unwind the
stack and to obtain the function name pointed by the IP.

Based on the code that was originally taken from strace-plus
of Philip J. Guo.

* configure.ac: Add --with-libunwind option. Check libunwind support.
* Makefile.am: Add libunwind support.
* defs.h (struct tcb) [USE_LIBUNWIND]: Append libunwind specific fields.
[USE_LIBUNWIND] (stack_trace_enabled, alloc_mmap_cache,
delete_mmap_cache, print_stacktrace): New prototypes.
* mem.c (print_mmap, sys_munmap, sys_mprotect): Add libunwind support.
* process.c (sys_execve): Likewise.
* strace.c (usage, alloctcb, droptcb, init): Likewise.
* syscall.c (trace_syscall_exiting): Likewise.
* unwind.c: New file.
* strace.1: Document -k option.
/external/strace/strace.c
e53bf23f1c33076090b51184b82af4dd98d0c51c 28-May-2014 Mark Hills <Mark.Hills@framestore.com> Optionally produce stats on syscall latency

Time spent in system time is not useful where a syscall depends on some
non-CPU resource, eg. typically open() or stat() to a network drive.

This patch adds a new flag (-w) to produce a summary of the time
difference between beginning and end of the system call (ie. latency)

This functionality has been useful to profile slow processes that
are not CPU-bound.

Signed-off-by: Mark Hills <mark.hills@framestore.com>
/external/strace/strace.c
329fa3919d0da95ec32949c2092dc40dac6a9d5b 10-Apr-2014 Denys Vlasenko <dvlasenk@redhat.com> Make int3 example in comments more cut-n-pastable

I found that I use it quite often. Lets make it so that
after cut-n-pasting it into a file, there is no need
to edit the result (e.g. no need to remove C comment
chars from every line.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
d354130b3ac060051b55cda46c45ab5f5574548d 26-Feb-2014 Dmitry V. Levin <ldv@altlinux.org> Fix build with Bionic libc

Add generic tests for fopen64 and fputs_unlocked functions to fix build
with Bionic libc that does not provide them.

* configure.ac (AC_CHECK_FUNCS): Add fopen64 and fputs_unlocked.
* strace.c [_LARGEFILE64_SOURCE]: Use fopen instead of fopen64
if !HAVE_FOPEN64.
Use fputs instead of fputs_unlocked if !HAVE_FPUTS_UNLOCKED.
* vsprintf.c: Use fputs instead of fputs_unlocked
if !HAVE_FPUTS_UNLOCKED.

Reported-by: Elliott Hughes <enh@google.com>
/external/strace/strace.c
0506f0f430c15677c7724f9c4500093e0e7e15d3 12-Nov-2013 Dmitry V. Levin <ldv@altlinux.org> Stop using _LFS64_LARGEFILE

There is only one place left in the code where strace guesses whether
libc provides LFS64 functions and structures. The most natural thing to
do there is to check for _LARGEFILE64_SOURCE - the macro provided by
glibc. Other libc implementations that provide nondegenerate LFS64
interfaces are expected to define this macro as well.

* defs.h (_LFS64_LARGEFILE): Remove.
* strace.c: Use _LARGEFILE64_SOURCE instead of _LFS64_LARGEFILE.
/external/strace/strace.c
a34deadbb3419909d691de514a298f6b748f2d95 12-Jul-2013 Anton Blanchard <anton@samba.org> powerpc: fix iflag build issue (static -> extern)

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
c169d94718e0c3a980dbf352010e615daf2f4332 10-Jul-2013 Denys Vlasenko <dvlasenk@redhat.com> PTRACE_SEIZE can set ptrace options immediately, use this feature

This eliminates some rare bugs, such as post-execve SIGTRAP
generation when we attach to a process, and it manages to finish
execve'ing before we set TRACEEXEC option to suppress that.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
7c41ce287804f5409400c2b87bf11ebc6f6e1091 08-Jul-2013 Denys Vlasenko <dvlasenk@redhat.com> If -o|logger is in use, exit trace loop if nprocs == 0.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
d2e1f42d8a28486484f00739e561a58be4808b03 08-Jul-2013 Denys Vlasenko <dvlasenk@redhat.com> Exit trace loop if got ECHILD, not if nprocs == 0.

Comment gives a testcase which wasn't handled correctly
by the old code.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
6162a3f34fc8d15095a3b71dc6e4cbdfe1b14ac1 04-Jul-2013 Denys Vlasenko <dvlasenk@redhat.com> Add paranoia check before passing a long to pid2tcb(int pid)

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
38eab5d6ea5627233b781f1bc68c2b264e8ee774 02-Jul-2013 Denys Vlasenko <dvlasenk@redhat.com> In debug output, show waitpid status with 6 hex digits, not 4

This shows event byte values better (without variable offset):

[wait(0x01057f) = 29491] WIFSTOPPED,sig=SIGTRAP,EVENT_FORK (1)
[wait(0x80057f) = 29492] WIFSTOPPED,sig=SIGTRAP,EVENT_STOP (128)
^^

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
519af5ad34fa19fb48e2bc6539135fe0852210c3 02-Jul-2013 Denys Vlasenko <dvlasenk@redhat.com> Replace suspicious popen_pid assignment with an obviously correct one

popen_pid = vfork() does work correctly, but for a subtle reason
that wrong assignment of 0 happens in the child _first_,
and _then_ correct value overwrites it in the parent.

(And in a hyphothetical system where vfork = fork,
popen_pid wouldn't be shared, so it will also be ok.)

However, it's not necessary to be difficult.
This change makes it so that assignment is done only in parent.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
d0ffdf494ac722f3d121c6e807f105000409e6a6 01-Jul-2013 Denys Vlasenko <dvlasenk@redhat.com> Convert trace() from returning int to returning void

The cleanup sequence in error cases, and on normal code path
was nearly the same, no point in duplicating it.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
5a2483ba25fd80cb189abcdc14624be72b0c4c0b 01-Jul-2013 Denys Vlasenko <dvlasenk@redhat.com> Remove ia64-specific printing of current address on signal delivery

The address is printed anyway by printleader() if -i is active.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
752e5a02e67f66f555aa39faf522f07126924e62 28-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Change upeek() to take pid, not full tcp.

This will be used by next change.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
c8511f07aba78178f8528e22a8daa438347eb4fa 26-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> In -f mode, do not assume that new pid is stopped - handle exits too

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
e8681c926c02dad48aca66f3aba1e33122002c36 26-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Set strace_child only in the right branch

"strace_child = pid" assignment was racing in NOMMU case
because of vfork (no way to know which process would win).

After this change, strace_child is set to nonzero only
in one process after [v]fork.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
fadbf6679cb52d4265a771cbb8635a2ff472e869 26-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Get rid of TCB_INUSE and TCB_STRACE_CHILD

We can use tcb::pid == 0 as an indicator of free tcb,
and we already have strace_child variable which holds
pid of our child, if any.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
1b2bfbc8257231c18dcdd30b8a84eadffbe9417a 21-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Fix debug output of wait4 result (was reusing buf[] on unknown events)

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
4e020c0f4b054a030ce8922906cdc217c4b2faf4 21-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Show PTRACE_EVENT_STOP correctly in debug output

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
71d3d29a9d51add731c07e328a7394db0b3dd212 21-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Panic a bit less when we see an unknown pid

I stumbeld over this case when I used "exec stace ...".

* strace.c (trace): Do not exit if we see an unknown pid in wait4.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
e2567d54dd57438d8ebe0167748cde7b661103e8 21-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> detach(): Reorganize code. Logic is the same.

* strace.c (detach): Use goto's instead of excessive nesting.
Drop sigstop_expected and interrupt_done variables.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
a2de9dacec47b7902b19f37edcc564faff346816 21-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Eat pending SIGSTOP _before_ PTRACE_DETACH in detach()

* strace.c (detach): If TCB_IGNORE_ONE_SIGSTOP is set,
di not PTRACE_DETACH - wait for SIGSTOP first.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
fdfa47af7e05b320cc1c62fc5854ded781679917 20-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> detach(): warn if we see ECHILD from waitpid

* strace.c (detach): Warn if we see ECHILD from waitpid.
Explain in comments that we don't normally expect !WIFSTOPPED
either, and also that PTRACE_CONT failure isn't expected
(the "break" there is a "I'm confused, bailing out" code style)..

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
4a9ba989e65c12c50286a8423196236e6bac529d 20-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Improve error messages in detach()

* strace.c (detach): Change return type from int to void.
Improve error meesages: show PID, tell exactly which operation fails.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
725dd425a60af0cd0fa7bb764ae3a122269a70fc 20-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Remove workarounds for ancient kernels lacking __WALL

__WALL is available and working at least since 2.4 kernels: 10 years ago.

* strace (detach): Remove workarounds for ancient kernels lacking __WALL.
Add missing EINTR check.
(trace): Remove workarounds for ancient kernels lacking __WALL.
Remove redundant double error printout.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
69e27ef24402059d1d103c83e511b62bc60310d2 19-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> USE_SEIZE: fix detaching from stopped processes

V3: split SEIZE/!SEIZE code paths to reduce confusion.
Extensively comment every possible case.
Verified that all tests/detach* tests work in both SEIZE and !SEIZE
cases.

* strace.c (detach): If PTRACE_SEIZE API is in use, stop the tracee
using PTRACE_INTERRUPT instead of sending it a SIGSTOP.
In a subsequent waitpid loop, correctly wait and suppress SIGSTOP
on detach if PTRACE_INTERRUPT wasn't used, or wait for any ptrace
stop and detach without suppressing signals.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
f1669e7975cb8d67448d52d9ae7dde3301d27273 18-Jun-2013 Denys Vlasenko <dvlasenk@redhat.com> Cleanups. No logic changes.

* defs.h: Define new ptrace constants unconditionally.
* strace.c (detach): Fix comment.
(trace): Remove now unnecessary "if USE_SEIZE".

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
e8ff4c6f863c16180dacff74988f0e617f8136d9 28-May-2013 Dmitry V. Levin <ldv@altlinux.org> Do not suppress signal delivery messages with -qq

Current implementation of -qq does not allow suppressing exit status
messages without suppressing signal delivery messages, which is not
good. There is a traditional "-e signal=none" syntax that can be used
to suppress all signal delivery messages.
This partially reverts commit v4.7-222-g01997cf.

* strace.c (trace): Do not suppress signal delivery messages with -qq.
* strace.1: Update documentation about -qq option.
/external/strace/strace.c
1d2435b20bc81fb52c3edb19a3b6247ce2d43ca6 15-May-2013 Dmitry V. Levin <ldv@altlinux.org> NOMMU: do not hide startup syscalls unless in -D mode

On NOMMU systems in "strace PROG" case, we have no way to attach to
the tracee before it calls execve unless in -D mode. That is, the
first execve call is very likely to be missed, and setting
hide_log_until_execve just results to empty log.

* strace.c (init) [NOMMU_SYSTEM]: Do not set hide_log_until_execve
unless in -D mode.
/external/strace/strace.c
882478a0724c04287ac232c212312c8e094cce43 13-May-2013 Dmitry V. Levin <ldv@altlinux.org> Make -D mode work when the Yama LSM is enabled

* strace.c [HAVE_PRCTL]: Include sys/prctl.h.
(startup_child) [HAVE_PRCTL && PR_SET_PTRACER && PR_SET_PTRACER_ANY]:
In -D mode, allow tracing the process that is going to become the
tracee.
/external/strace/strace.c
2a3d27552f17a5b378344620bec7d255bac65a8d 14-May-2013 Denys Vlasenko <dvlasenk@redhat.com> Hide startup syscalls.

Tested with "./strace [-D] [-q] [-bexecve] env true",
all cases seem to work.

* defs.h: Declare new variable: bool hide_log_until_execve.
* strace.c: Define hide_log_until_execve.
Rename skip_startup_execve to skip_one_b_execve.
(startup_child): Do not set skip_one_b_execve = 1 here.
(init): If "strace PROG" case (as opposed to "strace -pPID"),
set skip_one_b_execve and hide_log_until_execve to 1.
(trace): Don't print signal messages if hide_log_until_execve == 1.
* syscall.c (trace_syscall_entering):
Skip syscall printing if hide_log_until_execve == 1.
Reset hide_log_until_execve if we enter execve syscall.
(trace_syscall_exiting): Skip syscall printing if hide_log_until_execve == 1.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
01997cf32d4492b9898283ced45e8a4a6fd161b8 13-May-2013 Daniel P. Berrange <berrange@redhat.com> Allow -q to be repeated for very quiet output

Even with the -q flag specified, tracing output is still mixed
with messages about signals and process exit status, which is
often irrelevant. Allow the -q option to be repeated to force
the suppression of signals / exit status info too.

* defs.h: Change 'qflag' from 'bool' to 'unsigned int'.
* strace.1: Document ability to repeat '-q' option.
* strace.c: Allow '-q' to be repeated to quieten process
exit status and signal messages.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
/external/strace/strace.c
c8938e08ad06ae7bf0f50872ddbb0efbe7bf7560 20-Mar-2013 Dmitry V. Levin <ldv@altlinux.org> Use 64-bit versions of stat, readdir and setrlimit functions when available

strace already has a mechanism to use fopen64 for output when the 64-bit
version of fopen is available on 32-bit architectures. Apply this
mechanism for other three functions to make strace fully adopted for
64-bit types.

* strace.c (struct_stat, stat_file, struct_dirent, read_dir,
struct_rlimit, set_rlimit): New macros.
(startup_attach): Use read_dir.
(startup_child): Use struct_stat and stat_file.
(main): Use struct_rlimit and set_rlimit.
/external/strace/strace.c
38cfe7c92328e940c71074c9b579b5bf9f2cb2f6 05-Mar-2013 Denys Vlasenko <vda.linux@googlemail.com> Remove variable tracing_paths and check in pathtrace_match

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
7239dbcf2dff792f408c60fe3e278f707fdf497b 05-Mar-2013 Denys Vlasenko <vda.linux@googlemail.com> Use dynamically-sized selected[] array for -P PATH

While at it, added a small optimization of not remembering
the path twice if it happens to be the same.

text data bss dec hex filename
245111 680 10860 256651 3ea8b strace_old
245075 680 9804 255559 3e647 strace

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
22efaf0028ddec8f9ed2a2a11e9baaa201594a33 27-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> Make -b take SYSCALL param, document it in --help and in manpage.

To not waste an option letter for just one trick,
extend -b to take a parameter:
"on which syscalls do you want to detach?".
Currently supports only execve.

While at it, fixed (by removing non-Linux and stale info)
and extended manpage text about -f.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
905e8e0e2f0a1f51ab92424dcb005885ea8b2459 26-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> Mass replace error_msg("%s", "literal") -> error_msg("literal")

There is no need to print literal strings through "%s".
Only untrusted strings such as filenames need that.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
05f325199a6cf36c92560d5a08b56652502705c2 26-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> Assorted NOMMU fixes

With -D, strdup'ing of pathname is necessary only on NOMMU.

Don't set skip_startup_execve to 1 if NOMMU and not in daemonized mode
(try "strace [-D] -b env echo HI" to see whether we detach on correct execve).

Fix test_ptrace_FOO shortcuts on NOMMU to always assume success
and _properly_ set all variables.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
38e79bbb25bca8b79ae2866b93c4ddf26dea2b13 26-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> Shorten help text - no need to show deprecated option -F

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
a9fe13c9437707fa132fde4e51a20d88381e7430 22-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> Create and use struct_sysent and struct_ioctlent typedefs.

This is a preparatory mass replace patch with no code changes.

The future change will need to typedef sysent to sysent0,
which results in compile failures when "struct sysent" string
gets mangled into "struct sysent0".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
74ec14f968a418691b851cbbfeb0269174c64b08 21-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> Eliminate many SCNO_IS_VALID checks

By adding tcp->s_ent pointer tot syscall table entry,
we can replace sysent[tcp->scno] references by tcp->s_ent.
More importantly, we may ensure that tcp->s_ent is always valid,
regardless of tcp->scno value. This allows us to drop
SCNO_IS_VALID(tcp->scno) checks before we access syscall
table entry.

We can optimize (qual_flags[tcp->scno] & QUAL_foo) checks
with a similar technique.

Resulting code shrink:
text data bss dec hex filename
245975 700 19072 265747 40e13 strace.t3/strace
245703 700 19072 265475 40d03 strace.t4/strace

* count.c (count_syscall): Use cheaper SCNO_IN_RANGE() check.
* defs.h: Add "int qual_flg" and "const struct sysent *s_ent"
to struct tcb. Remove "int u_nargs" from it.
Add UNDEFINED_SCNO constant which will mark undefined scnos
in tcp->qual_flg.
* pathtrace.c (pathtrace_match): Drop SCNO_IS_VALID check.
Use tcp->s_ent instead of sysent[tcp->scno].
* process.c (sys_prctl): Use tcp->s_ent->nargs instead of tcp->u_nargs.
(sys_waitid): Likewise.
* strace.c (init): Add compile-time check that DEFAULT_QUAL_FLAGS
constant is consistent with init code.
* syscall.c (decode_socket_subcall): Use tcp->s_ent->nargs
instead of tcp->u_nargs. Set tcp->qual_flg and tcp->s_ent.
(decode_ipc_subcall): Likewise.
(printargs): Use tcp->s_ent->nargs instead of tcp->u_nargs.
(printargs_lu): Likewise.
(printargs_ld): Likewise.
(get_scno): [MIPS,ALPHA] Use cheaper SCNO_IN_RANGE() check.
If !SCNO_IS_VALID, set tcp->s_ent and tcp->qual_flg to default values.
(internal_fork): Use tcp->s_ent instead of sysent[tcp->scno].
(syscall_fixup_for_fork_exec): Remove SCNO_IS_VALID check.
Use tcp->s_ent instead of sysent[tcp->scno].
(get_syscall_args): Likewise.
(get_error): Drop SCNO_IS_VALID check where it is redundant.
(dumpio): Drop SCNO_IS_VALID check where it is redundant.
Use tcp->s_ent instead of sysent[tcp->scno].
(trace_syscall_entering): Use (tcp->qual_flg & UNDEFINED_SCNO) instead
of SCNO_IS_VALID check. Use tcp->s_ent instead of sysent[tcp->scno].
Drop SCNO_IS_VALID check where it is redundant.
Print undefined syscall name with undefined_scno_name(tcp).
(trace_syscall_exiting): Likewise.
* util.c (setbpt): Use tcp->s_ent instead of sysent[tcp->scno].

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
f909c8d0d759d0511ad2c741854602b0494e0390 19-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> Fix NOMMU + daemonized tracer SEGV

pathname[] was getting destroyed, execve of garbage pathname
failing, and to top it off, the tracer's stack was also
smashed and trecer segfaulted.

* strace.c (exec_or_die): New function.
(startup_child): Don't use pathname[] contents after vfork,
make a malloced copy instead. Explain "NOMMU + -D bug"
and how we work around it.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
5c9d8f4fc5318fc740ec2a16bac5b8a29e7eb52d 19-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> Make it possible to to do test builds for NOMMU architectures

And while using it, I discovered that -D doesn't work too well
on NOMMU. Added a comment about it.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
eec8d5d6b028665a73169fda96e4e873cb8351f0 14-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> [X86] Use ptrace(PTRACE_GETREGSET, NT_PRSTATUS) to get registers.

Unlike PTRACE_GETREGS, this new method detects 32-bit processes
reliably, without checking segment register values which
are undocumented and aren't part of any sort of API.
While at it, also fixed x32 detection to use __X32_SYSCALL_BIT,
as it should have been from the beginning.

* defs.h: Declare os_release and KERNEL_VERSION.
* strace.c: Make os_release non-static, remove KERNEL_VERSION define.
* syscall.c: New struct i386_user_regs_struct,
static union x86_regs_union and struct iovec x86_io.
(printcall): Use i386_regs or x86_64_regs depending on x86_io.iov_len.
(get_regs): On x86 and kernels 2.6.30+, use PTRACE_GETREGSET,
on earlier kernels fall back to old method.
(get_scno): [X86] Determine personality based on regset size
on scno & __X32_SYSCALL_BIT.
(syscall_fixup_on_sysenter): Use i386_regs or x86_64_regs depending
on x86_io.iov_len.
(get_syscall_args): Likewise.
(get_error): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
8d4ca0c8cd81329ad730ab52b1e0653c1bbea803 06-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> Shortcut tests for fork/exec syscalls

This change should speed up strace by a tiny bit.

More importantly, it makes it much more clear that
fork and exec fixups are not necessary for any reasonably
recent kernels. IOW: syscall_fixup_for_fork_exec() and its callees
are all dead code.

* defs.h: Declare new need_fork_exec_workarounds flag variable.
* strace.c: Define need_fork_exec_workarounds flag variable.
(test_ptrace_setoptions_followfork): Return 0/1 as success/fail indicator.
(test_ptrace_setoptions_for_all): Likewise.
(init): Set need_fork_exec_workarounds to TRUE if needed.
* syscall.c: Rename internal_syscall() to syscall_fixup_for_fork_exec().
(trace_syscall_entering): Call syscall_fixup_for_fork_exec() only if
need_fork_exec_workarounds == TRUE.
(trace_syscall_exiting): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
ce7d953ebecc10f71e191b6d18cfeb2399429d5f 05-Feb-2013 Denys Vlasenko <vda.linux@googlemail.com> 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>
/external/strace/strace.c
9a71bcdab254e4cd93b8f1e93c659644eb70ea9b 18-Sep-2012 Dmitry V. Levin <ldv@altlinux.org> Use perror_msg instead of perror

* signal.c (sys_sigreturn): Use perror_msg instead of perror.
* strace.c (tprintf, tprints, detach, startup_attach): Likewise.
* syscall.c (get_scno): Likewise.
* util.c (umoven, umovestr): Likewise.
/external/strace/strace.c
978fbc901c4fe260caaa5881e54bd9cb54022101 13-Sep-2012 Denys Vlasenko <vda.linux@googlemail.com> Trivial fixes, no code changes.

* strace.c: Fix compiler warning message about tgkill - we don't use it.
Fix indentation of preprocessor directives.
(trace): Remove outdated comment.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
508279c94f15510d05c92a7694533c9a962d8585 24-Aug-2012 Dmitry V. Levin <ldv@altlinux.org> Always check setreuid return code

* strace.c (startup_child): Check setreuid return code.
/external/strace/strace.c
cf53436f737c0273028503186fc0f837c7191085 12-Jul-2012 Dmitry V. Levin <ldv@altlinux.org> Close pipe and wait for the pipe process termination

In case of normal strace termination, when the trace output is
redirected to a file or a pipe, close it and wait for the pipe
process termination.

* strace.c (main): Before normal exit, close shared_log when it
differs from stderr, and wait for popen_pid termination.
/external/strace/strace.c
26bc0606d96d05d30ba263939a0451889340a64c 10-Jul-2012 Denys Vlasenko <vda.linux@googlemail.com> Enable usage of PTRACE_SEIZE

* defs.h: Define USE_SEIZE to 1. Remove PTRACE_SEIZE_DEVEL
and PTRACE_EVENT_STOP1.
* strace.c (ptrace_attach_or_seize): Replace PTRACE_SEIZE_DEVEL
with 0.
(trace): Do not check for PTRACE_EVENT_STOP1.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
c59b3f13fbc50712785cc2635ab12e8152c96aa1 15-May-2012 Denys Vlasenko <vda.linux@googlemail.com> Remove outdated comment about suspending new tracees

We no longer track parent/child relationship between tracees.
Therefore, we no longer suspend new tracee until parent is seen
exiting form [v]fork/clone. The comment is obsolete.

* strace.c (trace): Remove outdated comment.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
0dbc80de895c25769791b7726022a274695eec31 15-May-2012 Dmitry V. Levin <ldv@altlinux.org> Fix kernel release string parsing

* strace.c (get_os_release): Handle "X.Y-something" utsname.release
strings properly.

Reported-by: Bryce Gibson <bryce@gibson-consulting.com.au>
/external/strace/strace.c
6e4f3c1fa41851cb72230432db4be8e0c2993c7d 16-Apr-2012 Denys Vlasenko <vda.linux@googlemail.com> Add custom (faster) vfprintf implementation (disabled by default)

* defs.h: Declare strace_vfprintf either as a alias to vfprintf
or as a bona fide function. USE_CUSTOM_PRINTF define controls whether
we use strace_vfprintf. By default, we don't.
* strace.c (tprintf): Call strace_vfprintf instead of vfprintf.
* vsprintf.c: New file, implements strace_vfprintf.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
142aee0a593ea9b42aa98347d998176b8a4e2489 16-Apr-2012 Denys Vlasenko <vda.linux@googlemail.com> Trivial speed optimization

* strace.c (tprints): Use fputs_unlocked instead of fputs.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
7ff5ed932568a8049c3ca134da374f64c3e255ce 05-Apr-2012 Mike Frysinger <vapier@gentoo.org> Fix indefinite hang on no-mmu systems

The ptrace setoptions code will fork a child which goes to sleep and
expects the parent to continue on to do tests. Unfortunately, this
does not work on no-mmu systems as fork() is actually vfork() and any
vforked children will hang the parent until it exits or execs.

We might be able to make this test work on no-mmu systems with a bit
of work, but easier to just disable this for the release so it works
now.

* strace.c (test_ptrace_setoptions_for_all): Return if strace_vforked.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
/external/strace/strace.c
df790130ff66b7cb9b3499210bae21a5baede111 26-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Remove unreachable code

* strace.c (process_opt_p_list): Remove unreachable code.
/external/strace/strace.c
c5ccfa450b9818ef9eab94f9d15189e50a796937 26-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Tweak help text and manpage (added -In to manpage)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
ccee169ab6aa4ae7515198dadcef5dd2286ede4b 25-Mar-2012 Dmitry V. Levin <ldv@altlinux.org> Robustify parsing of numbers from strings

* defs.h (string_to_uint): New prototype.
* util.c (string_to_uint): New function.
* strace.c (error_opt_arg): New function.
(process_opt_p_list): Use string_to_uint instead of atoi.
Terminate in case of invalid process id.
(init): Use string_to_uint instead of atoi.
Use error_opt_arg in case of invalid option argument.
* syscall.c (qual_syscall, qual_signal, qual_desc): Use string_to_uint
instead of atoi.
/external/strace/strace.c
6764f8f2f0b71ecc069d607eb8525735d1684a59 22-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Simplify current tcp switching and current column handling

Instead of using "static FILE *outf and static unsigned int curcol"
to cache current outfile and its position, we can simply
remember current tcb and use its ->outf and ->curcol.
This allows to drop numerous "tcp->curcol = curcol" ops in trace().

Turns out we can't drop "static FILE *outf", but now its role is
a bit clearer: it newer changes after init, stays == stderr or
opened to shared log (which may be the same thing if neither -o
nor -ff was specified). Let's rename it then.

text data bss dec hex filename
236953 704 18944 256601 3ea59 strace.before.prev.commit
236905 704 18944 256553 3ea29 strace.before
236869 704 18944 256517 3ea05 strace

* strace.c: Replace curcol static variable by struct tcb *current_tcp.
Rename static FILE *outf to shared_log (since it no longer caches tcp->outf).
(ptrace_restart): Use current_tcp->curcol instead of curcol.
(tprintf): Check current_tcp != NULL instead of outf != NULL.
Use current_tcp->outf instead of outf, current_tcp->curcol instead of curcol.
(tprints): Likewise.
(line_ended): Likewise.
(printleader): Switch current tcb by "current_tcp = tcp" istead of
assignments to outf and curcol.
(droptcb): Set current_tcp to NULL if we dropped it.
(startup_child): Rename outf to shared_log.
(init): Likewise.
(cleanup): Likewise.
(trace): Simplify current tcp switching and current column handling.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
8511f2a1f02a31f66eab86bf95dee1636fb39076 22-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Make threaded execve handling code more reabable and somewhat simpler

* strace.c (droptcb): Remove outfname check in "outfname && followfork >= 2" -
with recent changes, followfork >= 2 check guarantees that outfile
was specified, and _is already opened_.
(trace): Move tcb existence check before threaded execve handling.
This allows to remove tcp != NULL checks in threaded execve handling.
Rewrite threaded execve handling code to be less indented,
keeping the same logic.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
b5e0908a173cc8005ed73fa5c0eab59d03baa7f3 21-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Show "+++ exited..." with -C

* strace.c (trace): Show "+++ exited..." with -C too.
Save tcp->curcol after PTRACE_LISTEN failure too, just in case.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
a44f9696e45f5bb51c6ec37c0ef95dc2cdfd4c8a 21-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Replace reprinting decision logic

After this change, we no longer need to decide when we need
to set TCB_REPRINT, and when we don't: it's never needed :)

Well, almost. That pesky pid-changing execve needs special treatment.
If not it, it'd be possible to nuke TCB_REPRINT...

While at it, fix a case of mishandled -C.

* strace.c (printleader): Do not set TCB_REPRINT.
(trace): Set TCB_REPRINT only for execve with changing pid.
Fix mishandling of -C.
* syscall.c (trace_syscall_entering): Do not clear TCB_REPRINT.
(trace_syscall_exiting): Replace reprinting decision logic.
Remove call to printargs(): it is known to just return 0 here.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
235067525cc064a9a466c245fa8a6265ae136306 21-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Report some ptrace failures; nuke tcp->ptrace_errno

Report some (not all) ptrace errors, namely,
errors on ptrace restart operations.

Before: 10533 sendto(-1, 0x804895e, 17, 0, NULL, 0 <unfinished ...>
After: 10533 sendto(-1, 0x804895e, 17, 0, NULL, 0 <ptrace(SYSCALL):No such process>

This tells user that strace failed to let sendto syscall
to be entered - process was dead at that point of time.
It is (marginally) better than to always say "<unfinished ...>"

While at it, patch removes tcp->ptrace_errno.
I added it many months ago, and it looks that after all
it is not needed for ptrace error detection: I failed to execute
a single existing code path which is accessible
through that variable only.

* defs.h: Remove struct tcp::ptrace_errno field.
* strace.c (ptrace_restart): Emit message to log on error.
(printleader): Remove "if (printing_tcp->ptrace_errno)..." code.
(trace): Remove !tcp->ptrace_errno check, it's always true.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
852f98a3824f6b8359df744af5772306410341ab 20-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Make ptrace_restart() static. No code changes

* defs.h: Remove ptrace_restart() declaration.
* strace.c (ptrace_restart): Move its definition here.
* util.c (ptrace_restart): Remove its definition.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
3e3490acf776124a52c0315a113cb2e364d1bc40 17-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Indentation and whitespace fixes. No code changes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
9c3861d3177f3bfb12b24890fd118bcb77066abb 16-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Remove another "interrupt to quit" message

* strace.c (startup_attach): Remove another "interrupt to quit" message.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
3db3b26101443dccbea959ba0abcbffb240d04e8 16-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Fix "strace -oFILE -ff -p<nonexistant_pid>" behavior

* strace.c (newoutf): Set tcp->outf in non-ff mode too.
(alloctcb): This define is removed.
(alloc_tcb): Renamed to alloctcb. Does not set tcp->outf anymore.
Lost 'command_options_parsed' flag parameter.
(startup_attach): Do not say "interrupt to quit" in attach message -
^C does not work in all cases, we mislead users.
Call newoutf(tcp) after successful attach.
(startup_child): Call newoutf(tcp) after successful attach.
(trace): Call newoutf(tcp) when we picked up already attached child.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
800ec8ffde1296b3f2cfdd838fb08f2ff2bbe946 16-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Make alloc_tcb and droptcb static. No code changes.

The change is trivial. Diff is large because it is confused
by function definitions being moved around.

* defs.h: Remove declarations of alloc_tcb and droptcb.
* strace.c: Make alloc_tcb and droptcb static.
Shuffle functions around to make compiler happy.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
a6d91ded3f2d5401e09a9c2fa442aabfbfe593a8 16-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Tidy up includes and copyright notices, fix indentation

The files not mentioned in changelog below had only
copyright notices fixes and indentation fixes.

* defs.h: Include <stdint.h> and <inttypes.h>.
* file.c: Do not include <inttypes.h>.
Move struct kernel_dirent declaration below top include block.
* block.c: Do not include <stdint.h> and <inttypes.h>.
* quota.c: Likewise.
* desc.c: Likewise.
* signal.c: Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
a509054aeee00a89a2250919f74bd849c67ded61 15-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Simplify SIGCHLD handler setting

* strace.c (init): Set SIGCHLD to SIG_DFL earlier.
(startup_child): Do not bother restoring SIGCHLD handler.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
2c4fb905fef268a7e359ce3acaec4ee7ef087996 15-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> When reporting signals, use short signal names (SIGfoo) instead of strerror

* defs.h: Remove strsignal declaration.
* signal.c: Better check for SI_FROMUSER define.
* strace.c (strerror): Remove this function.
(trace): Use short signal names (SIGfoo) instead of strerror.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
6e0bfd11ac1aa36713d9a65542ae86dd607ae374 15-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Fix lame kernel version checking code

The code "os_release[0] >= '3'" is not good for any
finer-grained checks such as "kernel >= 3.2.1".
Let's proactively fix it.

* strace.c: Change os_release from string to integer.
(get_os_release): Parse uname.release to KERNEL_VERSION
representation.
(init): Convert kernel version check to KERNEL_VERSION.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
61e7aad9fa1a6a5bd5a586e6276767caf12b53f2 15-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Experimental support for "detach on execve" feature

* strace.c: Define new detach_on_execve, skip_startup_execve bool variables.
(init): Set detach_on_execve on -b, set skip_startup_execve if
"strace PROG" form is used.
(trace): Detach from process if -b and we see PTRACE_EVENT_EXEC event.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
3e084ac349c3b177a75916254a4a5a02f29969e2 15-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Simple fixes.

* strace.c (usage): Document -d; document that -F is deprecated.
(droptcb): Print "<detached ...>" correctly for non-ff mode too.
(detach): Suppress a warning.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
bcde70adbcff01af4a0675d2fd9d9522807d573e 15-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Remove extra include directives. No code changes.

* defs.h: Include <signal.h> unconditionally.
Other files were doing it unconditionally, so no harm done.
* bjm.c: Remove system includes which are already included by defs.h.
* pathtrace.c: Likewise.
* process.c: Likewise.
* signal.c: Likewise.
* strace.c: Likewise.
* stream.c: Likewise.
* syscall.c: Likewise.
* system.c: Likewise.
* util.c: Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
a50d2a87a1a8df4471bbd93f2ce9ef0541b1124b 15-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Tidy up order of includes; make bool variables explicit.

Bool variables are more compact in data and (on x86) on code too:

text data bss dec hex filename
237950 676 19044 257670 3ee86 strace.before
237838 676 19012 257526 3edf6 strace

* defs.h: Group library includes at the top of the file.
Rename dtime to Tflag, debug to debug_flag.
Change debug_flag,Tflag,qflag,not_failing_only,show_fd_path,tracing_paths
variable declarations from int to bool.
* strace.c: Change corresponding definitions. Do the same for static
variables iflag,rflag,print_pid_pfx.
Rename dtime to Tflag, debug to debug_flag.
* syscall.c: Rename dtime to Tflag, debug to debug_flag.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
67559ad260fd31c823615f650f5e131818acf20f 13-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Less ugly debug display of ptrace events

* strace.c (trace): Less ugly debug display of ptrace events.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
7de265d88a78a27d58c2c728424e5bb8379ef351 13-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Fix logging for "strace -o FILE -ff test/threaded_execve" test case

Our logic which was deciding whether to print "<unfinished ...>"
thingy wasn't working properly for -ff case.

* defs.h: Group log generation-related declarations together.
Add a large comment which explains how it works.
Add declaration of line_ended() function.
* strace.c (line_ended): New function which sets up internal data
to indicate that previous line was finished.
(printleader): Change logic to fix log generation in -ff mode.
(newoutf): Make check for -ff mode consistent with other places.
(droptcb): Print "<detached ...>" if last line for this tcp wasn't finished.
(cleanup): Remove code to print "<unfinished ...>", printleader()
or detach() will do it instead.
(trace): Remove code to print "<unfinished ...>".
Add code which finishes threaded execve's incomplete line
with " <pid changed to PID ...>" message. Replace printing_tcp = NULL
followed by fflush() by line_ended() call.
* process.c (sys_exit): Call line_ended() to indicate that we finished priting.
* syscall.c (trace_syscall_exiting): Set printing_tcp to current tcp.
Call line_ended() to indicate that we finished priting.
Remove call to fflush(), it is done by line_ended() now.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
328bf250bde8167cec6f2f5bf35463fb4ffb6f9f 12-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Treat -ff without -o FILE as single -f

* strace.c (init): Treat -ff without -o FILE as single -f.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
558e5127fb68a7ab5c5ba6d8e976efd77e396cc2 12-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Style fix. No code changes

* strace.c (process_opt_p_list): Style fix.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
ecc8b97c9bd36ad25c550ec412f43f44b59e2ebd 12-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Reduce stack usage by ~0.5k

main() uses ~0.5k of stack for local variables and such. When we enter
main tracing loop, most of these variables are no longer used.
But they still take up stack for the entire life of strace.
We can avoid this wastage if we move init code into a separate function.
(Need to be careful and not allow automatic inlining).

* strace.c (init): New function. Most of pre-existing code of
main is now living here.
(main): Call init() to do initialization.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
2e856a1c9215d292a7c41695928e8552788bc43c 12-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Preparatory cosmetic changes for the next commit

* strace.c (tprintf): Move function up in the source file. No code changes.
(tprints): Likewise.
(printleader): Likewise.
(tabto): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
37ab4b79de57c1657e41f96a96fa699a08194a80 09-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Trivial simplification

* strace.c (detach): Use waitpid instead of wait4.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
f20250266eb5988805b03b1cc0fa74cdb6398742 09-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Don't consider PROG to be our child in "strace -D PROG" case

TCB_STRACE_CHILD is used for the case when "strace PROG" is ^C-ed
or something like that. strace should not just exit - it should
do something with its child (such as signal it too).

In -D case, PROG is not really a child of _strace_, it is a child
of strace's parent. It's ok to handle it exactly as an attached process.

While we are at it, remove nonsensical special-casing of TCB_STRACE_CHILD
in printing of "<unfinished ...>" message.

* strace.c (startup_attach): Don't set TCB_STRACE_CHILD if -D.
(trace): Print "<unfinished ...>" on error regardless of TCB_STRACE_CHILD.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
75fe85c2ee83a31afe0c8f1468da28deb1c2bc28 09-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Fix the case where we try to detach unattached processes

Before this change:
$ strace -D -p1
strace: -D and -p are mutually exclusive options
Process 1 detached <==== WRONG! (and we try to SIGSTOP it!!!)

* defs.h: Change the meaning of TCB_ATTACHED: now it means "this tracee
is attached to us". Add TCB_STRACE_CHILD: "this tracee is our child".
* strace.c (kill_save_errno): Move up. No code changes.
(process_opt_p_list): Don't set TCB_ATTACHED on new tcb.
(startup_attach): Change how we work with TCB_ATTACHED.
Set TCB_STRACE_CHILD on -D.
(startup_child): Use kill_save_errno instead of kill.
Set TCB_ATTACHED and TCB_STRACE_CHILD on attached strace child.
If we are in -D case, don't set TCB_ATTACHED (we aren't attached yet).
(detach): do not do PTRACE_DETACH if TCB_ATTACHED is not set.
(cleanup): Check TCB_STRACE_CHILD instead of TCB_ATTACHED.
(trace): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
97c503fa2e9cd02126feae659f133631c8eb36f1 09-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Call PTRACE_CONT with addr=0

* strace.c (trace): Call PTRACE_CONT with addr=0.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
fd883380671693a4616881a9103491f9e67fc8ae 09-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Fix PID prefix printing in "strace -oLOG -ff -p1 -p2 -p3" case

In this case we were printing PIDs to LOG.* files
even though it is not necessary.

The fix is in the addition of "&& followfork < 2" condition.

* strace.c: Remove pflag_seen variable, add print_pid_pfx one.
(process_opt_p_list): Do not pflag_seen++.
(main): Use "nprocs != 0" condition instead of "pflag_seen != 0".
Set print_pid_pfx before entering main tracing loop.
(printleader): Use print_pid_pfx to decide whether to print pid prefix.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
e8172b79e3dd35a136f4dc4d4de9df5bb4565c01 09-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Allow -p PID to take comma or whitespace-separated list of PIDs

* defs.h: Clarify meaning of TCB_ATTACHED. No code changes.
* strace.c (process_opt_p_list): New function.
(main): Call process_opt_p_list to process -p PIDs argument.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
4c65c44478f1591d96cda425d78451334fe1d401 08-Mar-2012 Denys Vlasenko <vda.linux@googlemail.com> Trivial tweaks to error messages

* strace.c (test_ptrace_setoptions_followfork): Use kill_save_errno
instead of kill.
(trace): Use perror_msg instead of perror.
* count.c (set_sortby): Use error_msg_and_die instead of fprintf.
* syscall.c (qualify): Likewise.
* util.c (ptrace_restart): Expand error message.
(umoven): Likewise.
(umovestr): Likewise.
(upeek): Use perror_msg instead of sprintf + perror.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
1945ccc3fbd5b56008c4a6b0cdd4611616201675 27-Feb-2012 Denys Vlasenko <vda.linux@googlemail.com> Assorted trivial optimizations

text data bss dec hex filename
236448 672 19044 256164 3e8a4 strace.before
236360 672 19044 256076 3e84c strace

* file.c (sprintmode): Use smaller static buffer, eliminate strlen call.
(sprinttime): Use smaller static buffer.
(printstat_sparc64): Coalesce two printing calls into one.
(printstat_powerpc32): Likewise.
(printcompat_statfs6): Likewise.
(sys_utime): Do not fetch personality_wordsize[current_personality]
repeatedly - cache it in local variable instead.
* process.c (printargv): Likewise.
* resource.c (sprintrlim): Return const char*, not char*. This allows
to eliminate sprintf(buf, "RLIM_INFINITY"). Use smaller static buffer.
(sprintrlim64): Likewise.
* strace.c (strerror): Use smaller static buffer.
(strsignal): Likewise.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
e83e157021177930b64ec4aa4983bbe13b39e91b 25-Feb-2012 Dmitry V. Levin <ldv@altlinux.org> Compress blank lines

Suppress repeated empty lines left after automated code removal.
This change was made by filtering every source code file through
"cat -s".
/external/strace/strace.c
1a3cf10c3095a9f80138b83f3d54499b825c9797 25-Feb-2012 Denys Vlasenko <vda.linux@googlemail.com> Build fixes after non-Linux code removal

* configure.ac: Remove calls to proc-based ptrace checks.
* proc.c: Remove, it's empty now.
* Makefile.am: Remove reference to proc.c.
* net.c: Remove trailing newlines.
* quota.c: Likewise
* resource.c: Likewise
* strace.c: Likewise
* stream.c: Likewise
* time.c: Likewise

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
8470374cba7df0e70653d95c4f336a4082c68d82 25-Feb-2012 Denys Vlasenko <vda.linux@googlemail.com> Cleanup after non-Linux code removal.

Conditions such as defined(LINUX) are always true now,
defined(FREEBSD) etc are always false.
When if directive has them as subexpressions, it can be simplified.
Another trivial changes here are fixes for directive indentation.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
ed720fda5d515f1359fcd3242223e553d1216789 25-Feb-2012 Denys Vlasenko <vda.linux@googlemail.com> Automated removal of non-Linux code

This change is generated by running every source through the following command:

unifdef -DLINUX -Dlinux -USUNOS4 -USVR4 -UUNIXWARE -UFREEBSD
-USUNOS4_KERNEL_ARCH_KLUDGE -UHAVE_MP_PROCFS
-UHAVE_POLLABLE_PROCFS -UHAVE_PR_SYSCALL -UUSE_PROCFS file.c

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
6c38156b6e345a25118e0b7144822bdf55839631 22-Feb-2012 Dmitry V. Levin <ldv@altlinux.org> Avoid potential core file clobbering on exit

* strace.c (main): Set RLIMIT_CORE to zero before terminating itself
with a deadly signal.
This fixes Debian bug #656398.
/external/strace/strace.c
9aa25abb2e74b05872c8d141776ced5c77b29dcf 10-Feb-2012 Dmitry V. Levin <ldv@altlinux.org> Remove initialization of native_scno field for most of syscalls

The native_scno field is not so much used in the code than before.
In many cases sys_func is checked instead, and for most of syscall
entries there is no need to initialize native_scno.

* linux/i386/syscallent.h: Remove native_scno initialization for
_exit, read, write, waitpid, execve, wait4, sysfs, readv, writev,
pread64, pwrite64, exit_group, waitid, send, recv, sendto and
recvfrom syscall entries.
* linux/syscall.h: Do not define no longer used SYS_waitid and
SYS_sub_* constants.
[IA64]: Do not define SYS_waitpid and SYS32_* constants.
* defs.h: Do not define no longer used __NR_exit_group constant.
* strace.c [USE_PROCFS] (proc_open): Use sys_func to check for execve.
/external/strace/strace.c
cdab1becb03eeae442719027fc26a17da464e5de 03-Feb-2012 Denys Vlasenko <vda.linux@googlemail.com> Trivial changes to help text. No code changes.

* strace.c (usage): Tweak help text: remove unpaired closing brackets,
make -V and -h sit on separate lines (hard to see them otherwise).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
4f3df078b26899afe0f25d8651b06a5a5b5143e2 29-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Simple optimizations

text data bss dec hex filename
239474 672 20484 260630 3fa16 strace.before
239234 668 19044 258946 3f382 strace

* file.c (sprint_open_modes): Reduce static buffer size.
Simplify separator printing.
* signal.c (sprintsigmask): Reduce static buffer size.
Simplify separator printing and printing of almost full masks.
Use stpcpy instead of sprintf and strcpy+strlen.
* strace.c (startup_child): Don't strchr() for ':' twice in a row.
* util.c (sprintflags): Exit loop early if possible.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
3521884c91d0bbd8e796d72619da40bdad95789c 29-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Trivial optimization

* strace.c (cleanup): Read 'interrupted' volatile variable only once.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
b51581e8f0b11d8f1cce055cebb287f728a508a3 29-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Make interactive-ness directly controllable via command line option

Defaults are often ok, but when they are not, people get confused.
"Why can't I kill strace?" and "Why strace dies on ^C when I want
to _tracee_ to die instead?" are typical complaints.

* strace.c: Replace 'interactive' variable with 'opt_intr' variable.
Define INTR_foo constants for its possible values.
Define 'interactive' as a macro.
(usage): Document -I n option.
(main): Parse -I n option, modify signal handling to accomidate new
-I 1 and -I 4 modes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
6703816060c2cf4aaf9c82057ced31c3ba744346 29-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Suppress compiler warning

* strace.c (trace): Frame potentially unused label with ifdef/endif.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
a3559250d48ccc3ef755183ebb3246cbbb442c0d 29-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> On Ctrl-C induced detach, send SIGINT to child tracee, not SIGTERM.

* strace.c (interrupt): Remember signal number.
(cleanup): If we exiting due to signal, send that signal to child tracee.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
31fa8a22b17b2f898513b68e04269597147d2478 29-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Add experimental code to use PTRACE_SEIZE, disabled by default

All new code is predicated on "ifdef USE_SEIZE". If it is not defined,
behavior is not changed.

If USE_SEIZE is enabled and run-time check shows that PTRACE_SEIZE works, then:
- All attaching is done with PTRACE_SEIZE + PTRACE_INTERRUPT.
This means that we no longer generate (and possibly race with) SIGSTOP.
- PTRACE_EVENT_STOP will be generated if tracee is group-stopped.
When we detect it, we issue PTRACE_LISTEN instead of PTRACE_SYSCALL.
This leaves tracee stopped. This fixes the inability to SIGSTOP or ^Z
a straced process.

* defs.h: Add commented-out "define USE_SEIZE 1" and define PTRACE_SEIZE
and related constants.
* strace.c: New variable post_attach_sigstop shows whether we age going
to expect SIGSTOP on attach (IOW: are we going to use PTRACE_SEIZE).
(ptrace_attach_or_seize): New function. Uses PTRACE_ATTACH or
PTRACE_SEIZE + PTRACE_INTERRUPT to attach to given pid.
(startup_attach): Use ptrace_attach_or_seize() instead of ptrace(PTRACE_ATTACH).
(startup_child): Conditionally use alternative attach method using PTRACE_SEIZE.
(test_ptrace_setoptions_followfork): More robust parameters to PTRACE_TRACEME.
(test_ptrace_seize): New function to test whether PTRACE_SEIZE works.
(main): Call test_ptrace_seize() while initializing.
(trace): If PTRACE_EVENT_STOP is seen, restart using PTRACE_LISTEN in order
to not let tracee run.
* process.c: Decode PTRACE_SEIZE, PTRACE_INTERRUPT, PTRACE_LISTEN.
* util.c (ptrace_restart): Add "LISTEN" to a possible error message.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
000b601439d249a4afa2ceb6096850a702612d1e 28-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Fix a case of broken output if last seen syscall was exit

* defs.h: Rename tcp_last to printing_tcp. Explain what it means.
Remove printtrailer() function.
* process.c (sys_exit): Convert printtrailer() call to "printing_tcp = NULL".
* strace.c: Add new variable printing_tcp.
(cleanup): Convert printtrailer() call to "printing_tcp = NULL".
(trace): Likewise.
(trace): Fix checks for incomplete line - it was working wrongly if last syscall was exit.
(printleader): Set printing_tcp.
(printtrailer): Remove this function.
* syscall.c: Remove tcp_last variable.
(trace_syscall_entering): Don't set printing_tcp, printleader call now does it.
(trace_syscall_exiting): Convert printtrailer() call to "printing_tcp = NULL".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
f7db5dd876eb41a3f0d5fd223c831734acc8d8d1 28-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Fix handling of test/threaded_execve.c testcase

Since 3.0, Linux has a way to identify which thread execve'ed.
This patch makes use of it in order to properly dispose
of disappeared ("superseded") thread leader,
and replace it with execve'ed thread.

Before this patch, strace was "leaking" thread which exec'ed.
It was thinking that it still runs. It would look like this:

18460 pause( <unfinished ...> <=== thread leader
18466 execve("/proc/self/exe", ["exe", "exe"], [/* 47 vars */] <unfinished ...>
18465 +++ exited with 0 +++ <=== exits from other threads
18460 <... pause resumed> ) = 0

The last line is wrong: it's not pause resumed, it's execve resumed.
If thread leader would do exit instead of pause, it is much worse:
strace panics because it thinks it sees return from exit syscall!

And strace isn't aware 18466 (exec'ed thread) is gone.
It still thinks it's executes execve syscall.

* strace.c: New variable "static char *os_release".
(get_os_release): New static function.
(main): Call get_os_release to retrieve Linux version.
(trace): If we see PTRACE_EVENT_EXEC, retrieve old pid, and if it
differs from new one, free one of tcbs and print correct messages.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
eebb04d4ae8bf4b08a041f5ea442ca24c90692c2 27-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Make pid2tcb static

* defs.h: Remove pid2tcb declaration.
* strace.c (pid2tcb): Make this function static.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
cfad543087d98c5313fd7f006c0de69a1d87dc8e 24-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Per Dmitry's request, remove paranoid check in verror_msg()

* strace.c (verror_msg): Remove redundant check for msg != NULL.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
846ecb9b44995c99b80f762d579d65f738fca291 24-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> More robust error check for vasprintf

* strace.c (verror_msg): More robust error check for vasprintf.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
837399af4ffefec55f9693022dc6d8608da442cf 24-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Slightly more compact handling of argv[]

text data bss dec hex filename
238274 672 20484 259430 3f566 strace.before
238226 672 20484 259382 3f536 strace

* strace.c (main): Slightly more compact handling of argv[]

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
aa6ec415c1a9b8a886bddf0db765b5de365a8360 24-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Trivial optimization

* strace.c: Set default interactive = 1 statically instead
of doing it in main().

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
a677da5e3f25107d4402c1c917d019f2d0bc9f29 24-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Allocate -o OUTFILE buffer only if needed

text data bss dec hex filename
238258 668 28676 267602 41552 strace.before
238274 668 20484 259426 3f562 strace

* strace.c (main): Allocate -o OUTFILE buffer only if needed:
unused buffer in bss is not entirely free.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
82bb78c149a1b527f4ae7a764be29a9c85067b29 24-Jan-2012 Denys Vlasenko <vda.linux@googlemail.com> Use single fprintf in verror_msg()

This change partially reverts commit 44d0532.

In code before commit 44d0532, single fprintf was used on purpose:
we want to send entire message as one write() call. Since stderr
is unbuffered, separate fprintf's to it always result in separate
writes, they are not coalesced. If we aren't the only program
which writes to this particular stderr, this may result
in interleaved messages.

Since this function is not performance critical, I guess
it's ok to make it less efficient.

* strace.c (verror_msg): Attempt to print the message in single
write operation. Use separate fprintfs as a fallback if malloc fails.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
/external/strace/strace.c
023b7700de942f59fcb4cd30903969d276a4d796 18-Jan-2012 Denys Vlasenko <dvlasenk@redhat.com> Get rid of TCB_SIGTRAPPED

On attempts to block or set SIGTRAP handler,
for example, using sigaction syscall, we generate
an additional SIGSTOP.

This change gets rid of this SIGSTOP sending/ignoring.
It appears to work just fine.

It also works if I force strace to not use PTRACE_O_TRACESYSGOOD,
which means strace stops will be marked with SIGTRAP,
not (SIGTRAP | 0x80) - I wondered maybe that's when
this hack is needed.

So, why we even have TCB_SIGTRAPPED? No one knows. It predates
version control: this code was present in the initial commit,
in 1999. No adequate comments, either.

Moreover, TCB_SIGTRAPPED is not set in sys_rt_sigaction
and sys_sigprocmask syscalls - the ones which are most usually
used to implement signal blocking, it is only set in obsolete
sys_signal, sys_sigaction, sys_sigsetmask, and in some dead
non-Linux code.

I think whatever bug it was fixing is gone long ago -
at least as long as sys_rt_sigaction is used by glibc.
Again, since glibc (and uclibc) uses sys_rt_sigaction
and sys_sigprocmask, modified code paths are not used
by most programs anyway.

* defs.h: Remove definition of TCB_SIGTRAPPED.
* signal.c (sys_sigvec): Don't set TCB_SIGTRAPPED and don't send SIGSTOP.
(sys_sigsetmask): Likewise.
(sys_sigaction): Likewise.
(sys_signal): Likewise.
* strace.c (trace): Remove code which executes if TCB_SIGTRAPPED is set.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
5e09d77500a656da343580a16e6d005eb1c560b1 18-Jan-2012 Denys Vlasenko <dvlasenk@redhat.com> When we write log, flush output buffers in a few more cases

I observed a case when signal delivery message was buffered
by stdio until it was flushed along with the next syscall
entry message.

* strace.c (trace): Flush output buffers in a few more cases.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
f1e690370359f61f9533134817b52d74460a20fb 04-Jan-2012 Denys Vlasenko <dvlasenk@redhat.com> Do not detach from tracee which experienced ptrace error.

Before this patch, if a thread got nuked by exit in another thread
and we happened to poke it at the same time, we print "????(" thingy
and detach the thread. Since we removed "detach before death" logic,
this no longer matches the behavior of other threads.
Before patch:
[pid 1780] exit_group(1) = ?
[pid 1778] ????( <unfinished ...>
Process 1778 detached
[pid 5860] +++ exited with 1 +++
After:
[pid 17765] exit_group(1) = ?
[pid 21680] ????( <unfinished ...>
[pid 17791] +++ exited with 1 +++
[pid 21680] +++ exited with 1 +++

* strace (trace): Do not detach from tracee which experienced ptrace error.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
4c1963836fd96909c2d86315d4972b5b0075edf6 04-Jan-2012 Denys Vlasenko <dvlasenk@redhat.com> Remove sig parameter from detach()

* strace.c (detach): Drop sig parameter - it is zero in all calls.
(cleanup): Don't pass sig = 0 to detach() call.
(detach): Ditto.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
a5a839a920da9d54c4174ebc82b29d7718839029 23-Dec-2011 Dmitry V. Levin <ldv@altlinux.org> Enhance personality switching

On syscall entry, save current personality in the tcb structure
along with scno.
On syscall exit, restore current personality from the tcb structure.
* defs.h (struct tcb) [SUPPORTED_PERSONALITIES > 1]: Add currpers
field.
* strace.c (alloc_tcb) [SUPPORTED_PERSONALITIES > 1]: Initialize
tcp->currpers.
* syscall.c (update_personality) [SUPPORTED_PERSONALITIES > 1]: New
function.
(get_scno, trace_syscall_exiting): Use it.

Reported-by: Michael A Fetterman <mafetter@nvidia.com>
/external/strace/strace.c
436d892212dd56401bacf818a238333d30f85c6a 29-Nov-2011 Dmitry V. Levin <ldv@altlinux.org> strace.c (trace): Fix compilation warning
/external/strace/strace.c
f88837a666a716aecd9974f7ef3fcf006e0afce1 05-Sep-2011 Denys Vlasenko <dvlasenk@redhat.com> Do post-attach initialization earlier; fix "we ignore SIGSTOP on NOMMU" bug

We set ptrace options when we see post-attach SIGSTOP.
This is wrong: it's better to set them right away on the very first
stop (whichever it will be). It also will make adding SEIZE support easier,
since SEIZE has no post-attach SIGSTOP.

We do it by adding a new bit, TCB_IGNORE_ONE_SIGSTOP, and treating
TCB_STARTUP and TCB_IGNORE_ONE_SIGSTOP as two slightly different things.

* defs.h: Add a new flag bit, TCB_IGNORE_ONE_SIGSTOP.
* process.c (internal_fork): Set TCB_IGNORE_ONE_SIGSTOP on a newly added child.
* strace.c (startup_attach): Set TCB_IGNORE_ONE_SIGSTOP after attach.
Fix a case when "strace -p PID" found PID dead but sone other of its threads
still alive.
(startup_child): Set TCB_IGNORE_ONE_SIGSTOP after attach, _if needed_.
This fixes a bogus case where we can ignore a _real_ SIGSTOP on NOMMU.
(detach): Perform anti-SIGSTOP dance only if TCB_IGNORE_ONE_SIGSTOP is set,
not if TCB_STARTUP is set.
(trace): Set TCB_IGNORE_ONE_SIGSTOP after attach.
Clear TCB_STARTUP and initialize tracee on the very first tracee stop.
Clear TCB_IGNORE_ONE_SIGSTOP when SIGSTOP is seen.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
d116a7338645af45090aecc331701e999148d284 05-Sep-2011 Denys Vlasenko <dvlasenk@redhat.com> Get rid of TCB_ATTACH_DONE

* defs.h: Remove TCB_ATTACH_DONE constant.
* strace.c (startup_attach): Use TCB_STARTUP instead of TCB_ATTACH_DONE
to distinquish attached from not-yet-attached threads.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
381dbc22929428579f50d9b0b39193feba93dcfd 05-Sep-2011 Denys Vlasenko <dvlasenk@redhat.com> Set TCB_STARTUP only _after_ we attached.

This fixes logic in detach() which thinks that TCB_STARTUP
means that we are already attached, but did not see SIGSTOP yet.
This also allows to get rid of TCB_ATTACH_DONE flag.

* process.c (internal_fork): Set TCB_STARTUP after attach.
* strace.c (startup_attach): Likewise.
(startup_child): Likewise.
(alloc_tcb): Do not set TCB_STARTUP on tcb allocation - we are
not attached yet.
(trace): Set TCB_STARTUP when we detech an auto-attached child.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
6cda73ff9ca94e2be56d04186fceaca223a9c45b 02-Sep-2011 Denys Vlasenko <dvlasenk@redhat.com> Simple optimizations in trace()

* strace.c (trace): Calculate WSTOPSIG(status) once,
unify code paths to ptrace(PTRACE_SYSCALL).

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
014ca3a53cb24d8e12e87f43a880efc52940a8be 02-Sep-2011 Denys Vlasenko <dvlasenk@redhat.com> Trivial fixes on error paths

* strace.c (startup_attach): Emit message on fork() failure.
(startup_child): Remove non-informative comment.
* util.c (ptrace_restart): use perror_msg() on error instead of fprintf().

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
ab034fbf09460c2fd933ea47c9085d09b8a1ab27 01-Sep-2011 Denys Vlasenko <dvlasenk@redhat.com> Reformat setuid-ing code in startup_child()

New code does the same as old one, but is more readable (I hope).

* strace.c (startup_child): Reformat setuid-ing code.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
2e968c0bb7b89aa43df726eb651f0b51572b4194 01-Sep-2011 Denys Vlasenko <dvlasenk@redhat.com> Minor tweaks in startup_child(). Logic isn't changed (but code is)

* strace.c (startup_attach): Tweak comment.
(startup_child): Move common code out of ifdef.
Indent nested ifdefs. Tweak comments. Remove two
unnecessary calls to getpid().

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
60fe8c139c6f2febefe595781812ddf0864a6ab8 01-Sep-2011 Denys Vlasenko <dvlasenk@redhat.com> Use tprints with literal strings, it may be faster than tprintf

* bjm.c: Replace tprintf("str") with tprints("str").
* block.c: Likewise.
* desc.c: Likewise.
* file.c: Likewise.
* io.c: Likewise.
* ipc.c: Likewise.
* mem.c: Likewise.
* net.c: Likewise.
* proc.c: Likewise.
* process.c: Likewise.
* quota.c: Likewise.
* resource.c: Likewise.
* scsi.c: Likewise.
* signal.c: Likewise.
* sock.c: Likewise.
* strace.c: Likewise.
* stream.c: Likewise.
* syscall.c: Likewise.
* system.c: Likewise.
* term.c: Likewise.
* time.c: Likewise.
* util.c: Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
5940e6593911dcace424c668a1c0934c71fccb9e 01-Sep-2011 Denys Vlasenko <dvlasenk@redhat.com> Fix "format not a string literal" warning caused by tprintf(str)

* defs.h: Declare tprints().
* strace.c: Define tprints().
(tabto): Use tprints(str), since tprintf(str) was throwing a warning.
* desc.c: Use tprints(str) instead of tprintf("%s", str).
* file.c: Likewise.
* io.c: Likewise.
* net.c: Likewise.
* process.c: Likewise.
* signal.c: Likewise.
* syscall.c: Likewise.
* util.c: Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
1d46ba57a8ab16b353b531f2bbefe2ad7f354ca9 31-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Make out-of-memory handling more uniform

This fixes one real bug in dumpstr().

* defs.h: Declare die_out_of_memory().
* strace.c (die_out_of_memory): New function.
(strace_popen): If allocation fails, call die_out_of_memory().
(main): Likewise.
(expand_tcbtab): Likewise.
(rebuild_pollv): Likewise.
* count.c (count_syscall): Likewise.
(call_summary_pers): Likewise.
* desc.c (decode_select): Likewise.
* file.c (sys_getdents): Likewise.
(sys_getdents64): Likewise.
(sys_getdirentries): Likewise.
* pathtrace.c (pathtrace_match): Likewise.
* syscall.c (qualify): Likewise.
* util.c (printstr): Likewise.
(dumpiov): Likewise.
(dumpstr): Likewise.
(fixvfork): Likewise.
* mem.c (sys_mincore): Don't check free() parameter for NULL.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
a673f3fa62e1c2f34d27e88fb0772b9ee3d6f0f1 30-Aug-2011 Dmitry V. Levin <ldv@altlinux.org> Do not include <limits.h>

* strace.c: Do not include <limits.h> explicitly, it is already included
implicitly by <sys/param.h>.
/external/strace/strace.c
102ec4935440ff52a7fa3566154a84cc2473f16a 25-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Optimize tabto()

tabto is used in many lines of strace output.
On glibc, tprintf("%*s", col - curcol, "") is noticeably slow
compared to tprintf(" "). Use the latter.
Observed ~15% reduction of time spent in userspace.

* defs.h: Drop extern declaration of acolumn. Make tabto()
take no parameters.
* process.c (sys_exit): Call tabto() with no parameters.
* syscall.c (trace_syscall_exiting): Call tabto() with no parameters.
* strace.c: Make acolumn static, add static char *acolumn_spaces.
(main): Allocate acolumn_spaces as a string of spaces.
(printleader): Call tabto() with no parameters.
(tabto): Use simpler method to print lots of spaces.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
06602d99b72564e77600fc7c94e9ce8b78ec7085 24-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Rename some functions, delete unused one. No code changes

* defs.h: Rename get_scno_on_sysenter() to get_scno();
delete force_result() declaration.
* strace.c (proc_open): Rename get_scno_on_sysenter() to get_scno().
* syscall.c: Rename get_scno_on_sysenter() to get_scno().
Rename get_scno_on_sysexit() to get_syscall_result().
Delete unused force_result().

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
9a36ae5e886794865623b0d3d4f0d10bf541f32d 24-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> get_scno is an unholy mess, make it less horrible

Currently, get_scno does *much* more than "get syscall no".
It checks for post-execve SIGTRAP. It checks for changes
in personality. It retrieves params on entry and registers on exit.
Worse still, it is different in different architectures: for example,
for AVR32 regs are fetched in get_scno(), while for e.g. I386
it is done in syscall_enter().

Another problem is that get_scno() is called on both syscall entry and
syscall exit, which is stupid: we don't need to know scno on syscall
exit, it is already known from last syscall entry and stored in
tcp->scno! In essence, get_scno() does two completely different things
on syscall entry and on exit, they are just mixed into one bottle, like
shampoo and conditioner.

The following patches will try to improve this situation.

This change duplicates get_scno into identical get_scno_on_sysenter,
get_scno_on_sysexit functions. Call them in syscall enter and syscall
exit, correspondingly.

* defs.h: Rename get_scno to get_scno_on_sysenter; declare it only
if USE_PROCFS.
* strace.c (proc_open): Call get_scno_on_sysenter instead of get_scno.
* syscall.c (get_scno): Split into two (so far identical) functions
get_scno_on_sysenter and get_scno_on_sysexit.
(trace_syscall_entering): Call get_scno_on_sysenter instead of get_scno.
(trace_syscall_exiting): Call get_scno_on_sysexit instead of get_scno.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
b88f96129f8ebc064d490c8c161bcbc925d938c8 21-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Straighten up confused comments/messages about post-execve SIGTRAP handling

* defs.h: Explain TCB_INSYSCALL and TCB_WAITEXECVE bits in detail.
* strace.c (choose_pfd): Use entering/exiting macros instead of direct check
for TCB_INSYSCALL.
* syscall.c (get_scno): Use entering/exiting macros instead of direct check
for TCB_INSYSCALL. Fix comments about post-execve SIGTRAP.
(syscall_fixup): Use entering/exiting instead of direct check
for TCB_INSYSCALL. Add a comment what "not a syscall entry" message
usually means. Change wrong "stray syscall exit" messages into
"not a syscall entry" ones.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
2ecba32d52db699538bcfc3f69259aaff32a0fa9 21-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Optimize out dummy PC printing on signal delivery

* strace.c (trace): Optimize out dummy PC printing on signal delivery.
While at it, tweak comments.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
0890c8a403f60c2f66f17bf5d6bb16039b47c913 21-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Cosmetic improvement in ifdefs. No code changes

* strace.c (proc_open): Change ifdefs so that braces are properly paired.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
8dc0c8c5ef66c2b2eb76484b83c750c0712891f9 20-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Exclude tcp->pfd from non-procfs systems

* defs.h: Make struct tcb::pfd fields conditional on USE_PROCFS.
* strace.c (alloc_tcb): Use tcp->pfd only if USE_PROCFS.
(droptcb): Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
cfd364b011e170377ae002551c4391c01f51acbf 20-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Small optimizations related to memory allocation

* strace (expand_tcbtab): Shorten "out of memory" message.
(rebuild_pollv): Remove unnecessary NULL check before free().
* util.c (dumpstr): Add a comment about likely bug.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
5d64581e106f47c474707001f924ee15ef22830b 20-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Improve code readability by avoiding assignments inside if()

* desc.c (decode_select): Move assignment out of if() condition.
* file.c (sprinttime): Likewise.
(sys_getdirentries): Likewise.
* io.c (sys_ioctl): Likewise.
* strace.c (test_ptrace_setoptions_followfork): Likewise.
(main): Likewise.
(proc_open): Likewise.
(detach): Likewise.
(proc_poll): Likewise.
(trace): Likewise.
* syscall.c (qualify): Likewise.
(sys_indir): Likewise.
* test/procpollable.c (main): Likewise.
* test/sfd.c (main): Likewise.
* time.c (printtv_bitness): Likewise.
(sprinttv): Likewise.
(print_timespec): Likewise.
(void sprint_timespec): Likewise.
(printitv_bitness): Likewise.
* util.c (dumpstr): Likewise.
(umovestr): Likewise.
(fixvfork): Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
04f8b4860f12512186481ca21dbd311d9d612326 16-Aug-2011 Dmitry V. Levin <ldv@altlinux.org> Fix PTRACE_SETOPTIONS tests

* strace.c [LINUX] (kill_save_errno): New function.
(test_ptrace_setoptions_followfork): Change return type to void.
Fix and harden error handling. Use kill_save_errno() to avoid errno
clobbering. Treat EIO from ptrace() the same way as EINVAL.
(test_ptrace_setoptions_for_all): Use kill_save_errno() to avoid errno
clobbering. Treat EIO from ptrace() the same way as EINVAL.
(main): Update use of test_ptrace_setoptions_followfork().
/external/strace/strace.c
44f87efc676467ab47972feec49af4f7f34356bf 17-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Remove tcp->parent and TCB_CLONE_THREAD.

tcp->parent is used for only two things:
(1) to send signal on detach via tgkill (need to know tgid).
Solution: use tkill, it needs only tid.
(2) to optimize out ptrace options setting for new tracees.
Not a big deal if we drop this optimization: "set options" op is fast,
doing it just one extra time once per each tracee is hardly measurable.

TCB_CLONE_THREAD is a misnomer. It used only to flag sibling we attached to
in startup_attach. This is used to prevent infinite recursive rescanning
of /proc/PID/task.
Despite the name, there is no guarantee it is set only on non-leader:
if one would run "strace -f -p THREAD_ID" and THREAD_ID is *not*
a thread leader, strace will happily attach to it and all siblings
and will think that THREAD_ID is the leader! Which is a bug, but
since we no longer detach when we think tracee is going to die,
this bug no longer matters, because we do not use the knowledge
about thread group leaders for anything. (We used it to delay
leader's exit).

IOW: after this patch strace has no need to know about threads, parents
and children, and so on. Therefore it does not track that information.
It treats all tracees as independent entities. Overall,
this simplifies code a lot.

* defs.h: Add TCB_ATTACH_DONE flag, remove TCB_CLONE_THREAD flag
and struct tcb::parent field.
* process.c (internal_fork): Don't set tcpchild->parent.
* strace.c (startup_attach): Use TCB_ATTACH_DONE flag instead of
TCB_CLONE_THREAD to avoid attach attempts on already-attached threads.
Unlike TCB_CLONE_THREAD, TCB_ATTACH_DONE bit is used only temporarily,
and only in this function. We clear it on every tcb before we return.
(detach): Use tkill instead of tgkill.
(trace): Set ptrace options on new tracees unconditionally,
not only when tcp->parent == NULL.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
833fb13cef3f1f05b71361b5002aa3c2faad9615 17-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Remove TCB_SUSPENDED constant and related code.

Since we no longer suspend waitpid'ing tracees, we have only one case when
we suspend tracee: when we pick up a new tracee created by clone/fork/vfork.

Background: on some other OSes, attach to child is done this way:
get fork's result (pid), loop ptrace(PTRACE_ATTACH) until you hook up
new process/thread. This is ugly and not safe, but what matters for us
is that it doesn't require suspending. Suspending is required
on Linux only, because on Linux attach to child is done differently.

On Linux, we use two methods of catching new tracee:
adding CLONE_THREAD bit to syscall (if needed, we change
[v]fork into clone before that), or using ptrace options.
In both cases, it may be so that new tracee appears before one which
created it returns from syscall. In this case, current code
suspends new tracee until its creator returns. Only then
strace can determine who is its parent (it needs child's pid for this,
which is visible in parent's [v]fork/clone result).
This is inherently racy. For example, what if SIGKILL kills
creator after it succeeded creating child, but before it returns?
Looks like we will have child suspended forever.

But after previous commit, we DO NOT NEED parent<->child link for anything.
Therefore we do not need suspending too. Bingo!

This patch removes suspending code. Now new tracees will be continued
right away. Next patch will remove tcp->parent member.

* defs.h: Remove TCB_SUSPENDED constant
* process.c (handle_new_child): Delete this function.
(internal_fork): Do not call handle_new_child on syscall exit.
* strace.c (handle_ptrace_event): Delete this function.
(trace): Do not suspend new child; remove all handling
of now impossible TCB_SUSPENDED condition.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
19cdada5b499b978ffd9c3367b4ef34ad6f8bf2b 17-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Do not detach when we think tracee is going to die.

Current code plays some ungodly tricks, trying to not detach
thread group leader until all threads exit.

Also, it detaches from a tracee when signal delivery is detected
which will cause tracee to exit.
This operation is racy (not to mention the determination
whether signal is set to SIG_DFL is a horrible hack):
after we determined that this signal is indeed fatal
but before we detach and let process die,
*other thread* may set a handler to this signal, and
we will leak the process, falsely displaying it as killed!

I need to look in the past to figure out why we even do it.
First guess is that it's a workaround for old kernel bugs:
kernel used to deliver exit notifications to the tracer,
not to real parent. These workarounds are ancient
(internal_exit is from 1995).

The patch deletes the hacks. We no longer need tcp->nclone_threads,
TCB_EXITING and TCB_GROUP_EXITING. We also lose a few rather
ugly functions.

I also added a new message: "+++ exited with EXITCODE +++"
which shows exact moment strace got exit notification.
It is analogous to existing "+++ killed by SIG +++" message.

* defs.h: Delete struct tcb::nclone_threads field,
TCB_EXITING and TCB_GROUP_EXITING constants,
declarations of sigishandled() and internal_exit().
* process.c (internal_exit): Delete this function.
(handle_new_child): Don't ++tcp->nclone_threads.
* signal.c (parse_sigset_t): Delete this function.
(sigishandled): Delete this function.
* strace.c (startup_attach): Don't tcbtab[tcbi]->nclone_threads++.
(droptcb): Don't delay dropping if tcp->nclone_threads > 0,
don't drop parent if its nclone_threads reached 0:
just drop (only) this tcb unconditionally.
(detach): don't drop parent.
(handle_group_exit): Delete this function.
(handle_ptrace_event): Instead of handle_group_exit, just drop tcb;
do not panic if we see WIFEXITED from an attached pid;
print "+++ exited with EXITCODE +++" for every WIFEXITED pid.
* syscall.c (internal_syscall): Do not treat sys_exit specially -
don't call internal_exit on it.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
26d1b1eaa861ec33d2c671acc9c0ccb867042cb8 15-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Slight optimization and cleanup in trace()

* strace.c (trace): Do not recalculate "cflag ? &ru : NULL"
again and again. Do not clear errno unnecessarily.
Consistently check wait errors as pid < 0, not pid == -1.
Indent ifdefs for better readability.
Remove comments after endif if ifdef/endif block is really tiny.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
5bd67c86a93c658d258348e8f14af94fd45cbeb6 15-Aug-2011 Denys Vlasenko <dvlasenk@redhat.com> Fix compilation on 2.4.20 kernel based system

* block.c (block_ioctl): add ifdef/endif around BLKGETSIZE64 usage
* strace.c (trace): add ifdef/endif around WIFCONTINUED usage

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
13d22f1aa3a1beba79a8febb3770f75e646211a8 24-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Trivial cleanups

* strace.c (trace): Change ifdef LINUX to make a bit more sense,
remove wrong comment at its endif. Slightly optimize
"+++ killed by SIG +++" message for systems without WCOREDUMP macro.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
e18314ed0fc97ed9df74944d755a9be63075178c 24-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Remove redundant include <stdarg.h>

* strace.c: Remove redundant include <stdarg.h>

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
178de007d14f3ae890117b540def9cf14bcb61fe 24-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Clean up two old comments

* strace.c (startup_attach): Remove misplaced comment.
(trace) Remove incomplete part of a comment.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
ead73bd3493c517fde508aecf6bc097aeae1752c 24-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Make a few variables static.

* defs.h: Remove tcbtab declaration.
* strace.c: Make run_uid, run_gid, outf, tcbtab, progname
global variables static

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
f95397afb8aadf017b2d3d42056c5929dbf16775 24-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Add debug output in initial attachment code

* strace.c (startup_attach): If -d, report pid and success/failure
of every attach attempt.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
1d5f12ecb88f0cd7aa889d1d7ebd47449f4691b7 24-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Better debug logging of allocations and waitpit results

* strace.c (alloc_tcb): Print number of allocated tcb's if -d.
(droptcb): Likewise.
(handle_ptrace_event): Remove PTRACE_EVENT_EXEC debug message.
(trace): Improve logging of waitpid: show WIFxxx, exitcode/signal,
ptrace event name, WCOREDUMP - all on one line.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
65d7c4d66c209dce592a5a2ec0d1f83eef6b2f28 23-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Remove TCB_FOLLOWFORK

TCB_FOLLOWFORK flag seems to be unnecessary, because we either follow
all [v]forks/clones or don't follow any, therefore global variable
followfork is an already existing indicator of what we want to do.
This patch drops all setting/clearing of TCB_FOLLOWFORK bit,
and replaces checks for this bit by checks of followfork value.
In internal_fork, check is moved to in front of if(), since
the check is needed on both "entering" and "exiting" branch.

* defs.h: Remove TCB_FOLLOWFORK define.
* process.c (internal_fork): Do not set/clear TCB_FOLLOWFORK,
test followfork instead of tcp->flags & TCB_FOLLOWFORK.
(handle_new_child): Likewise.
* strace.c (startup_attach): Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
4f12af24e4c1d4e44b84ba6d5e72e6d8b6490e35 23-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Make initial tcb allocation more readable. No logic changes.

* strace.c (main): Make initial tcb allocation more readable.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
cb2ad00652e746b370703b5470932b7612308b9c 23-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Use [p]error_msg[_and_die] where appropriate. No logic changes.

Resulting size changes:
text data bss dec hex filename
17445 16 8572 26033 65b1 strace.o.old
16850 16 8572 25438 635e strace.o

* strace.c: Replace fprintf[+cleanup]+exit with [p]error_msg_and_die,
fprintf("progname: ...") with [p]error_msg where appropriate.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
7b609d5ba0852e6c56ba311350ebd4412361777b 22-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Whitespace cleanups. No code changes.

* count.c: Place opening curly brace after if (),
not on the next line. Almost all strace code alredy
uses this style.
* desc.c: Likewise.
* file.c: Likewise.
* net.c: Likewise.
* pathtrace.c: Likewise.
* process.c: Likewise.
* quota.c: Likewise.
* signal.c: Likewise.
* strace.c: Likewise.
* syscall.c: Likewise.
* time.c: Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
3d5ed41252ab8c0bb9f410058c61e95ba91caf90 22-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Make strace_fopen abort on error

Error from strace_fopen in main results in call to exit(1).
Error from strace_fopen in newoutf is propagated to newoutf
callers: startup_attach (where it results in exit(1))
and alloc_tcb (where error is ignored). In second case,
the behavior doesn't seem to be right: it means with -ff
on open error for new LOGFILE.PID the output will continue
to go into *the same file as the previous process* - which
would be confusing. Moreover, on droptcb outf may be closed
and the output of other, still running process outputting
to the same outf will be lost. I don't think this is sane.
IOW: in all cases, error in strace_fopen should be fatal.

* strace.c (strace_fopen): Abort on error instead of returning NULL.
(newoutf): Change return type to void.
(startup_attach): Remove error check on newoutf return value.
(main): Remove error check on strace_fopen return value.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
1f532ab27db945c33818ba5298fdd78c52d229ea 22-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Make set_cloexec_flag abort on error

set_cloexec_flag() may fail only if we pass it a bad fd,
such as -1 or non-opened one. If we do, we have a bug
in the caller. It makes no sense to try to continue
running when we detect such a blatant bug in our own code.

* strace (set_cloexec_flag): Abort instead of returning error
indicator. Change function to return void.
(strace_fopen): Remove error check on set_cloexec_flag return value.
(proc_open): Likewise.
(proc_poll_open): Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
7dd23384f77e9917bd3173c673f318c5d5b485ac 22-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Make strace_popen abort on error

It makes no sense to postpone abort on strace_popen error
unti it returns. Moreover, out-of-memory error was exiting
without any message.
While at it, use 0 as "none" for popen_pid, as optimization.

* strace: Initialize popen_pid to 0 - this puts it in bss.
(trace): Reset popen_pid to 0 instead of -1.
(strace_popen): Never return NULL as error indicator,
abort with good error message instead.
(main): Remove NULL check of strace_popen result.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
2b60c35b33cf22a88405c60db1e620880d05a7d4 22-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Delete fork_tcb()

Get rid of fork_tcb() function. It used to do what the comment
above it says, but now it doesn't do much:
it only sets tcp->flags |= TCB_FOLLOWFORK and maybe calls
expand_tcbtab(). The second operation is not necessary, since
alloc_tcp() will do it itself when needed.
This patch deletes fork_tcb(), open-coding tcp->flags |= TCB_FOLLOWFORK
where it was formerly called. It also makes nprocs, tcbtabsize and
expand_tcbtab() static. (While at it, I nuked redundant
extern char **environ declaration: strace.c had *two* of them...)

* defs.h: Remove declarations of nprocs, tcbtabsize and
expand_tcbtab.
* process.c (fork_tcb): Remove this function.
(internal_fork): Open-code fork_tcb.
(handle_new_child): Likewise.
* strace.c: Remove redundant "extern char **environ". Declare
nprocs and tcbtabsize static.
(expand_tcbtab): Make it static.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
18da27367534217ac52a425413ae3f8b4b9d8ad2 22-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Simplify expand_tcbtab and alloc_tcb

Get rid of a few intermediate variables, simplifies a few expressions,
and uses error_msg_and_die instead of more verbose
fprintf+cleanup+exit sequence.
In alloc_tcp, I use memset to clear entire new tcp.
This not only saves a few bytes of code, but lowers the chances
of future bugs where some data "leaks out" into new tcb's
from old ones because we forgot to re-initialize it.

* strace.c (expand_tcbtab): Simplify this function. No logic changes.
(alloc_tcb): Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
b56d6d3bfeeb8889ea18105033acfba6f3fcbf51 21-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Remove write-only nchildren member from struct tcb

* defs.h: Remove nchildren member from struct tcb.
* process.c (handle_new_child): Remove inc/decrements of tcp->nchildren.
(internal_fork): Likewise.
* strace.c (startup_attach): Likewise.
(droptcb): Likewise.
(alloc_tcb): Remove initialization of tcp->nchildren.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
f0a5f6d7107ade2ea9c425330655e97d11d17d79 21-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Remove write-only nzombies member from struct tcb

* defs.h: Remove nzombies member from struct tcb.
* strace.c (droptcb): Remove "tcp->parent->nzombies++".
(alloc_tcb): Remove "tcp->nzombies = 0".

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
f44cce48bbbd573cc5ae801f69f857433160b03a 21-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Fix regression introduced by "Properly handle real SIGTRAPs" change

Commit 3454e4b463e6c22c7ea8c5461ef5a077f4650a54
introduced a bug: sometimes, TRACECLONE/TRACE[V]FORK opts were not set.
The check (tcp->parent == NULL) in old code was meant to check
"if we are not a child created by auto-attach" - in this case,
options need to be set on the child; otherwise they are inherited
and do not need to be set.
I misunderstood the check and if tcp->parent is not NULL, I was
setting only ptrace_setoptions_for_all bits.
This change fixes the problem. Since the fixed logic makes it
unnecessary to keep two sets of options in separate variables,
I merge them back into one variable, ptrace_setoptions.

* defs.h: Merge ptrace_setoptions_followfork and ptrace_setoptions_for_all
into one variable, ptrace_setoptions.
* strace.c: Likewise.
(test_ptrace_setoptions_followfork): Use ptrace_setoptions variable.
(test_ptrace_setoptions_for_all): Likewise.
(main): Likewise.
* process.c (internal_fork): Likewise.
(internal_exec): Likewise.
* strace.c (trace): Fix the bug where different options were set
depending on "tcp->parent == NULL" condition. Add a comment
which makes it more clear why this condition is checked.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
0df9ed47af7a9385a2fbe6ba688ed4fc24ab0c00 18-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Do not suspend waitpid.

strace used to suspend waitpid until there is a child
for waitpid'ing process to collect status from.
Apparently, it was done because in some very old kernels
(circa 2002 or even earlier) there were ptrace bugs which
were making waitpid in real parent to not see children.
This kernel bug is fixed long ago. This change removes the workaround.
test/wait_must_be_interruptible.c is a test program which
illustrates why without this change strace changes
programs's behavior.

* defs.h: Delete waitpid and nclone_waiting members from from struct tcb.
Remove declaration of internal_wait().
* process.c (internal_wait): Remove this function.
* strace.c (alloc_tcb): Do not set tcp->nclone_waiting.
(resume): Remove this function.
(resume_from_tcp): Remove this function.
(detach): Do not call resume_from_tcp().
(handle_group_exit): Do not call resume_from_tcp().
* syscall.c (internal_syscall): Do not call internal_wait().

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
44d053218ba658c901c3ab7dd905ab31ba417286 09-Jun-2011 Dmitry V. Levin <ldv@altlinux.org> * strace.c (verror_msg): Rewrite without use of heap memory allocation
/external/strace/strace.c
e62df004ce7a649c014fc0b5af058d56bc168920 08-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Print at least one space between SYSCALL(ARGS) and = RESULT if tracee is killed

We already do it in the normal case, but in rare code path where
tracee is gone (SIGKILLed?) sometimes we were printing this:
"SYSCALL(ARGS <unavailable>)= ? <unavailable>" - note jammed together ")=".
test/sigkill_rain.c can be used to verify the fix.

* strace.c (printleader): add a space after ")" in " <unavailable>)"

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
b63256e69bf3f1a74aadb0e14556490bc8f4ef95 07-Jun-2011 Denys Vlasenko <dvlasenk@redhat.com> Whitespace cleanups. no code changes.

* bjm.c: Fix tabulation (such as extra spaces before tabs),
convert punctuation where it deviates from prevalent form
elsewhere in strace code, convert sizeof and offsetof where
it deviates from from prevalent form, remove space between
function/macro/array names and (parameters) or [index],
add space between "if" and (condition), correct non-standard
or wrong indentaion.
* defs.h: Likewise
* desc.c: Likewise
* file.c: Likewise
* ipc.c: Likewise
* linux/arm/syscallent.h: Likewise
* linux/avr32/syscallent.h: Likewise
* linux/hppa/syscallent.h: Likewise
* linux/i386/syscallent.h: Likewise
* linux/ioctlsort.c: Likewise
* linux/m68k/syscallent.h: Likewise
* linux/microblaze/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/tile/syscallent.h: Likewise
* linux/x86_64/syscallent.h: Likewise
* mem.c: Likewise
* net.c: Likewise
* pathtrace.c: Likewise
* process.c: Likewise
* signal.c: Likewise
* sock.c: Likewise
* strace.c: Likewise
* stream.c: Likewise
* sunos4/syscall.h: Likewise
* sunos4/syscallent.h: Likewise
* svr4/syscall.h: Likewise
* svr4/syscallent.h: Likewise
* syscall.c: Likewise
* system.c: Likewise
* test/childthread.c: Likewise
* test/leaderkill.c: Likewise
* test/skodic.c: Likewise
* time.c: Likewise
* util.c: Likewise

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
1201426dd43f5b4e12dfe520e2a9c5027d33dc11 30-May-2011 Denys Vlasenko <dvlasenk@redhat.com> "Modernize" all old-style function parameter declarations

* bjm.c: Convert all remaining old-style C function definitions
to a "modern" form. This does not change any actual code.
* io.c: Likewise
* ioctl.c: Likewise
* net.c: Likewise
* proc.c: Likewise
* process.c: Likewise
* signal.c: Likewise
* sock.c: Likewise
* strace.c: Likewise
* stream.c: Likewise
* syscall.c: Likewise
* system.c: Likewise
* time.c: Likewise
* util.c: Likewise

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
75422766d51cf96ea081977c9d0b26b2ba1a8ade 27-May-2011 Denys Vlasenko <dvlasenk@redhat.com> Cleanups on top of "handle SIGTRAP properly" change,
based on Dmitry's comments.

* defs.h ([p]error_msg[_and_die]): Declare new functions.
* strace.c (SYSCALLTRAP): Rename to syscall_trap_sig.
([p]error_msg[_and_die]): Define new functions.
(strace_tracer_pid): New variable, it controls which pid will
do cleanup on exit via [p]error_msg_and_die.
(main): Set strace_tracer_pid to our initial pid.
(startup_attach): Change strace_tracer_pid if we are in -D mode.
(test_ptrace_setoptions_for_all): Minor changes to logic,
such as better diagnostic messages.
/external/strace/strace.c
35aba6a8dd87a8d1fd69110d80f98224d1f5b18d 25-May-2011 Denys Vlasenko <dvlasenk@redhat.com> Identifier "errno" may be a macro, it's unsafe to use it

* strace.c (strerror): Rename parameter errno to err_no
/external/strace/strace.c
f8bc0655a0db6fd3031384a88cdc707285029ca5 24-May-2011 Denys Vlasenko <dvlasenk@redhat.com> Don't perform TCB_WAITEXECVE wait if not needed.

* defs.h (ptrace_setoptions_for_all): Expose this variable.
* strace.c (ptrace_setoptions_for_all): Remove "static".
* process.c (internal_exec): Don't set TCB_WAITEXECVE bit
if we know that post-execve SIGTRAP is not going to happen.
/external/strace/strace.c
3454e4b463e6c22c7ea8c5461ef5a077f4650a54 23-May-2011 Denys Vlasenko <dvlasenk@redhat.com> Properly handle real SIGTRAPs.

* defs.h (ptrace_setoptions): Variable renamed to ptrace_setoptions_followfork.
* process.c (internal_fork): Ditto.
* strace.c (ptrace_setoptions_for_all): New variable.
(SYSCALLTRAP): New variable.
(error_msg_and_die): New function.
(test_ptrace_setoptions_for_all): New function.
(main): Call test_ptrace_setoptions_for_all() at init.
(handle_ptrace_event): Handle PTRACE_EVENT_EXEC (by ignoring it).
(trace): Check events and set ptrace options without -f too.
Check WSTOPSIG(status) not for SIGTRAP, but for SYSCALLTRAP.
/external/strace/strace.c
8a08277d13d0378c2ff3ce851534c3bf7e31defa 07-Apr-2011 Grant Edwards <grant.b.edwards@gmail.com> Add ability to print file descriptor paths and filter by those paths

* pathtrace.c: New file, implements matching syscall arguments to
user-specified file paths.
* Makefile.am (strace_SOURCES): Add pathtrace.c.
* defs.h (TCB_FILTERED, filtered): New defines.
(getfdpath, pathtrace_select, pathtrace_match, show_fd_path,
tracing_paths): New declarations.
* strace.c (show_fd_path, tracing_paths): New global variables.
(usage, main): Implement handling of -y and -P options.
* strace.1: Add descriptions of -y and -P options.
* syscall.c (trace_syscall_entering): Add path matching logic to the
print/noprint decision and set the TCB_FILTERED bit appropriately.
(trace_syscall_exiting): Use filtered() macro that checks the
TCB_FILTERED bit to determine print/noprint status.
* util.c (printfd): Use getfdpath().
/external/strace/strace.c
6b7a261ff81fdbe84769cb59852fa43cabc77e8f 10-Mar-2011 Dmitry V. Levin <ldv@altlinux.org> Show more details about signals received by traced processess

* strace.c [!USE_PROCFS] (trace): Differentiate output format depending
on PTRACE_GETSIGINFO success or failure. In the former case, use
printsiginfo() to show more details about received signal.
/external/strace/strace.c
c15dfc796150d09bb74bebfbb85bebf142766b6c 10-Mar-2011 Dmitry V. Levin <ldv@altlinux.org> Get rid of PT_GETSIGINFO

* strace.c [!USE_PROCFS] (trace): Assume that PTRACE_GETSIGINFO is
available. Replace PT_GETSIGINFO with PTRACE_GETSIGINFO. Use
PTRACE_GETSIGINFO for all signals.
/external/strace/strace.c
2fabd0eaf05379bf121c208ee7a1c129ce1f2f18 19-Feb-2011 Dmitry V. Levin <ldv@altlinux.org> Fix PTRACE_GETEVENTMSG usage and enhance test_ptrace_setoptions()

* strace.c (handle_ptrace_event): Fix PTRACE_GETEVENTMSG usage.
(test_ptrace_setoptions): Test that PTRACE_GETEVENTMSG works properly.
/external/strace/strace.c
21ccf5ed07ed7b9f208827dc7ba9b932bfa6cfaa 13-Jan-2011 Dmitry V. Levin <ldv@altlinux.org> 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().
/external/strace/strace.c
8044bc1463f62ae5f974cc531576bc18dade0337 07-Dec-2010 Dmitry V. Levin <ldv@altlinux.org> 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().
/external/strace/strace.c
b1467440f7c57c4ba9dc17ab9756e45c84d0adbe 02-Dec-2010 Dmitry V. Levin <ldv@altlinux.org> Cleanup test_ptrace_setoptions()

* strace.c (test_ptrace_setoptions): Cleanup.
(main): Fix test_ptrace_setoptions() error diagnostics message.
Print ptrace_setoptions value in debug mode.
/external/strace/strace.c
ca8ab8d2958f86297a6574a73cc1b9759d59c9b1 12-Nov-2010 Wang Chao <wang.chao@cn.fujitsu.com> 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>
/external/strace/strace.c
b13c0de058585de7d47778a8923426b89bfffbb5 12-Nov-2010 Wang Chao <wang.chao@cn.fujitsu.com> 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>
/external/strace/strace.c
54e931fb858410644f61885b4b36fc20320e1fc6 15-Sep-2010 Roland McGrath <roland@redhat.com> 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).
/external/strace/strace.c
30145dda9d7ff70df1d5ad750a183572c73e8963 07-Sep-2010 Dmitry V. Levin <ldv@altlinux.org> 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 *".
/external/strace/strace.c
21b8db4eb966a6098c7cd10bd6cf0ce8ec59cab8 27-Aug-2010 Wang Chao <wang.chao@cn.fujitsu.com> 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>
/external/strace/strace.c
d322a4bbe118642c4c9b170451a601a1e80b72d6 05-Aug-2010 Wang Chao <wang.chao@cn.fujitsu.com> 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>
/external/strace/strace.c
372cc84c972f8e88cc148f343b02f4b5beb83dc7 09-Jul-2010 Andreas Schwab <schwab@redhat.com> Balance braces

* strace.c (proc_open): Avoid unbalanced braces.
(trace): Likewise.
/external/strace/strace.c
b87d30c785679b37a2ec7242881f0d0b819c738d 11-Jun-2010 Andreas Schwab <schwab@redhat.com> Document -C/-D

* strace.c (usage): Document -C.
* strace.1: Document -D.
/external/strace/strace.c
e3a7ef5a2a3ac31bfa0d3f9ce65981e51700073e 28-Mar-2010 Dmitry V. Levin <ldv@altlinux.org> 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.
/external/strace/strace.c
e5e60858063f214fcd7860f50f8bcb46f951f9ab 31-Dec-2009 Dmitry V. Levin <ldv@altlinux.org> Remove dead code

* defs.h (tv_tv): Remove.
* net.c (sys_xsetsockaddr): Remove commented out dead code.
* process.c (setarg, sys_execv, sys_execve, struct_user_offsets):
Likewise.
* signal.c (sys_sigsuspend): Likewise.
* strace.c (reaper, trace): Likewise.
* stream.c (internal_stream_ioctl): Likewise.
* syscall.c (trace_syscall): Likewise.
* term.c (term_ioctl): Likewise.
* util.c (tv_tv, umoven, uload, getpc, fixvfork, setbpt, clearbpt):
Likewise.
/external/strace/strace.c
840d85b3e50cea9f28aedd23af94742c2a60265a 12-Jan-2010 Andreas Schwab <schwab@redhat.com> Don't kill the process when detaching

* strace.c (detach): Call clearbpt when TCB_BPTSET is set.
/external/strace/strace.c
e5355de95c495dcfc616509f88c4fb5f9996b8e6 27-Oct-2009 Andreas Schwab <schwab@redhat.com> Remove support for pre-C89

* defs.h: Remove references to __STDC__ and P macros.
* strace.c: Likewise.
/external/strace/strace.c
ccdff481c086611488c5df70550fcf8fe907e7af 27-Oct-2009 Andreas Schwab <schwab@redhat.com> Maintain separate print column for each process

* defs.h (struct tcp): Add curcol.
* strace.c: (alloc_tcb): Initialize it.
(trace): Use curcol from current process and save it before
continuing.
(tprintf): Don't modify curcol on output error.
/external/strace/strace.c
c1a5b7e8c42086635d09ce8adc7f8b3dd018c999 08-Oct-2009 Mike Frysinger <vapier@gentoo.org> Add support for Linux/no-mmu with vfork

* configure.ac (AC_CHECK_FUNCS): Add fork.
* strace.c (strace_vforked): Define.
(startup_child): Do not raise SIGSTOP if vforked.
(trace): Skip first exec when starting up after vforked.
* syscall.c [BFIN] (get_scno): Drop waitexec checks.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
/external/strace/strace.c
eb9e2e8904ce85a6c7390be25bb873c6db88c4d3 03-Jun-2009 Roland McGrath <roland@redhat.com> Revert unapproved commits.
/external/strace/strace.c
4ac9d627f4b8d2022958668e5c2f3b784605cb16 01-Jun-2009 Dmitry V. Levin <ldv@altlinux.org> * strace.c (handle_stopped_tcbs): Fix cast for 4th argument passed to ptrace().
/external/strace/strace.c
246f42ff5ab28f71a08d790352f9411db99e0fb8 20-Apr-2009 Denys Vlasenko <dvlasenk@redhat.com> * strace.c (collect_stopped_tcbs): Do not enable/disable signals
multiple times, do it just once per collecting pass.
/external/strace/strace.c
1e209212163c84290990e1c5e75200c733ba0bf2 20-Mar-2009 Denys Vlasenko <dvlasenk@redhat.com> As it turned out, "if (interrupted) break;" is needed in both loops,
in "collect tasks" loop and in enclosing "collect/process" loop.
Before this patch, "strace cat" + "killall -INT strace" wasn't
making strace stop and exit. This patch restores 4.5.18 behavior
in this regard.
/external/strace/strace.c
aab52cae4cf597a556911fec3ef4cb5803a95b12 17-Mar-2009 Denys Vlasenko <dvlasenk@redhat.com> Remove "better attach to SIGSTOP", it is not correct...
(^C fix remains).
/external/strace/strace.c
222713aa409c5caa47327a084f1083a7d6fee66f 17-Mar-2009 Denys Vlasenko <dvlasenk@redhat.com> * strace.c (startup_attach): Take care to correctly attach
to stopped processes by resending SIGSTOP.
(collect_stopped_tcbs): Check for ^C here, not in trace().
(trace): Remove check for ^C.
/external/strace/strace.c
5ae2b7c601dadf79a4345e1ee21053947b9e4add 27-Feb-2009 Denys Vlasenko <dvlasenk@redhat.com> AVR32 support by Hans-Christian Egtvedt
(hans-christian.egtvedt AT atmel.com).
* configure.ac: Make it recognize avr32.
* defs.h: Define LINUX_AVR32.
* linux/avr32/syscallent.h: New file.
* Makefile.am: Reference linux/avr32/syscallent.h.
* proc.c (change_syscall, setarg): Add support for avr32.
(struct xlat struct_user_offsets[]): Ditto.
* syscall.c (get_scno): Ditto.
(get_error, force_result, syscall_enter): Ditto.
* util.c (getpc, printcall): Ditto.
/external/strace/strace.c
8ed57276426392f961d557ea0bf54d9ba6ac4a5f 25-Feb-2009 Denys Vlasenko <dvlasenk@redhat.com> By Hans-Christian Egtvedt (hans-christian.egtvedt AT atmel.com):

strace.c: suppress "warning: unused static" message by adding #ifdef's around
a variable
.gitignore: trivial
test/*.c: cleanup (suppress warnings, much better style).
/external/strace/strace.c
4dedd561d61562fe66f1a0b673ad33ac6a1e3c71 24-Feb-2009 Denys Vlasenko <dvlasenk@redhat.com> Replace many more bare ptrace calls with calls to wrappers
which do proper error-checking and set tcp->ptrace_errno.
In some cases, missing error checking is added.
Error handling for trace_syscall() failures and other cases
where tcp->ptrace_errno is nonzero is cleaned up a bit
and made more verbose if we see error other than ESRC.
Some comments are added or expanded.
* defs.h: Declare ptrace_cmds[]. Modify do_ptrace
declaration (last parameter is long, not void *).
* process.c: Make ptrace_cmds[] non-static.
(change_syscall): Use do_ptrace() instead of bare ptrace().
* signal.c: Use do_ptrace() instead of bare ptrace().
* strace.c: Update trace_syscall() failure handling.
* syscall.c: Use do_ptrace() instead of bare ptrace().
* util.c: Use do_ptrace() instead of bare ptrace().
Update do_ptrace() wrapper.
(str_PTRACE_xxx): New function - helper returning "PTRACE_xxx".
(do_ptrace_peekdata): New function - wrapper for PTRACE_PEEKDATA
(do_ptrace5): New function - wrapper for 5-argument ptrace calls.
/external/strace/strace.c
84e20af5a6f3d6e02c24579b60a282053ef01e0e 10-Feb-2009 Denys Vlasenko <dvlasenk@redhat.com> Cleanup after tcb table expansion simplification.
There was code which was trying to continue tracing
even if table expansion fails. Now we treat it as fatal
failure, so this code is removed by this change.
* defs.h: Delete TCB_FOLLOWFORK constant.
* process.c: Delete fork_tcb() and all calls of it.
* strace.c (startup_attach): Remove usage of TCB_FOLLOWFORK.
* syscall.c: Indent preprocessor directives.
/external/strace/strace.c
3bb7cd6660032e97f76e8f62efd3540dbba97656 09-Feb-2009 Denys Vlasenko <dvlasenk@redhat.com> * defs.h: Correct the comment about TCB_SUSPENDED.
* strace.c: Fix misplaced #endif.
* util.c: Indent preprocessor directives, mark code parts
which can never be reached by compilation because of
the combination of #if directives. These are likely dead code,
I want to remove them later.
/external/strace/strace.c
7a8bf065802f836901ae886317efcb4ed77cae7b 29-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> * strace.c (newoutf): Prevent -o FILENAME overflowing the stack.
(startup_attach): Fix wrong pid in "Process <PID> attached".
(handle_group_exit): Do not consider exit to be spurious if
tcb has TCB_STARTUP bit set - we can attach to the task
right before its death, it can legitimately happen.
(handle_stopped_tcbs): Ditto.
/external/strace/strace.c
7e0615f3aecc023e2756a83bdf113c5ceaac431d 28-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> * process.c (internal_clone): Check and complain if pid value
looks insane.
* strace.c (alloc_tcb): Clear *all* fields in reused tcb.
(main): Query and remember uname() info on startup.
(handle_stopped_tcbs): Do not use PTRACE_SETOPTIONS on Linux < 2.6.29.
(printleader): Correct printing of "<unavailable>" markers.
/external/strace/strace.c
47ce6dfc9f54fe8809179fd4e200e4e2f5bb7d02 27-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> * strace.c (collect_stopped_tcbs): Guard against the case when
waitpid() reports the same task multiple times.
Run tested.
/external/strace/strace.c
2c8a2583612f4df2a93cb8d180aadda4e93ec1dd 21-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> * strace.c (collect_stopped_tcbs): Do not return NULL when ECHILD
is detected, return collected list instead. Fixes symptom when
the last "+++ killed by SIGxxx +++" is not printed.
/external/strace/strace.c
418d66a847bda4867c59e604c0d07c64ed53e320 17-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> Two cleanups: tcb table expansion failure is not really a survivable
event, we do not have any viable way to continue. No wonder most
places where that is detected have FIXMEs.
It's way simpler to treat as fatal failure, and handle it inside
tcb table expansion finctions.
Second cleanup: tidy up haphazard locations of a few externs.

* defs.h: Change return type of expand_tcbtab() to void.
Declare change_syscall().
* process.c: Change all callsites of alloctcb(), alloc_tcb() and
fork_tcb(), removing now-redundant error checks.
(fork_tcb): Change return type to void - it can't fail now.
* strace.c: Move extern declarations out of function bodies.
Change all callsites of alloctcb(), alloc_tcb() and
fork_tcb(), removing now-redundant error checks.
(expand_tcbtab): Change return type to void - it can't fail now.
On failure to expand, print a message, clean up, and exit.
(alloc_tcb): On failure to expand, print a message, clean up, and exit.
* util.c (setbpt): Remove extern declaration from function body.
/external/strace/strace.c
1d5b113f8c013b11afa10de8393e770b29c648fd 17-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> * defs.h: Update a comment. No code changes.
* strace.c (handle_stopped_tcbs): Discard all execve stops
and clear TCB_WAITEXECVE bit.
* syscall.c (get_scno): Add the code to not mistakenly
treat ptrace stop as execve stop (execve stops can be blocked
by traced program).
Fixes RH#477775 "strace hangs if the target process blocks SIGTRAP".
/external/strace/strace.c
f9a7e63a1ad57a87c1e6be10b7a6b49282ed1203 17-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> * process.c: Add a comment. No code changes.
* strace.c (collect_stopped_tcbs): Stop reversing list of stopped
tcp's. I'm not totally convinced it is crucial, but this is surely
fits the concept of "least surprise".
Do not collect TCB_SUSPENDED tcp's (this is closer to how
it was before).
(handle_stopped_tcbs): Remove the code to reject TCB_SUSPENDED tcp's,
it's done earlier now. In an unobvious way, this was causing
SIGSTOPs from freshly attached children to be misinterpreted.
/external/strace/strace.c
f535b54bc40373c81b13df0975aef4212dacbbde 13-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> Fixes for ptrace() argument parsing.
* process.c: Add parsing of PTRACE_SETOPTIONS, PTRACE_GETEVENTMSG,
PTRACE_GETSIGINFO, PTRACE_SETSIGINFO.
* strace.c (handle_stopped_tcbs): Make PTRACE_SETOPTIONS
define check more robust.
* defs.h: Declare several "extern const struct xlat" arrays here.
* desc.c: Remove open_mode_flags[] and open_access_modes[]
extern declarations.
* net.c: Remove open_mode_flags[] extern declaration.
* sock.c: Remove addrfams[] extern declaration.
* util.c: Remove struct_user_offsets[] extern declaration.
* signal.c: Remove open_mode_flags[] extern declaration.
/external/strace/strace.c
215cc2703763894faea05899642ea5dfd5fc5c95 09-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> * defs.h: Add new struct tcb fields: wait_status, next_need_service.
make flags field wider (ints are easier to work with on many CPUs).
* strace.c (trace): Split this function into two:
collect_stopped_tcbs() and handle_stopped_tcbs().
Now we collect *all* waitable tasks, then handle them all,
then repeat.
Fixes RH#478419 "Some threads stop when strace with -f option
is executed on a multi-thread process"
* test/many_looping_threads.c: example program which cna't be straced
successfully without this fix.
/external/strace/strace.c
ef2fbf856cf775981b52278c80ce2a74a44019f4 06-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> Output format fixes, improving the situation after recent
change which added better handling of processes suddenly
disappearing. Now we often do not finish last line
before exiting in those cases.
The only change affecting something other than output
is change in umovestr where we were calling
abort() on ptrace error.

* strace.c (trace): If trace_syscall() failed with ESRCH,
finish current output line with " <unfinished ...>".
(mp_ioctl): While we are at it, fix gross style mismatch
in this function definition. No code chages.
* syscall.c (trace_syscall): If decode fails on syscall exit,
finish current output line with "= ? <unavailable>".
* util.c (umoven): Do not complain if error is ESRCH.
(umovestr): Do not complain and do not abort() if error is ESRCH.
* defs.h: Remove unused tcp parameter from printtrailer().
* process.c: Adjust printtrailer() calls accordingly.
* strace.c: Adjust printtrailer() calls accordingly.
* syscall.c: Adjust printtrailer() calls accordingly.
/external/strace/strace.c
0861ecbb44c1a7756e776af4a6fd7731e2a82a68 02-Jan-2009 Denys Vlasenko <dvlasenk@redhat.com> * strace.c: Fix compile failure: on some systems PTRACE_O_xxx
and PTRACE_EVENT_xxx constants are not defined.
/external/strace/strace.c
ecfe2f19f963b5c2f176c5e70d42654d7429ce3e 30-Dec-2008 Denys Vlasenko <dvlasenk@redhat.com> Experimental support for -D option.
Unlike normal case, with -D *grandparent* process exec's,
becoming a traced process. Child exits (this prevents traced process
from having children it doesn't expect to have), and grandchild
attaches to grandparent similarly to strace -p PID.
This allows for more transparent interaction in cases
when process and its parent are communicating via signals,
wait() etc. Without -D, strace process gets lodged in between,
disrupting parent<->child link.

* strace.c: Add global flag variable daemonized_tracer for -D option.
(startup_attach): If -D, fork and block parent in pause().
In this case we are already a child, we in fact created a grandchild.
After attaching to grandparent, grandchild SIGKILLs parent.
(startup_child): If -D, parent blocks in wait(), then
execs the program to strace. Normally (w/o -D), it is child
who execs the program.
(main): Detect -D option, call startup_attach() if it is given.
/external/strace/strace.c
96d5a76109b4f1d1f4c9c76641e6ec896108083d 29-Dec-2008 Denys Vlasenko <dvlasenk@redhat.com> * defs.h: Remove sigtrap80 field from struct tcb.
* strace.c: Add ptrace_stop_sig static variable
and use it in place of tcp->sigtrap80.
Add ptrace_opts_set static flag variable.
(trace): Set ptrace options once, not per-process.
If unexpected SIGTRAP is later received,
revert back to using SIGTRAP
(assume old, broken kernel).
/external/strace/strace.c
b1efe53531c2f0f3fd2a4fc8a56220737539c44e 23-Dec-2008 Denys Vlasenko <dvlasenk@redhat.com> Fix build breakage from my previous commit.
Now I test for PT_SETOPTIONS being #defined.
Remove trailing whitespace.
No actual code changes.
/external/strace/strace.c
1e3ce32a4fadb58230bca4f16baf8152579dd3d0 22-Dec-2008 Denys Vlasenko <dvlasenk@redhat.com> Make strace correctly handle SIGTRAP produced by e.g.
kill(2) and by trapping instruction.
* defs.h: Add sigtrap80 field to struct tcb.
* strace.c (alloc_tcb): Initialize it to SIGTRAP.
(detach): Use tcp->sigtrap80 instead of SIGTRAP constant.
(trace): Attempt to set PTRACE_O_TRACESYSGOOD and
PTRACE_O_TRACEEXEC options on each newly attached process,
distinquish between SIGTRAP and (SIGTRAP | 0x80) stops.
Fixes RH#162774 "strace ignores int3 SIGTRAP".
/external/strace/strace.c
732d1bf4d4aaff68eff1c41d8900264637a57dfe 17-Dec-2008 Denys Vlasenko <dvlasenk@redhat.com> Make strace somewhat resilient against process disappearing
under its claws. Prime example is sudden SIGKILL.
Fixes RH#472053
/external/strace/strace.c
932fc7d4fc1a29e8b8bcea5685db3f6c2e212e36 16-Dec-2008 Denys Vlasenko <dvlasenk@redhat.com> This patch does not change any logic.

It merely passes tcp pointer to upeek instead of pid.
This is needed if one wants to check or change
some tcp fields.

I have patches which require this. I can imagine someone else
eventually needing to look at tcp for completely orthogonal reasons.
/external/strace/strace.c
a68096576afc07e51d33b49c432d658b27a7f13c 10-Nov-2008 Dmitry V. Levin <ldv@altlinux.org> 2008-09-29 Dmitry V. Levin <ldv@altlinux.org>

* strace.c (startup_child): Save child pid for future use.
(main): Exit/kill ourself with straced child's exitcode/signal.
(trace): If signalled process pid matches the saved child pid,
save the signal number. If terminated process pid matches the
saved child pid, save its exit status.
Patch from Denys Vlasenko <dvlasenk@redhat.com>
/external/strace/strace.c
1f942710a57860eeabfa03e62b8ac151022d1be3 06-Aug-2008 Jan Kratochvil <jan.kratochvil@redhat.com> 2008-08-06 Jan Kratochvil <jan.kratochvil@redhat.com>

Fix compiler warnings.
* signal.c (sys_signal): Cast to SIG_* to the matching type LONG.
* strace.c (trace): Variables PSR and PC are now signed.
* syscall.c (syscall_enter): Variable RBS_END is now signed long.
Remove/add the RBS_END casts appropriately.
* util.c [IA64] (arg_setup): Variable BSP is now signed long.
Remove/add the BSP casts appropriately.
<ia32>: Initialize *STATE.
/external/strace/strace.c
06350dba7505eda4b8220cca8a9b112504fafc4d 25-Jul-2008 Dmitry V. Levin <ldv@altlinux.org> 2008-07-24 Dmitry V. Levin <ldv@altlinux.org>

* strace.c (main): Fix -F option backwards compatibility.
/external/strace/strace.c
41c48227a86a176da333f713d5047240885f25cc 18-Jul-2008 Roland McGrath <roland@redhat.com> 2008-07-03 Jan Kratochvil <jan.kratochvil@redhat.com>

Trace even VFORK on -f on all the platforms.
* strace.1 <-f>: Describe Linux catches new children immediately.
<-F>: Make the option obsolete. Move the SunOS VFORK comment to the
`-f' option description.
* defs.h (followvfork): Declaration removed.
* strace.c (followvfork): Variable removed.
(main) <-F>: Merge with the `-f' option.
(trace): Make !FOLLOWVFORK unconditional.
* process.c (internal_fork): Make !FOLLOWVFORK unconditional.
/external/strace/strace.c
276ceb33f20fc41403e46684e441230296f6a433 13-Nov-2007 Roland McGrath <roland@redhat.com> 2007-11-06 Jan Kratochvil <jan.kratochvil@redhat.com>

* strace.c [LINUX] (droptcb): Recurse on TCP->parent if it is a
TCB_EXITING zombie group leader.
* test/childthread.c: New file.
* test/.cvsignore, test/Makefile: Add it.
Code advisory: Roland McGrath
Fixes RH#354261.
/external/strace/strace.c
54cc1c8ae2d097502439a95d43e1f0ed6782d38c 04-Nov-2007 Roland McGrath <roland@redhat.com> 2007-11-03 Jan Kratochvil <jan.kratochvil@redhat.com>

* strace.c (main): Move the STARTUP_CHILD call before setting up the
signal handlers. New comment about the valid internal states.
/external/strace/strace.c
08b623eb84266d4a2defc619fa78400c4e4f0dc1 08-Oct-2007 Dmitry V. Levin <ldv@altlinux.org> 2007-09-25 Dmitry V. Levin <ldv@altlinux.org>

* strace (main): Use calloc for tcbtab allocation.
Check calloc return value.
Reported by Bai Weidong.
/external/strace/strace.c
1bfd31032538222fa7d6b5d1741f1a4efa0eb739 03-Aug-2007 Roland McGrath <roland@redhat.com> 2007-08-02 Jan Kratochvil <jan.kratochvil@redhat.com>

* strace.c (detach): Moved the resume notification code to ...
(resume_from_tcp): ... a new function here.
(handle_group_exit): No longer detach also the thread group leader.
(trace): Fixed panic on exit of the TCB_GROUP_EXITING leader itself.
/external/strace/strace.c
d6a32f176c7a07c72c69000c39a5a964e4168874 11-Jul-2007 Roland McGrath <roland@redhat.com> 2007-07-11 Roland McGrath <roland@redhat.com>

* strace.c (handle_group_exit): Detach TCP before LEADER.
Don't use PTRACE_KILL on LEADER.
/external/strace/strace.c
4bfa6266eb6c67fce50907b427dff6bbd9e93794 05-Jul-2007 Roland McGrath <roland@redhat.com> 2007-07-05 Roland McGrath <roland@redhat.com>

* strace.c (strace_fopen): [_LFS64_LARGEFILE]: Use fopen64.
Fixes Debian#385310.
/external/strace/strace.c
09553f85cd97c4ad35cdf316c8e65621b9e86712 05-Jul-2007 Roland McGrath <roland@redhat.com> 2007-07-05 Roland McGrath <roland@redhat.com>

* strace.c (main): Fix error message for unfound -u user.
From Srinivasa Ds <srinivasa@in.ibm.com>.
/external/strace/strace.c
0a463880341945df08b6dc79134dc78cc38dc283 05-Jul-2007 Roland McGrath <roland@redhat.com> 2007-07-05 Jan Kratochvil <jan.kratochvil@redhat.com>

* strace.c (detach): New prototype. Extended the function comment.
[LINUX] (detach): Call droptcb() instead of the wrongly parametrized
detach() call.
(handle_group_exit): Call droptcb() instead of the wrongly parametrized
detach() call. Always call detach() only once from the group leader.
Comment the leader killing known bug tested by `test/leaderkill.c'.
Code advisory: Roland McGrath
Fixes RH#240961.
/external/strace/strace.c
02203311e96a90608c30e6604dc1f7bda0a777f0 12-Jun-2007 Roland McGrath <roland@redhat.com> 2007-06-11 Jan Kratochvil <jan.kratochvil@redhat.com>

Never interrupt when the attached traced process would be left stopped.
* strace.c (main): `-p' attaching moved to ...
(startup_attach): ... a new function, renamed a variable C to TCBI.
Block interrupting signals since the first tracee has been attached.
New comment about INTERRUPTED in the nonthreaded case.
[LINUX] (startup_attach): Check INTERRUPTED after each attached thread.
(main): Command spawning moved to ...
(startup_child): ... a new function, replaced RETURN with EXIT.
[LINUX] (detach): New variable CATCH_SIGSTOP, do not signal
new SIGSTOP for processes still in TCB_STARTUP.
(main): Move signals and BLOCKED_SET init before the tracees attaching,
[SUNOS4] (trace): Removed fixvfork () call as a dead code, SIGSTOP must
have been already caught before clearing TCB_STARTUP.
(trace): Removed the `!WIFSTOPPED(status)' dead code.
Clear TCB_STARTUP only in the case the received signal was SIGSTOP.
New comment when `TCB_BPTSET && TCB_STARTUP' combination can be set.
Code advisory: Roland McGrath
Fixes RH#240986.
/external/strace/strace.c
134813ae1ecf7f214440a5a09d5eff15a71bf8e6 02-Jun-2007 Roland McGrath <roland@redhat.com> 2007-05-24 Jan Kratochvil <jan.kratochvil@redhat.com>

* strace.c [LINUX] (my_tgkill): New macro.
[LINUX] (detach): Use my_tgkill () instead of kill(2).
Fixes RH#240962.
/external/strace/strace.c
10de62bb052b541af3d0566f05f3f870cce0e028 13-Dec-2006 Dmitry V. Levin <ldv@altlinux.org> 2006-12-12 Dmitry V. Levin <ldv@altlinux.org>

Fix -ff -o behaviour. Fix piping trace output.
* defs.h (newoutf): Remove.
(alloctcb): Rename to alloc_tcb. Add alloctcb() macro wrapper
around alloc_tcb().
* process.c [!USE_PROCFS] (internal_clone, internal_fork):
Remove newoutf() call.
* strace.c (set_cloexec_flag, strace_fopen, strace_popen,
swap_uid): New functions.
(popen_pid): New variable.
(newoutf): Make static, use strace_fopen().
(main): Use strace_fopen() and strace_popen(), remove uids
swapping. Do not open outfname when followfork > 1.
Reinitialize tcp->outf properly.
(alloctcb): Rename to alloc_tcb. Use newoutf().
(trace): Check popen_pid. Remove newoutf() call.
[USE_PROCFS] (proc_open, proc_poll_open): Use set_cloexec_flag().
Fixes RH#204950, RH#218435.
/external/strace/strace.c
b9fe011cdfb0a3014e68a6e82007b6c2703a340b 13-Dec-2006 Dmitry V. Levin <ldv@altlinux.org> 2006-12-10 Dmitry V. Levin <ldv@altlinux.org>

Make several global variables static.
#ifdef definitions of rarely unused functions.
* defs.h (rflag, tflag, outfname): Remove.
* strace.c (iflag, interactive, pflag_seen, rflag, tflag,
outfname, username): Make static.
* desc.c (sys_getdtablesize): Define only for
ALPHA || FREEBSD || SUNOS4.
* file.c (sys_fchroot): Define only for SUNOS4 || SVR4.
(sys_mkfifo): Define only for FREEBSD.
* mem.c (sys_sbrk): Define only for FREEBSD || SUNOS4.
(sys_getpagesize): Define only for
ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4.
* net.c (sys_so_socket): Define only for SVR4.
* process.c (sys_gethostid): Define only for
FREEBSD || SUNOS4 || SVR4.
(sys_gethostname): Define only for
ALPHA || FREEBSD || SUNOS4 || SVR4.
(sys_setpgrp): Define only for ALPHA || SUNOS4 || SVR4.
(sys_execv): Define only for SPARC || SPARC64 || SUNOS4.
* signal.c (sys_sigblock): Define only for FREEBSD || SUNOS4.
(sys_sighold, sys_sigwait): Define only for SVR4.
(sys_killpg): Define only for FREEBSD || SUNOS4.
* stream.c (sys_getmsg): Define only for
SPARC || SPARC64 || SUNOS4 || SVR4.
* syscall.c (sys_indir): Define only for SUNOS4.
/external/strace/strace.c
cbd470fc9d92ff2553567a4334fb307afcaec09a 14-Oct-2006 Dmitry V. Levin <ldv@altlinux.org> 2006-10-14 Dmitry V. Levin <ldv@altlinux.org>

* strace.c (main): Check getcwd() return code.
/external/strace/strace.c
9633942c07427ed51caea0e73f139e964d1a19cc 12-Oct-2006 Dmitry V. Levin <ldv@altlinux.org> 2006-10-06 Dmitry V. Levin <ldv@altlinux.org>

* strace.c [!USE_PROCFS] (trace): Presence of PT_GETSIGINFO
macro does not mean that PT_CR_IPSR and PT_CR_IIP macros are
also defined, so check them along with PT_GETSIGINFO.
Fixes RH#209856.
/external/strace/strace.c
76860f60d73bbdcc98725b6f8d7997ad0746cac2 12-Oct-2006 Dmitry V. Levin <ldv@altlinux.org> 2006-03-29 Dmitry V. Levin <ldv@altlinux.org>

Fix race conditions in tcb allocation.
* process.c (fork_tcb): Return error code as documented. Do not
print "tcb table full" error message.
[USE_PROCFS] (internal_fork): Do not print "tcb table full"
error message.
[SYS_clone || SYS_clone2] (internal_clone, internal_fork): Call
fork_tcb() before alloctcb(). Do not print "tcb table full"
error message.
* strace.c (main): Do not print "tcb table full" error message.
(expand_tcbtab): Print error message in case of memory allocation
failure.
(alloctcb): Print error message when tcb table is full.
(trace): Expand tcb table if necessary prior to allocating
entry there. Do not print "tcb table full" error message.
Fixes RH#180293.
/external/strace/strace.c
cb9def6975f28933ada9d35f05c6fba9ab3fe1fd 25-Apr-2006 Roland McGrath <roland@redhat.com> 2006-04-25 Roland McGrath <roland@redhat.com>

* strace.c (main): Fail when -c is given with -ff.
* strace.1: Note their incompatibility.
Fixes RH#187847.
/external/strace/strace.c
d0c4c0cb881facd0ccf16b0c266875a8bf3e56aa 25-Apr-2006 Roland McGrath <roland@redhat.com> 2006-04-25 Roland McGrath <roland@redhat.com>

* strace.c (main): Fail when nonoption args follow -p switches.
Fixes Debian#361302.
/external/strace/strace.c
138c6a334fd9949d6147c63ada02cf55472e02c0 12-Jan-2006 Roland McGrath <roland@redhat.com> 2005-11-17 Dmitry V. Levin <ldv@altlinux.org>

Implement qual_flags support for each personality.
* strace.c (main): Move qualify calls after set_personality call.
* syscall.c (qual_flags0): New variable..
[SUPPORTED_PERSONALITIES >= 2] (qual_flags1): New variable.
[SUPPORTED_PERSONALITIES >= 3] (qual_flags2): New variable.
(qual_flags): Change variable definition from array to pointer.
(set_personality): Initialize qual_flags variable.
(qualify_one): Add "pers" argument to specify personality.
[SUPPORTED_PERSONALITIES >= 2]: Set qual_flags1 if requested.
[SUPPORTED_PERSONALITIES >= 3]: Set qual_flags2 if requested.
(qual_syscall): Pass personality to qualify_one.
[SUPPORTED_PERSONALITIES >= 2]: Look for syscall also in sysent1
table.
[SUPPORTED_PERSONALITIES >= 3]: Look for syscall also in sysent2
table.
(qual_signal): Pass personality to qualify_one.
(qual_desc): Likewise.
(qualify): Use qualify_one instead of manual qual_flags
manipulations.
[SUPPORTED_PERSONALITIES >= 2]: Look for syscall also in sysent1
table.
[SUPPORTED_PERSONALITIES >= 3]: Look for syscall also in sysent2
table.
* defs.h: Update qual_flags declaration.
Fixes RH#173986.
/external/strace/strace.c
a08a97eff32ba016ec5d71d2e6948dd43b98cf34 03-Aug-2005 Roland McGrath <roland@redhat.com> 2005-08-03 Roland McGrath <roland@redhat.com>

* strace.c (detach): If detaching the last live thread in a group with
a zombie leader, then detach the leader too.
(handle_group_exit): Use detach, not droptcb, for predeceased thread.
Mark process about to take a signal with TCB_GROUP_EXITING flag.
Fixes RH#161919.
/external/strace/strace.c
76989d7a16cb9683d0a75a6261f18ced66d0c04a 08-Jun-2005 Roland McGrath <roland@redhat.com> 2005-06-06 Roland McGrath <roland@redhat.com>

* defs.h (struct sysent): New member `native_scno'.
(known_scno): Declare new function.
* linux/syscallent.h: Add new final field to interesting syscalls.
* syscall.c (known_scno): New function.
(dumpio, internal_syscall, syscall_fixup, trace_syscall): Use it.
* process.c (internal_fork, internal_exit): Likewise.
[IA64] (ARG_STACKSIZE, ARG_PTID, ARG_CTID, ARG_TLS): Likewise.
* strace.c (proc_open): Likewise.
* util.c [LINUX] (setbpt): Likewise.
* linux/syscall.h: Remove [!defined(X86_64)] from conditional
for defining SYS_socket_subcall et al.
* linux/syscallent.h: Likewise for #error check.
* syscall.c (trace_syscall): Likewise for SYS_{socketcall,ipc} cases.
Fixes RH#158934.
/external/strace/strace.c
46100d07257824da2ae1147da0324b5788c95501 01-Jun-2005 Roland McGrath <roland@redhat.com> 2005-05-31 Dmitry V. Levin <ldv@altlinux.org>

* bjm.c (sys_query_module) [LINUX]: Unitize "out of memory"
errors reporting style.
* strace.c (rebuild_pollv) [USE_PROCFS]: Likewise.
* system.c (sys_capget, sys_capset) [SYS_capget]: Likewise.
* util.c (printstr): Likewise.
(dumpiov) [HAVE_SYS_UIO_H]: Likewise.
(fixvfork) [SUNOS4]: Likewise.
* desc.c (decode_select): Continue to decode syscall arguments
in case of OOM condition.
* file.c (sys_getdents): Likewise.
(sys_getdents64) [_LFS64_LARGEFILE]: Likewise.
(sys_getdirentries) [FREEBSD]: Likewise.
* mem.c (sys_mincore): Changed type of variables which deal with
malloc size from int to unsigned long.
Fixes RH#159308.
/external/strace/strace.c
dccec72a72e7b6451d9739e5d4611f4abf39f48d 09-May-2005 Roland McGrath <roland@redhat.com> 2005-05-09 Roland McGrath <roland@redhat.com>

* strace.c (main): Refuse negative -s argument value.
Fixes Debian bug #303256.
/external/strace/strace.c
3a055d7d64222223da2550ca540043de7e3e232b 06-Mar-2005 Roland McGrath <roland@redhat.com> 2005-03-06 Roland McGrath <roland@redhat.com>

* strace.c (trace) [PTRACE_GETSIGINFO]: Fetch siginfo_t for SIGSEGV
and SIGBUS signals, use si_addr in output.
/external/strace/strace.c
15dca8e307086cb2a53045046fe4791dc7afe378 06-Feb-2005 Roland McGrath <roland@redhat.com> 2004-12-19 Dmitry V. Levin <ldv@altlinux.org>

* strace.c (main) [!USE_PROCFS]: In child process, raise SIGSTOP
right before execv() call. Remove fake_execve() call.
* defs.h (fake_execve): Remove unused declaration.
* process.c (fake_execve): Remove unused function.
Fixes RH#143365.
/external/strace/strace.c
795edb11488dd47c4598e2228e3b5431de7ed46d 02-Feb-2005 Roland McGrath <roland@redhat.com> 2004-12-20 Dmitry V. Levin <ldv@altlinux.org>

* configure.ac: Use AC_GNU_SOURCE macro instead of changing CFLAGS.
* defs.h [HAVE_CONFIG_H]: Include config.h first.
* strace.c: Include "defs.h" first.
Fixes RH#143370.
/external/strace/strace.c
00dc13fbe7a4d1bba614c8b75877db110cabb044 20-Oct-2004 Roland McGrath <roland@redhat.com> 2004-10-19 Roland McGrath <roland@redhat.com>

* strace.c (handle_group_exit): Don't detach leader that wasn't
TCB_ATTACHED. Instead mark it with TCB_GROUP_EXITING.
Remove droptcb loop at end, no longer required since 2.6 reports each
thread death.
Fixes RH#135254.
/external/strace/strace.c
0569095472c93c8513edefcf31013503ce4c0589 20-Oct-2004 Roland McGrath <roland@redhat.com> 2004-10-19 Roland McGrath <roland@redhat.com>

* strace.c (trace): Use handle_group_exit for non-TCB_ATTACHED child
taking signal when it has nclone_threads > 0.
* strace.c (handle_group_exit): Don't detach leader that wasn't
TCB_ATTACHED.
* strace.c (handle_group_exit, trace): Mark leader with
TCB_GROUP_EXITING and don't be surprised at child deaths when their
leader has it set.
Fixes RH#132150.
/external/strace/strace.c
08f0ae30fd500a577cd735073fd6b4e09ebb8aac 31-Aug-2004 Roland McGrath <roland@redhat.com> 2004-08-30 Roland McGrath <roland@redhat.com>

* strace.c (main): Don't call fake_execve under -c.
From Ulrich Drepper <drepper@redhat.com>.
Fixes RH#129166.
/external/strace/strace.c
7b54a7ae61d0eda798575f77d898a24dda7a0952 04-Jun-2004 Roland McGrath <roland@redhat.com> 2004-06-03 Roland McGrath <roland@redhat.com>

* strace.c (main) [LINUX]: Expand TCBTAB as necessary for threads
attached. Attach threads only under -f. Set TCB_FOLLOWFORK in them.
(expand_tcbtab): New function, broken out of ...
* process.c (fork_tcb): ... here, call that.
* defs.h: Declare expand_tcbtab.
/external/strace/strace.c
70b08530b80a6ee6591c38cf397fe0eeba1b4d7a 09-Apr-2004 Roland McGrath <roland@redhat.com> 2004-04-08 Roland McGrath <roland@redhat.com>

* strace.c (main) [LINUX]: When attaching for -p, look in
/proc/PID/task for all threads and attach them as presumed
CLONE_THREAD children.
/external/strace/strace.c
bdb09df1866b8c50317011938bb963aa9d694cd6 02-Mar-2004 Roland McGrath <roland@redhat.com> 2004-03-01 Roland McGrath <roland@redhat.com>

* strace.c (main): Avoid potential buffer overruns from ludicrous
arguments or PATH values.
/external/strace/strace.c
c3266d51f0b4c0af082000a02649e37f992dbc8b 20-Feb-2004 Roland McGrath <roland@redhat.com> 2004-02-19 Roland McGrath <roland@redhat.com>

* strace.c (main): Use TCP->pid, not PID, in -p message.
Fixes Debian bug #229802.
/external/strace/strace.c
2efe879fa8df30bf69c3a4c471dcc5e19ad0b6ea 13-Jan-2004 Roland McGrath <roland@redhat.com> 2003-12-15 Dmitry V. Levin <ldv@altlinux.org>

* strace.c (trace) [WCOREDUMP]: Show coredump status of the
killed process if available.
/external/strace/strace.c
ce0d15442eec017b1dcbfdd14ac92e73c39c586a 11-Nov-2003 Roland McGrath <roland@redhat.com> 2003-11-11 Roland McGrath <roland@redhat.com>

* strace.c (main): Bail with usage error for missing command before we
open the -o file or fiddle uids.
/external/strace/strace.c
37b9a66dd4cf063c4a3d1002f4196cd7ef9ae5b7 07-Nov-2003 Roland McGrath <roland@redhat.com> 2003-11-06 Roland McGrath <roland@redhat.com>

* strace.c (main): Treat piped output more like file output.
Disallow -ff with piped output. Fixes RH#105366.
Reported by Dmitry V. Levin <ldv@altlinux.org>
/external/strace/strace.c
b310a0c26b3b31d52aa4b25549e06113284bd5bb 07-Nov-2003 Roland McGrath <roland@redhat.com> 2003-11-06 Roland McGrath <roland@redhat.com>

* strace.c (tprintf): Check result of vfprintf and use perror when it
fails while not writing to stderr itself. Fixes Debian bug #218762.
/external/strace/strace.c
0a396906981a03f93c07cb912585d0679dd50899 10-Jun-2003 Roland McGrath <roland@redhat.com> 2003-06-09 Roland McGrath <roland@redhat.com>

* strace.c (trace): Print a message and newline for a WIFEXITED report
from the process we just printed an unterminated syscall line for.
/external/strace/strace.c
ed64516fa4f4ce25308a1f2ad3b84f8734c3e783 03-Jun-2003 Roland McGrath <roland@redhat.com> 2003-06-03 Roland McGrath <roland@redhat.com>

* strace.c (main): In PATH search, accept only a regular file with
execute bits set. Fixes Debian bug #137103.
/external/strace/strace.c
369310502bfca4b202d72be9452c8cdb55bb6d5e 03-Jun-2003 Roland McGrath <roland@redhat.com> 2003-06-02 Roland McGrath <roland@redhat.com>

* strace.c (main): Set -q when given -o and not -p, and not when not
given -o, to match what the man page always said.
Fixes Debian bug #47113, #153678.
/external/strace/strace.c
0962345a5775e0eea75c3ec408fb4807e851e7f0 23-May-2003 Roland McGrath <roland@redhat.com> 2003-05-22 Roland McGrath <roland@redhat.com>

* defs.h (struct tcb): New member `nzombies'.
* strace.c (alloctcb): Initialize it.
(droptcb): Increment our parent's zombie count.
* process.c (internal_wait): Don't go into TCB_SUSPENDED if the
process has zombies it can reap. On the way out, if we reaped
an untraced process, decrement the zombie count.
/external/strace/strace.c
9c9a2534e361b683f1e4e08804b7166a01475bf1 20-Feb-2003 Roland McGrath <roland@redhat.com> 2003-02-19 Roland McGrath <roland@redhat.com>

* version.c: Removed.
* Makefile.am (strace_SOURCES): Remove it.
* strace.c: Use PACKAGE_NAME and VERSION macros instead of version var.
/external/strace/strace.c
de6e53308ca58da7d357f8114afc74fff7a18043 24-Jan-2003 Roland McGrath <roland@redhat.com> 2003-01-21 Roland McGrath <roland@redhat.com>

* strace.c (usage): Omit -z, since it has never worked properly.
* NEWS: Likewise.
* strace.c (main): Grok new option `-E var=val' or `-E var' to put
var=val in environ or to remove var, respectively.
(usage): Mention it.
* strace.1, NEWS: Document it.
/external/strace/strace.c
8f474e087ebb77b57eb87f4fdc557d53c64ca933 14-Jan-2003 Roland McGrath <roland@redhat.com> 2003-01-13 Roland McGrath <roland@redhat.com>

* strace.c [! HAVE_STRSIGNAL]: Clean up #ifdefs on decls for
sys_siglist and _sys_siglist.
Reported by John Hughes <john@Calva.COM>.
/external/strace/strace.c
e29341c02f4fb658a34bca1f36c5d587257970d6 10-Jan-2003 Roland McGrath <roland@redhat.com> 2003-01-10 Roland McGrath <roland@redhat.com>

* strace.c (droptcb): Clear flags word before calling rebuild_pollv.
/external/strace/strace.c
c012d223a6b915f06ef32b8aaa52b984015d192e 10-Jan-2003 Roland McGrath <roland@redhat.com> 2003-01-10 Roland McGrath <roland@redhat.com>

* strace.c (rebuild_pollv): Fix typo: struct poll -> struct pollfd.
/external/strace/strace.c
ca16be8be9521b61bd2c5d945aa115519ebcb4da 10-Jan-2003 Roland McGrath <roland@redhat.com> 2003-01-10 Roland McGrath <roland@redhat.com>

* strace.c (pfd2tcb): Fix for new tcbtab type.
(rebuild_pollv): Likewise.
(detach): Put variables used under [LINUX] inside #ifdef.
/external/strace/strace.c
e85bbfe9ab55854cc3a6227d2f9001587fe64996 09-Jan-2003 Roland McGrath <roland@redhat.com> 2003-01-08 Roland McGrath <roland@redhat.com>

Support for new Linux 2.5 thread features.
* defs.h [LINUX]: Define __NR_exit_group if not defined.
(struct tcb): New members nclone_threads, nclone_detached,
and nclone_waiting.
(TCB_CLONE_DETACHED, TCB_CLONE_THREAD, TCB_GROUP_EXITING): New macros.
(waiting_parent): Macro removed.
(pid2tcb): Declare it.
* process.c (internal_clone) [TCB_CLONE_THREAD]: Reparent the new
child to our parent if we are a CLONE_THREAD child ourselves.
Maintain TCB_CLONE_THREAD and TCB_CLONE_DETACHED flags and counts.
(internal_wait) [TCB_CLONE_THREAD]: Factor out detached children when
determining if we have any. If TCB_CLONE_THREAD is set, check
parent's children instead of our own, and bump nclone_waiting count.
(internal_exit) [__NR_exit_group]: Set the TCB_GROUP_EXITING flag if
the syscall was exit_group.
* syscall.c (internal_syscall): Use internal_exit for exit_group.
* strace.c (pid2tcb): No longer static.
(alloctcb) [TCB_CLONE_THREAD]: Initialize new fields.
(droptcb) [TCB_CLONE_THREAD]: Maintain new fields.
If we have thread children, set TCB_EXITING and don't clear the TCB.
(resume) [TCB_CLONE_THREAD]: Decrement parent's nclone_waiting.
(detach) [TCB_CLONE_THREAD]: When calling resume, check all thread
children of our parent that might be waiting for us too.
[TCB_GROUP_EXITING] (handle_group_exit): New function.
(trace) [TCB_GROUP_EXITING]: Use that in place of detach or droptcb.
Revamp -f support for Linux.
* util.c [LINUX] (setbpt, clearbpt): New implementations that tweak
the system call to be clone with CLONE_PTRACE set. Various new static
helper functions.
* process.c (internal_clone): Define also #ifdef SYS_clone2.
Initialize TCPCHILD->parent field.
[CLONE_PTRACE]: Don't do PTRACE_ATTACH here, because it's preattached.
Check in case the new child is in the tcb already.
(internal_fork) [LINUX]: Just call internal_clone.
* strace.c (trace) [LINUX]: Under -f/-F, grok an unknown pid
reporting to wait, put it in the TCB with TCB_ATTACHED|TCB_SUSPENDED.
/external/strace/strace.c
fd3e0423000adbb2648b7d389a3d9d953b901ab3 30-Dec-2002 Roland McGrath <roland@redhat.com> 2002-12-30 Roland McGrath <roland@redhat.com>

* version.c (version): Make const, bump to 4.4.90.
* strace.c: Update decl.
/external/strace/strace.c
6d2b34971b33d379c89c36c5ad1b0c6d5d12c453 30-Dec-2002 Roland McGrath <roland@redhat.com> 2002-12-22 Roland McGrath <roland@redhat.com>

Update to Autoconf 2.57, and Automakify with version 1.7.
* Makefile.am: New file.
* Makefile.in: File removed.
* configure.in: Moved to ...
* configure.ac: ... here. Update for Autoconf 2.5x and Automake.
* aclocal.m4: Moved to ...
* acinclude.m4: ... here. Update for Autoconf 2.5x.
* AUTHORS: New file, makes automake happy.
* autogen.sh: File removed.
* README-CVS: Update to recommend autoreconf instead.
* file.c: HAVE_ST_* -> HAVE_STRUCT_STAT_ST_*.
* net.c: HAVE_SIN6_SCOPE_ID -> HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID,
HAVE_MSG_CONTROL -> HAVE_STRUCT_MSGHDR_MSG_CONTROL.
* strace.c: *_DECLARED -> HAVE_DECL_*
* stream.c: HAVE_* -> HAVE_STRUCT_*
/external/strace/strace.c
ee9d435275fd7abf736992f84b5053ee16ec4fc7 18-Dec-2002 Roland McGrath <roland@redhat.com> 2002-12-17 Roland McGrath <roland@redhat.com>

* strace.c (tcbtab): Make this a pointer to pointers, not an array.
(tcbtabsize): New variable.
(main): Initialize them using dynamic allocation.
(alloctcb, main): Use tcbtabsize in place of MAX_PROCS; indirect.
(pid2tcb, cleanup): Likewise.
[USE_PROCFS] (pollv): Make this a pointer, not an array; make static.
(rebuild_pollv): Dynamically allocate the vector.
* defs.h (tcbtab): Update decls.
(MAX_PROCS): Macro removed, no more static limit on this.
* process.c (fork_tcb): New function.
(internal_clone, internal_fork): Use it instead of checking nprocs.
/external/strace/strace.c
7508cb4678141d146d819120f6b5b428c103882e 17-Dec-2002 Roland McGrath <roland@redhat.com> 2002-12-17 Roland McGrath <roland@redhat.com>

* strace.c (detach) [LINUX]: Use __WALL (or a second try with __WCLONE)
in wait after sending SIGSTOP.
/external/strace/strace.c
5bc05558bb9f9acd1f895ea128f3326ef4b03338 17-Dec-2002 Roland McGrath <roland@redhat.com> 2002-12-16 Roland McGrath <roland@redhat.com>

* strace.c (trace) [LINUX]: Only check errno if wait4 actually fails,
so we don't repeat a wait and thus drop a status. Fixes RH#62591.
/external/strace/strace.c
7bf10474b981aa27f6b8c5b5e3f563d21f2eafca 16-Dec-2002 Roland McGrath <roland@redhat.com> Fix botched commit.
/external/strace/strace.c
553a609807074e95eed5a0bffba334b7fb3d3751 16-Dec-2002 Roland McGrath <roland@redhat.com> 2002-12-15 Roland McGrath <roland@redhat.com>

* strace.c (main) [! USE_PROCFS]: Always reset SIGCHLD to SIG_DFL.
/external/strace/strace.c
17f8fb3484e94976882f65b7a3aaffc6f24cd75d 06-Nov-2002 Michal Ludvig <mludvig@suse.cz> Added switch for printing only succeeding syscalls.
/external/strace/strace.c
b664308560d655bc1fb333663eb0d0fb3395409f 23-May-2002 John Hughes <john@Calva.COM> Fix warning if not using POLL_HACK
/external/strace/strace.c
d870b3c31a0139b335a66a829169bacc74624c44 21-May-2002 John Hughes <john@Calva.COM> fix warning will POLL_HACK
/external/strace/strace.c
822f0c9a84a4c992cc126766c83726e7275a5572 03-Apr-2002 Wichert Akkerman <wichert@deephackmode.org> Fix closing of outputfiles in droptcb()
/external/strace/strace.c
eb8ebdad122a20ecae0ce8e3e60cb71d8e4a7152 01-Apr-2002 Wichert Akkerman <wichert@deephackmode.org> close tcp->outf in droptcb()
/external/strace/strace.c
19e49984acc8f12dfaf0b7835ad17ca24f854c47 19-Oct-2001 John Hughes <john@Calva.COM> only trace syscalls/signals/faults of interest
/external/strace/strace.c
5826589d8e210c2d34c8ce496d5b7a0f54188ef0 18-Oct-2001 John Hughes <john@Calva.COM> Merge SVR4/Linux printsiginfo
/external/strace/strace.c
7b3346be42d6a1f539e95d385ee498f8b3c529f8 10-Oct-2001 Wichert Akkerman <wichert@deephackmode.org> Import lots of ia64 related changes from David Mosberger
/external/strace/strace.c
54b4f79216c819ec93aaf5031acb1772fccef7a9 03-Aug-2001 Wichert Akkerman <wichert@deephackmode.org> set CLOEXEC flag for outputfile
/external/strace/strace.c
1d08dcf46dd4b2cfe3e27723c05b0aec9955c591 10-Jul-2001 John Hughes <john@Calva.COM> Merge iov fixes from Richard Kettlewell
/external/strace/strace.c
2f1d87e74ff68004b99901f964a1cbab89da09db 28-Mar-2001 Wichert Akkerman <wichert@deephackmode.org> use __WALL for wait4 if we can
/external/strace/strace.c
2e4ffe59b588159eb80e236f068278ba47735932 04-Sep-2000 Wichert Akkerman <wichert@deephackmode.org> more FreeBSD updates
/external/strace/strace.c
bf79f2e16b090ffe59cd1e1820935680a2da7b78 01-Sep-2000 Wichert Akkerman <wichert@deephackmode.org> Add FreeBSD support
/external/strace/strace.c
16a03d2e97415afe6cf34172a0aea97a95a0b160 10-Aug-2000 Wichert Akkerman <wichert@deephackmode.org> test/clone.c: minor fixup
Another bunch of patches from John Hughes merged:
signal.c:
+ SVR4 printcontext(): sigset_t != sigset_t*
+ getcontext returns a value, so print on exit of syscall
+ add UC_FP to ucontext_flags for OS writers that can't spell
+ sys_signal(): special case SIG_{ERR,DFL,IGN}
+ decode_subcall(): only do subcall range checking when needed
bunch of UnixWare updates
aclocal.m4, acconfig.h, configure.in: add test for long long type
/external/strace/strace.c
7987cdf192632516d6ba493b0a9943f5a3a7c362 05-Jul-2000 Wichert Akkerman <wichert@deephackmode.org> net.c: add SOL_PACKET and SOL_RAW socket options, update SOL_IP and SOL_TCP
/external/strace/strace.c
bd4125c6bcd20e8f014b682b31d6fc5d0fef3ed0 27-Jun-2000 Wichert Akkerman <wichert@deephackmode.org> Close outf fd when forking
/external/strace/strace.c
5ae21ead9f83597452f9a0517e8a51fa4823f921 01-May-2000 Wichert Akkerman <wichert@deephackmode.org> The `too much stuff, just check the ChangeLog' update
/external/strace/strace.c
faf722234dc8af97776f94fdda7e100fb60650a2 20-Feb-2000 Wichert Akkerman <wichert@deephackmode.org> test/vfork.c: new file to test vfork traces
test/.cvsignore: new file
defs.h: Up maximum number of traced processed to 64
strace.c: Disable some debugging code from davidm
implement setarg for more architectures
implement change_syscall
/external/strace/strace.c
2ee6e45f36566e8735b35ffad40bfcc626a25a98 18-Feb-2000 Wichert Akkerman <wichert@deephackmode.org> Fixup isdigit calls
/external/strace/strace.c
8b1b40cd8b49151374d0ac2a5b1a4b459f9e0ae5 03-Feb-2000 Wichert Akkerman <wichert@deephackmode.org> Merge Trillian patches (Linux ia64)
/external/strace/strace.c
4dc8a2aec63e4fb5ee2688544c4de323ed5de3ef 23-Dec-1999 Wichert Akkerman <wichert@deephackmode.org> Bunch of stuff
/external/strace/strace.c
ea78f0f77185f7d6d0b2055805139d96e1be816c 29-Nov-1999 Wichert Akkerman <wichert@deephackmode.org> Add UnixWare support to configure
/external/strace/strace.c
9dbf15466e9c178ac4090eba2c1232e2fe0706f9 26-Nov-1999 Wichert Akkerman <wichert@deephackmode.org> Add pollhack
/external/strace/strace.c
54a4767f8609abfe2d7cb1802bc9e8dca97dd08f 17-Oct-1999 Wichert Akkerman <wichert@deephackmode.org> Add missing newline in error
/external/strace/strace.c
9ce1a63eb20b069607c06f9645ac5a17b418a5f3 30-Aug-1999 Wichert Akkerman <wichert@deephackmode.org> Catching up on my mail-backlog, see ChangeLog for details
/external/strace/strace.c
e68d61c7d6dcf986d32c462e533ea46f85183db8 28-Jun-1999 Wichert Akkerman <wichert@deephackmode.org> Remove stupid error in strace.c. Looks like I pasted something
I shouldn't have in there :(
/external/strace/strace.c
360815ecc28b2a44611b146c873fab76c88e12af 28-Jun-1999 Wichert Akkerman <wichert@deephackmode.org> Update documentation somewhat
/external/strace/strace.c
789ed35db520a552ba5ea0a5cbe5b31efa7adde5 14-Jun-1999 Wichert Akkerman <wichert@deephackmode.org> avoid leaking fd into child
/external/strace/strace.c
dacfb6ebd630641d851b6df94c3b4587969a6cfb 03-Jun-1999 Wichert Akkerman <wichert@deephackmode.org> Add sparc patches from Jakub Jelinek
/external/strace/strace.c
ce780fc9e6067b15b65ca2904c698c77503bf635 30-Mar-1999 Nate Sammons <nate@users.sourceforge.net> Add new function `signame', which returns name (SIGXXX) of numeric
signal, and replace lookups in signalent[] with calls to it.
/external/strace/strace.c
76baf7c9f6dd61a15524ad43c1b690c252cf5b7c 19-Feb-1999 Wichert Akkerman <wichert@deephackmode.org> Initial revision
/external/strace/strace.c