Andreas Schwab [Fri, 16 Oct 2009 09:37:13 +0000 (11:37 +0200)]
Fix decoding of newfstatat syscall on x86-64
* file.c (printstat64) [LINUX && X68_64]: If tracing a 64-bit
process redirect to printstat.
Fixes RH#529316 "Field values shown for "newfstatat" system
call are incorrect"
Mike Frysinger [Mon, 12 Oct 2009 15:05:14 +0000 (11:05 -0400)]
sparc/linux: Rewrite to use asm/ptrace.h
The current sparc/linux code uses asm/reg.h, but recent Linux kernels
dropped that header completely. So switch over to the ptrace headers
as those should stick around indefinitely as part of the ABI.
* defs.h [LINUXSPARC] (U_REG_G1, U_REG_O0, U_REG_O1): Define.
* process.c: Drop asm/regs.h include.
[SPARC || SPARC64] (change_syscall): Change struct regs to struct pt_regs.
* signal.c: Drop asm/regs.h include.
(m_siginfo_t): Unify [SPARC || SPARC64] and [MIPS].
[SPARC || SPARC64] (sys_sigreturn): Change struct regs to struct pt_regs.
* syscall.c: Drop asm/regs.h include.
[SPARC || SPARC64] (internal_syscall, get_scno, get_error, force_result,
syscall_enter): Change struct regs to struct pt_regs.
* util.c: Drop asm/regs.h include.
(_hack_syscall5, _ptrace): Delete.
[SPARC || SPARC64] (getpc, printcall, arg_setup_state): Change
struct regs to struct pt_regs.
Mike Frysinger [Thu, 8 Oct 2009 00:41:29 +0000 (20:41 -0400)]
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.
Mike Frysinger [Thu, 8 Oct 2009 00:41:56 +0000 (20:41 -0400)]
Avoid malloc(0) in getdents parsers
On end of directory, getdents returns 0. This return value is used to
then try and do malloc(0), but on some systems this will always return
NULL. Since the code won't read the pointer in question if len is 0,
then don't bother calling malloc(0) and set the pointer to NULL ourself.
* file.c (sys_getdents, sys_getdents64): Avoid malloc(0) call.
* debian/rules: Do not ship ChangeLog anymore.
* debian/control: Update to Debian standards version 3.8.1, and remove
Roland from the Maintainers list. This closes Debian bug #521458.
* debian/changelog: Document changes and prepare for release.
__NR_SYSCALL_BASE eis 0 for EABI and is 0x900000 for OABI.
* process (change_syscall) [LINUX && ARM]: Mask off the high order bits
when changing syscall.
Signed-off-by: Steve Bennett <steveb@workware.net.au> Reviewed-by: Kirill A. Shutemov <kirill@shutemov.name>
Paolo Bonzini [Fri, 14 Aug 2009 10:34:06 +0000 (12:34 +0200)]
Add accept4 socketcall
This second patch in the series adds support for accept4 as a socketcall
sub-call. Besides the need to renumber all system calls, this poses
no problem.
Tested on i686.
Paolo Bonzini [Fri, 14 Aug 2009 10:34:05 +0000 (12:34 +0200)]
Replace x86-64 paccept with accept4
This patch changes the paccept syscall to accept4 for x86-64, since
the former was dropped in Linux kernel commit v2.6.27-rc7-14-g2d4c826.
At the same time, it adds support for pretty printing its arguments.
* linux/x86_64/syscallent.h: Replace paccept with accept4,
hook in sys_accept4.
* net.c (sys_accept): Leave a small stub calling the new...
(do_accept): ... function, which also adds a flags_arg argument.
(sys_accept4): New.
Dmitry V. Levin [Mon, 1 Jun 2009 09:59:11 +0000 (09:59 +0000)]
Clean up header checks
* configure.ac: Reformat AC_CHECK_HEADERS to keep it sorted and
easily updated, and reduce merging errors in the future.
* system.c: Convert all non-standard #ifdef checks for specific
headers to regular #ifdef HAVE_*_H checks.
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* strace.c (printstatsol, printstat_sparc64):
Remove NULL and error check for addr parameter.
(printoldstat, printstat, printoldstat64):
Move NULL and error check for addr parameter
so that it happens before printstatsol/printstat_sparc64 calls.
* signal (sys_rt_sigaction): Print struct sigaction correctly
in 32/64 environment.
* desc.c (printflock): Add #ifdefs around earlier flock 32/64 fix
so that we don't waste time on arches with one personality.
Denys Vlasenko [Mon, 23 Mar 2009 13:12:46 +0000 (13:12 +0000)]
* system.c (sram_alloc_flag): Add L2_SRAM constant.
by Mike Frysinger (vapier AT gentoo.org).
(sys_sram_alloc): Fix improperly used %zu:
tcp->u_arg is not a size_t, it is a long.
* net.c (printcmsghdr): Fix improperly used %zu:
struct cmsghdr::cmsg_len is not a size_t.
Denys Vlasenko [Fri, 20 Mar 2009 13:28:00 +0000 (13:28 +0000)]
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.
Denys Vlasenko [Tue, 17 Mar 2009 14:29:59 +0000 (14:29 +0000)]
* 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.
Denys Vlasenko [Tue, 10 Mar 2009 20:41:58 +0000 (20:41 +0000)]
Decode fcntl's F_{GET,SET}LEASE, F_NOTIFY, and F_DUPFD_CLOEXEC.
By Mike Frysinger (vapier AT gentoo.org)
* desc.c: Add F_SETLEASE, F_GETLEASE, F_NOTIFY,
F_DUPFD_CLOEXEC to fcntlcmds[]. Create notifyflags[] array.
(sys_fcntl): Handle new flags.
Optimize printing of open modes.
* defs.h: Declare sprint_open_modes(),
remove unused parameter in tprint_open_modes().
* desc.c (sprint_open_modes): Move fuction definition from here...
* file.c (sprint_open_modes): To here.
(tprint_open_modes): Use sprint_open_modes(), it already
generates needed string.
* ipc.c: Remove unused parameter from calls
to tprint_open_modes().
Denys Vlasenko [Wed, 25 Feb 2009 17:08:40 +0000 (17:08 +0000)]
CRIS support by Hinko Kocevar (hinko.kocevar AT cetrtapot.si)
* configure.ac: Make it recognize cris.
* process.c: Define ARG_xxx constants for cris.
(change_syscall): Add support for cris.
(struct_user_offsets): Add cris-specific data.
* signal.c (sys_sigreturn): Add support for cris.
* syscall.c (get_scno): Add support for cris.
(syscall_fixup): Add support for cris.
(get_error): Add support for cris.
(syscall_enter): Add support for cris.
(force_result): While at it, fix cpp directives indentation.
* util.c (printcall): Add support for cris.
Denys Vlasenko [Tue, 24 Feb 2009 15:17:53 +0000 (15:17 +0000)]
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.
Denys Vlasenko [Mon, 23 Feb 2009 08:07:45 +0000 (08:07 +0000)]
More cleanups from Mike Frysingler:
README: update an URL
.gitignore: added
config.guess config.sub install-sh: removed, they are revenerated
by autoconf anyway
Denys Vlasenko [Fri, 20 Feb 2009 17:38:47 +0000 (17:38 +0000)]
Further signalent.h cleanup.
* linux/ia64/signalent.h: Remove, it is identical to common signalent.h
sans "SIGRTnn" definitions which are redundant.
* linux/powerpc/signalent.h: Remove, it is identical to common signalent.h
sans outdated "SIGUNUSED" which should be "SIGSYS".
* linux/s390/signalent.h: Ditto.
* linux/s390x/signalent.h: Ditto.
* Makefile.am: Remove references to the above files.
Denys Vlasenko [Fri, 20 Feb 2009 16:24:39 +0000 (16:24 +0000)]
Patch by Mike Frysinger (vapier AT gentoo.org).
* Makefile.am: Remove reference to linux/sh/signalent.h.
* linux/sh/signalent.h: Remove, it is identical to common signalent.h.
Denys Vlasenko [Fri, 20 Feb 2009 16:00:41 +0000 (16:00 +0000)]
Patch by Mike Frysinger (vapier AT gentoo.org).
* linux/errnoent.h: Make ERRNO_58 show EDEADLOCK for POWERPC.
* Makefile.am: Remove reference to linux/powerpc/errnoent.h.
* linux/powerpc/errnoent.h: Remove, we can use common errnoent.h now.
Denys Vlasenko [Tue, 10 Feb 2009 16:03:20 +0000 (16:03 +0000)]
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.
Denys Vlasenko [Mon, 9 Feb 2009 18:55:59 +0000 (18:55 +0000)]
* 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.
Denys Vlasenko [Thu, 29 Jan 2009 20:38:20 +0000 (20:38 +0000)]
* 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.
Denys Vlasenko [Wed, 28 Jan 2009 19:00:54 +0000 (19:00 +0000)]
* 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.
Denys Vlasenko [Fri, 23 Jan 2009 16:10:22 +0000 (16:10 +0000)]
By Michal Nowak <mnowak@redhat.com>:
* mem.c (print_ldt_entry): Fix warning:
Format '%#08lx' expects type 'long unsigned int', but
argument 2 was type 'unsigned int'.
Denys Vlasenko [Wed, 21 Jan 2009 19:05:43 +0000 (19:05 +0000)]
* 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.
Denys Vlasenko [Sat, 17 Jan 2009 01:52:54 +0000 (01:52 +0000)]
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.
Denys Vlasenko [Sat, 17 Jan 2009 01:06:18 +0000 (01:06 +0000)]
* 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".
Denys Vlasenko [Sat, 17 Jan 2009 00:21:31 +0000 (00:21 +0000)]
* 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.
Denys Vlasenko [Fri, 9 Jan 2009 17:22:56 +0000 (17:22 +0000)]
* 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.