Commit Graph

318 Commits

Author SHA1 Message Date
Mike Frysinger
c1a5b7e8c4 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>
2009-10-08 14:25:01 +00:00
Roland McGrath
eb9e2e8904 Revert unapproved commits. 2009-06-02 16:49:22 -07:00
4ac9d627f4 * strace.c (handle_stopped_tcbs): Fix cast for 4th argument passed to ptrace(). 2009-06-01 18:45:41 +00:00
Denys Vlasenko
246f42ff5a * strace.c (collect_stopped_tcbs): Do not enable/disable signals
multiple times, do it just once per collecting pass.
2009-04-20 18:20:18 +00:00
Denys Vlasenko
1e20921216 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.
2009-03-20 13:28:00 +00:00
Denys Vlasenko
aab52cae4c Remove "better attach to SIGSTOP", it is not correct...
(^C fix remains).
2009-03-17 14:46:54 +00:00
Denys Vlasenko
222713aa40 * 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.
2009-03-17 14:29:59 +00:00
Denys Vlasenko
5ae2b7c601 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.
2009-02-27 20:32:52 +00:00
Denys Vlasenko
8ed5727642 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).
2009-02-25 14:24:02 +00:00
Denys Vlasenko
4dedd561d6 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.
2009-02-24 15:17:53 +00:00
Denys Vlasenko
84e20af5a6 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.
2009-02-10 16:03:20 +00:00
Denys Vlasenko
3bb7cd6660 * 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.
2009-02-09 18:55:59 +00:00
Denys Vlasenko
7a8bf06580 * 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.
2009-01-29 20:38:20 +00:00
Denys Vlasenko
7e0615f3ae * 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.
2009-01-28 19:00:54 +00:00
Denys Vlasenko
47ce6dfc9f * strace.c (collect_stopped_tcbs): Guard against the case when
waitpid() reports the same task multiple times.
Run tested.
2009-01-27 19:38:44 +00:00
Denys Vlasenko
2c8a258361 * 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.
2009-01-21 19:05:43 +00:00
Denys Vlasenko
418d66a847 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.
2009-01-17 01:52:54 +00:00
Denys Vlasenko
1d5b113f8c * 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".
2009-01-17 01:06:18 +00:00
Denys Vlasenko
f9a7e63a1a * 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.
2009-01-17 00:21:31 +00:00
Denys Vlasenko
f535b54bc4 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.
2009-01-13 18:30:55 +00:00
Denys Vlasenko
215cc27037 * 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.
2009-01-09 17:22:56 +00:00
Denys Vlasenko
ef2fbf856c 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.
2009-01-06 21:45:06 +00:00
Denys Vlasenko
0861ecbb44 * strace.c: Fix compile failure: on some systems PTRACE_O_xxx
and PTRACE_EVENT_xxx constants are not defined.
2009-01-02 16:55:24 +00:00
Denys Vlasenko
ecfe2f19f9 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.
2008-12-30 20:51:30 +00:00
Denys Vlasenko
96d5a76109 * 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).
2008-12-29 19:13:27 +00:00
Denys Vlasenko
b1efe53531 Fix build breakage from my previous commit.
Now I test for PT_SETOPTIONS being #defined.
Remove trailing whitespace.
No actual code changes.
2008-12-23 16:14:42 +00:00
Denys Vlasenko
1e3ce32a4f 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".
2008-12-22 19:14:47 +00:00
Denys Vlasenko
732d1bf4d4 Make strace somewhat resilient against process disappearing
under its claws. Prime example is sudden SIGKILL.
Fixes RH#472053
2008-12-17 19:21:59 +00:00
Denys Vlasenko
932fc7d4fc 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.
2008-12-16 18:18:40 +00:00
a68096576a 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>
2008-11-10 17:14:58 +00:00
Jan Kratochvil
1f942710a5 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.
2008-08-06 21:38:52 +00:00
06350dba75 2008-07-24 Dmitry V. Levin <ldv@altlinux.org>
* strace.c (main): Fix -F option backwards compatibility.
2008-07-25 15:42:34 +00:00
Roland McGrath
41c48227a8 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.
2008-07-18 00:25:10 +00:00
Roland McGrath
276ceb33f2 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.
2007-11-13 08:12:12 +00:00
Roland McGrath
54cc1c8ae2 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.
2007-11-03 23:34:11 +00:00
08b623eb84 2007-09-25 Dmitry V. Levin <ldv@altlinux.org>
* strace (main): Use calloc for tcbtab allocation.
	Check calloc return value.
	Reported by Bai Weidong.
2007-10-08 21:04:41 +00:00
Roland McGrath
1bfd310325 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.
2007-08-03 10:02:00 +00:00
Roland McGrath
d6a32f176c 2007-07-11 Roland McGrath <roland@redhat.com>
* strace.c (handle_group_exit): Detach TCP before LEADER.
	Don't use PTRACE_KILL on LEADER.
2007-07-11 08:35:11 +00:00
Roland McGrath
4bfa6266eb 2007-07-05 Roland McGrath <roland@redhat.com>
* strace.c (strace_fopen): [_LFS64_LARGEFILE]: Use fopen64.
	Fixes Debian#385310.
2007-07-05 20:03:16 +00:00
Roland McGrath
09553f85cd 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>.
2007-07-05 19:31:49 +00:00
Roland McGrath
0a46388034 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.
2007-07-05 18:43:16 +00:00
Roland McGrath
02203311e9 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.
2007-06-11 22:06:31 +00:00
Roland McGrath
134813ae1e 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.
2007-06-02 00:07:33 +00:00
10de62bb05 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.
2006-12-13 21:45:31 +00:00
b9fe011cdf 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.
2006-12-13 16:59:44 +00:00
cbd470fc9d 2006-10-14 Dmitry V. Levin <ldv@altlinux.org>
* strace.c (main): Check getcwd() return code.
2006-10-14 14:23:57 +00:00
9633942c07 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.
2006-10-11 23:11:43 +00:00
76860f60d7 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.
2006-10-11 22:55:25 +00:00
Roland McGrath
cb9def6975 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.
2006-04-25 07:48:03 +00:00
Roland McGrath
d0c4c0cb88 2006-04-25 Roland McGrath <roland@redhat.com>
* strace.c (main): Fail when nonoption args follow -p switches.
	Fixes Debian#361302.
2006-04-25 07:39:40 +00:00
Roland McGrath
138c6a334f 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.
2006-01-12 09:50:49 +00:00
Roland McGrath
a08a97eff3 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.
2005-08-03 11:23:46 +00:00
Roland McGrath
76989d7a16 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.
2005-06-07 23:21:31 +00:00
Roland McGrath
46100d0725 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.
2005-06-01 18:55:42 +00:00
Roland McGrath
dccec72a72 2005-05-09 Roland McGrath <roland@redhat.com>
* strace.c (main): Refuse negative -s argument value.
	Fixes Debian bug #303256.
2005-05-09 07:45:47 +00:00
Roland McGrath
3a055d7d64 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.
2005-03-06 22:24:29 +00:00
Roland McGrath
15dca8e307 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.
2005-02-06 01:16:32 +00:00
Roland McGrath
795edb1148 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.
2005-02-02 04:44:57 +00:00
Roland McGrath
00dc13fbe7 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.
2004-10-20 02:04:15 +00:00
Roland McGrath
0569095472 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.
2004-10-20 01:00:27 +00:00
Roland McGrath
08f0ae30fd 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.
2004-08-31 07:01:56 +00:00
Roland McGrath
7b54a7ae61 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.
2004-06-04 01:50:45 +00:00
Roland McGrath
70b08530b8 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.
2004-04-09 00:25:21 +00:00
Roland McGrath
bdb09df186 2004-03-01 Roland McGrath <roland@redhat.com>
* strace.c (main): Avoid potential buffer overruns from ludicrous
	arguments or PATH values.
2004-03-02 06:50:04 +00:00
Roland McGrath
c3266d51f0 2004-02-19 Roland McGrath <roland@redhat.com>
* strace.c (main): Use TCP->pid, not PID, in -p message.
	Fixes Debian bug #229802.
2004-02-20 02:23:52 +00:00
Roland McGrath
2efe879fa8 2003-12-15 Dmitry V. Levin <ldv@altlinux.org>
* strace.c (trace) [WCOREDUMP]: Show coredump status of the
	killed process if available.
2004-01-13 09:59:45 +00:00
Roland McGrath
ce0d15442e 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.
2003-11-11 21:24:23 +00:00
Roland McGrath
37b9a66dd4 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>
2003-11-07 02:26:54 +00:00
Roland McGrath
b310a0c26b 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.
2003-11-06 23:41:22 +00:00
Roland McGrath
0a39690698 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.
2003-06-10 03:05:53 +00:00
Roland McGrath
ed64516fa4 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.
2003-06-03 07:18:19 +00:00
Roland McGrath
369310502b 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.
2003-06-03 01:35:20 +00:00
Roland McGrath
0962345a57 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.
2003-05-23 02:27:13 +00:00
Roland McGrath
9c9a2534e3 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.
2003-02-20 02:56:29 +00:00
Roland McGrath
de6e53308c 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.
2003-01-24 04:31:23 +00:00
Roland McGrath
8f474e087e 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>.
2003-01-14 07:53:33 +00:00
Roland McGrath
e29341c02f 2003-01-10 Roland McGrath <roland@redhat.com>
* strace.c (droptcb): Clear flags word before calling rebuild_pollv.
2003-01-10 20:14:20 +00:00
Roland McGrath
c012d223a6 2003-01-10 Roland McGrath <roland@redhat.com>
* strace.c (rebuild_pollv): Fix typo: struct poll -> struct pollfd.
2003-01-10 20:05:56 +00:00
Roland McGrath
ca16be8be9 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.
2003-01-10 19:55:28 +00:00
Roland McGrath
e85bbfe9ab 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.
2003-01-09 06:53:31 +00:00
Roland McGrath
fd3e042300 2002-12-30 Roland McGrath <roland@redhat.com>
* version.c (version): Make const, bump to 4.4.90.
	* strace.c: Update decl.
2002-12-30 09:33:22 +00:00
Roland McGrath
6d2b34971b 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_*
2002-12-30 00:51:30 +00:00
Roland McGrath
ee9d435275 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.
2002-12-18 04:16:10 +00:00
Roland McGrath
7508cb4678 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.
2002-12-17 10:48:05 +00:00
Roland McGrath
5bc05558bb 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.
2002-12-17 04:50:47 +00:00
Roland McGrath
7bf10474b9 Fix botched commit. 2002-12-16 20:42:50 +00:00
Roland McGrath
553a609807 2002-12-15 Roland McGrath <roland@redhat.com>
* strace.c (main) [! USE_PROCFS]: Always reset SIGCHLD to SIG_DFL.
2002-12-16 20:40:39 +00:00
Michal Ludvig
17f8fb3484 Added switch for printing only succeeding syscalls. 2002-11-06 13:17:21 +00:00
John Hughes
b664308560 Fix warning if not using POLL_HACK 2002-05-23 11:02:22 +00:00
John Hughes
d870b3c31a fix warning will POLL_HACK 2002-05-21 11:24:18 +00:00
Wichert Akkerman
822f0c9a84 Fix closing of outputfiles in droptcb() 2002-04-03 10:55:14 +00:00
Wichert Akkerman
eb8ebdad12 close tcp->outf in droptcb() 2002-04-01 17:48:02 +00:00
John Hughes
19e49984ac only trace syscalls/signals/faults of interest 2001-10-19 08:59:12 +00:00
John Hughes
5826589d8e Merge SVR4/Linux printsiginfo 2001-10-18 15:13:53 +00:00
Wichert Akkerman
7b3346be42 Import lots of ia64 related changes from David Mosberger 2001-10-09 23:47:38 +00:00
Wichert Akkerman
54b4f79216 set CLOEXEC flag for outputfile 2001-08-03 11:43:35 +00:00
John Hughes
1d08dcf46d Merge iov fixes from Richard Kettlewell 2001-07-10 13:48:44 +00:00
Wichert Akkerman
2f1d87e74f use __WALL for wait4 if we can 2001-03-28 14:40:14 +00:00
Wichert Akkerman
2e4ffe59b5 more FreeBSD updates 2000-09-03 23:57:48 +00:00
Wichert Akkerman
bf79f2e16b Add FreeBSD support 2000-09-01 21:03:06 +00:00
Wichert Akkerman
16a03d2e97 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
2000-08-10 02:14:04 +00:00
Wichert Akkerman
7987cdf192 net.c: add SOL_PACKET and SOL_RAW socket options, update SOL_IP and SOL_TCP 2000-07-05 16:05:39 +00:00
Wichert Akkerman
bd4125c6bc Close outf fd when forking 2000-06-27 17:28:06 +00:00
Wichert Akkerman
5ae21ead9f The `too much stuff, just check the ChangeLog' update 2000-05-01 01:53:59 +00:00
Wichert Akkerman
faf722234d 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
2000-02-19 23:59:03 +00:00
Wichert Akkerman
2ee6e45f36 Fixup isdigit calls 2000-02-18 15:36:12 +00:00
Wichert Akkerman
8b1b40cd8b Merge Trillian patches (Linux ia64) 2000-02-03 21:58:30 +00:00
Wichert Akkerman
4dc8a2aec6 Bunch of stuff 1999-12-23 14:20:14 +00:00
Wichert Akkerman
ea78f0f771 Add UnixWare support to configure 1999-11-29 15:34:02 +00:00
Wichert Akkerman
9dbf15466e Add pollhack 1999-11-26 13:11:29 +00:00
Wichert Akkerman
54a4767f86 Add missing newline in error 1999-10-17 00:57:34 +00:00
Wichert Akkerman
9ce1a63eb2 Catching up on my mail-backlog, see ChangeLog for details 1999-08-29 23:15:07 +00:00
Wichert Akkerman
e68d61c7d6 Remove stupid error in strace.c. Looks like I pasted something
I shouldn't have in there :(
1999-06-28 13:17:16 +00:00
Wichert Akkerman
360815ecc2 Update documentation somewhat 1999-06-28 13:16:03 +00:00
Wichert Akkerman
789ed35db5 avoid leaking fd into child 1999-06-14 10:45:01 +00:00
Wichert Akkerman
dacfb6ebd6 Add sparc patches from Jakub Jelinek 1999-06-03 14:21:07 +00:00
Nate Sammons
ce780fc9e6 Add new function `signame', which returns name (SIGXXX) of numeric
signal, and replace lookups in signalent[] with calls to it.
1999-03-29 23:23:13 +00:00
Wichert Akkerman
76baf7c9f6 Initial revision 1999-02-19 00:21:36 +00:00