Commit Graph

114 Commits

Author SHA1 Message Date
Denys Vlasenko
4f3df078b2 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>
2012-01-29 22:38:35 +01:00
Andreas Schwab
a7920a8927 Fix missing parens
* signal.c (sys_sigreturn): Add missing parens.
2012-01-18 21:19:25 +01:00
Denys Vlasenko
023b7700de 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>
2012-01-18 16:30:47 +01:00
Denys Vlasenko
bbe29b36aa Fix old sigaction display
* signal.c (sys_sigaction): Fix display of sigaction with
SIG_DFL/SIG_IGN handlers.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2012-01-18 15:30:56 +01:00
Denys Vlasenko
b11322fd3c Display mask on enter to sigreturn, not on exit
sys_sigreturn() performs ugly manipulations in order to show
signal mask which is restored by this syscall: on syscall entry,
fetches it from the stack, saves it in tcp->u_arg[]
(where it used to overflow this array - fixed sometime ago),
then retrieves the mask and displays it on syscall exit.

Apparently, the motivation is to make it slightly more obvious
to user that signal mask is restored only when this syscall returns.
IMO, this hardly justifies the necessary hacks. It is much easier
to display the mask at the point when we fetch it - on syscall entry.

While at it, I made it so that we do display returned value/errno.
I see no point in hiding it and showing uninformative "= ?" instead.

Example of pause() being interrupted by ALRM which has installed handler
which re-arms ALRM:

Before the patch:

rt_sigsuspend([INT])                    = ? ERESTARTNOHAND (To be restarted)
--- {si_signo=SIGALRM, si_code=SI_KERNEL} (Alarm clock) ---
alarm(1)                                = 0
sigreturn()                             = ? (mask now [INT])

After:

rt_sigsuspend([INT])                    = ? ERESTARTNOHAND (To be restarted)
--- {si_signo=SIGALRM, si_code=SI_KERNEL} (Alarm clock) ---
alarm(1)                                = 0
sigreturn() (mask [INT])                = -1 EINTR (Interrupted system call)

* defs.h: Declare struct pt_regs i386_regs and struct pt_regs x86_64_regs.
* syscall.c: Remove "static" keywork from these structures' definitions.
* signal.c (sys_sigreturn): Display mask on enter, not on exit.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2012-01-10 16:40:35 +01:00
Denys Vlasenko
60fe8c139c 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>
2011-09-01 10:00:28 +02:00
Denys Vlasenko
5940e65939 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>
2011-09-01 09:55:05 +02:00
Denys Vlasenko
a7949748d1 Conditionally optimize out unused code
* syscall.c (internal_syscall): Call internal_exec only if
SUNOS4 || (LINUX && TCB_WAITEXECVE).
* process.c (internal_exec): Define this function only if
SUNOS4 || (LINUX && TCB_WAITEXECVE).
(printwaitn): Don't check wordsize if SUPPORTED_PERSONALITIES == 1.
* signal.c (sys_kill): Likewise.
* syscall.c (is_negated_errno): Likewise.
(trace_syscall_exiting): Fold a tprintf into tprintfs which follow it.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2011-08-23 12:53:02 +02:00
Denys Vlasenko
39fca62801 Small optimization in signal and ioctl tables
Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.

Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.

* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
2011-08-23 12:53:01 +02:00
Denys Vlasenko
d9560c1080 Set saner MAX_ARGS (6 or 8) for X86_64 and I386
I noticed that tcp->u_args[MAX_ARGS] array is way larger than
I'd expect: for all arches except HPPA it has 32 (!) elements.

I looked at the code and so far I spotted only one abuser of
this fact: sys_sigreturn. On several arches, it saves sigset_t
into tcp->u_args[1...N] on entry and prints it on exit, a-la

memcpy(&tcp->u_arg[1], &sc.oldmask[0], sizeof(sigset_t))

The problem here is that in glibc sigset_t is insanely large:
128 bytes, and using sizeof(sigset_t) in memcpy will overrun
&tcp->u_args[1] even with MAX_ARGS == 32:
On 32 bits, sizeof(tcp->u_args) == 32*4 == 128 bytes!
We may already have a bug there!

This commit changes the code to save NSIG / 8 bytes only.
NSIG can't ever be > 256, and in practice is <= 129,
thus NSIG / 8 is <= 16 bytes == 4 32-bit words,
and even MAX_ARGS == 5 should be enough for saving signal masks.

* defs.h: Reduce MAX_ARGS for X86_64 and I386 from 32 to 8
for FreeBSD and to 6 for everyone else. Add comment about current
state of needed MAX_ARGS.
* signal.c: Add comment about size of sigset_t.
(sprintsigmask): Reduce static string buffer from 8k to 2k.
(sys_sigreturn): Fix sigset saving to save only NSIG / 8 bytes,
not sizeof(sigset_t) bytes.
* linux/mips/syscallent.h: Reduce nargs of printargs-type syscall to 7.
* linux/arm/syscallent.h: Reduce nargs of printargs-type syscall to 6.
* linux/i386/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2011-08-23 12:53:01 +02:00
Denys Vlasenko
041b3ee42e Cosmetic fixes, no code changes
* defs.h: Add/reformat comments.
* signal.c: Remove wrong comment. Add warning directive
when we detect that NSIG is undefined. Add comment about
NSIG on ARM. Fix typo in comment.
(signame): Reformat code a bit without changes to logic.
Shorten static buffer.
(sys_rt_sigprocmask): Remove stray empty line.
* syscall.c: Add warning directive when we detect that
NSIG is undefined. Add comment about NSIG on ARM.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2011-08-23 12:53:01 +02:00
Denys Vlasenko
19cdada5b4 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>
2011-08-17 10:45:32 +02:00
Denys Vlasenko
7b609d5ba0 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>
2011-06-22 14:32:43 +02:00
fcda7a5f4f Introduce ARRAY_SIZE() macro
* defs.h (ARRAY_SIZE): New macro.
* ioctl.c: Use it.
* pathtrace.c (pathmatch, storepath): Likewise.
* process.c (printpriv): Likewise.
* signal.c: Likewise.
* syscall.c: Likewise.
2011-06-13 21:58:43 +00:00
Denys Vlasenko
56a52984ae Optimize sigreturn handling
* signal.c (sys_sigreturn): move stack pointer variables,
and for SPARC and MIPS, stack pointer and sigmask reading code
into "if (entering) ..." block, because it is only needed
in this branch; load tcp->u_arg[1] into sigmask for display
_after_ we know for sure u_arg[1] does contain valid sigmask
(IOW: perform operation only when we know we will need the result)

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2011-06-09 01:36:29 +02:00
Denys Vlasenko
eccc48c63e "Modernize" four old-style function parameter declarations
* signal.c (signame, long_to_sigset, printsigmask, printsignal):
Convert old-style C function definitions to a "modern" form.
This does not change any actual code.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2011-06-09 01:28:11 +02:00
Denys Vlasenko
facd45b255 Fix sigreturn decoding on MIPS
The "return 0" line was accidentally deleted circa 2007,
which made sigreturn on MIPS always display "= 0" return
instead of more informative " = ? (mask now [MASK])".

* strace.c (sys_sigreturn): Add wrongly deleted "return 0" line

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2011-06-09 01:22:10 +02:00
Denys Vlasenko
b63256e69b 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>
2011-06-07 12:13:24 +02:00
Denys Vlasenko
1201426dd4 "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>
2011-05-30 14:00:14 +02:00
b41e1c90f0 Enhance decoding of kernel-generated signals
* signal.c (printsiginfo) [LINUX]: Do not print uninteresting
zero-initialized fields.
2011-03-10 23:14:47 +00:00
6d9e8e82f8 Fix decoding of user-generated signals
* signal.c [LINUX] (SI_FROMUSER): Define.
[LINUX || SVR4] (printsiginfo) [SI_FROMUSER]: Enhance decoding.
2011-03-10 22:18:56 +00:00
7d4bff1851 Recognize SI_KERNEL and SI_ASYNCNL
* signal.c [LINUX] (SI_KERNEL, SI_ASYNCNL): Define.
[LINUX || SVR4] (siginfo_codes): Add entries for SI_KERNEL and
SI_ASYNCNL, reorder entries.
2011-03-10 21:41:34 +00:00
3138213bc9 Fix decoding of file descriptors
* defs.h (printfd): New function prototype.
* util.c (printfd): New function.
* file.c (print_dirfd): Update prototype to use printfd().
(sys_openat, sys_faccessat, sys_newfstatat, sys_mkdirat, sys_linkat,
sys_unlinkat, sys_readlinkat, sys_renameat, sys_fchownat, sys_fchmodat,
sys_futimesat, sys_utimensat, sys_mknodat): Update use of print_dirfd().
(sys_lseek, sys_llseek, sys_readahead, sys_ftruncate, sys_ftruncate64,
sys_fstat, sys_fstat64, sys_oldfstat, sys_fstatfs, sys_fstatfs64,
sys_fchdir, sys_fchroot, sys_linkat, sys_fchown, sys_fchmod, sys_fsync,
sys_readdir, sys_getdents, sys_getdirentries, sys_fsetxattr,
sys_fgetxattr, sys_flistxattr, sys_fremovexattr, sys_fadvise64,
sys_fadvise64_64, sys_inotify_add_watch, sys_inotify_rm_watch,
sys_fallocate): Use printfd() for decoding of file descriptors.
* desc.c (sys_fcntl, sys_flock, sys_close, sys_dup, do_dup2,
decode_select, sys_epoll_ctl, epoll_wait_common): Use printfd() for
decoding of file descriptors.
* io.c (sys_read, sys_write, sys_readv, sys_writev, sys_pread,
sys_pwrite, sys_sendfile, sys_sendfile64, sys_pread64, sys_pwrite64,
sys_ioctl): Likewise.
* mem.c (print_mmap, sys_mmap64): Likewise.
* signal.c (do_signalfd): Likewise.
* stream.c (decode_poll): Likewise.
* time.c (sys_timerfd_settime, sys_timerfd_gettime): Likewise.
Based on patch from Grant Edwards <grant.b.edwards@gmail.com>.
2011-03-04 02:08:02 +00:00
30145dda9d Fix const-correctness issues uncovered by gcc -Wwrite-strings
* defs.h (struct xlat): Add const qualifier to the field of
type "char *".
(set_sortby, qualify, printnum, printnum_int): Add const qualifier to
arguments of type "char *".
* count.c (set_sortby): Add const qualifier to the argument and
automatic variable of type "char *".
* desc.c (decode_select): Add const qualifier to automatic variables of
type "char *".
* ioctlsort.c (struct ioctlent): Add const qualifier to fields of
type "char *".
(main):  Add const qualifier to argv.
* process.c (printargv): Add const qualifier to the argument and
automatic variable of type "char *".
(printargc) Add const qualifier to argument of type "char *".
* signal.c (sprintsigmask, parse_sigset_t): Add const qualifier to
arguments of type "char *".
* strace.c (progname): Add const qualifier.
(detach): Add const qualifier to automatic variable of type "char *".
* stream.c (struct strbuf): Add const qualifier to the field of
type "char *".
* syscall.c (struct qual_options): Add const qualifier to fields of
type "char *".
(qual_syscall, qual_fault, qual_desc, lookup_class): Add const qualifier
to arguments of type "char *".
(qual_signal): Add const qualifier to the argument of type "char *",
avoid modification of constant argument.
(qualify): Likewise.
* util.c (printflags): Add const qualifier to automatic variable of
type "char *".
(printnum, printnum_int): Add const qualifier to arguments of
type "char *".
2010-09-07 00:59:18 +00:00
Edgar E. Iglesias
939caba68e Add support for the MicroBlaze architecture
* configure.ac: Recognize MicroBlaze.
* linux/microblaze/syscallent.h: New file.
* Makefile.am (EXTRA_DIST): Add linux/microblaze/syscallent.h
* process.c (change_syscall, struct_user_offsets): Add MicroBlaze
support.
* signal.c (sys_sigreturn): Likewise.
* syscall.c (internal_syscall, get_scno, syscall_fixup, get_error,
syscall_enter): Likewise.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-05 20:04:50 +00:00
Andreas Schwab
d69fa497f4 Add biarch support for powerpc64
* acinclude.m4 (AC_LITTLE_ENDIAN_LONG_LONG): Use int instead of
long.
* configure.ac [$host_cpu = powerpc*]: Also define POWERPC64 if
$host_cpu = powerpc64.
* defs.h (SUPPORTED_PERSONALITIES, PERSONALITY0_WORDSIZE)
(PERSONALITY1_WORDSIZE) [POWERPC64]: Define.
* file.c: (struct stat_powerpc32, printstat_powerpc32) [POWERPC64]:
Define.
(printstat) [LINUX && POWERPC64]: Use printstat_powerpc32 in
32-bit personality.
(sys_newfstatat) [POWERPC64]: Handle personalities.
* signal.c (sys_sigreturn) [POWERPC64]: Likewise.
* util.c (printllval) [POWERPC64]: Likewise.
(printcall) [POWERPC64]: Use wider format for IP prefix.
* syscall.c (get_scno) [POWERPC64]: Check for 64/32 bit mode.
* linux/powerpc/errnoent1.h: New file.
* linux/powerpc/ioctlent1.h: New file.
* linux/powerpc/signalent1.h: New file.
* linux/powerpc/syscallent1.h: New file.
2010-07-13 19:13:03 +02:00
Andreas Schwab
edb393420c Fix reporting signal mask by sigreturn on powerpc
* signal.c (sys_sigreturn) [POWERPC]: Skip dummy stack frame when
locating signal context.
2010-02-23 22:26:16 +01:00
Chris Metcalf
c8c6698ef7 Add support for the TILE architecture
* configure.ac: Add TILE to the list of supported architectures.
* defs.h: Define TCB_WAITEXECVE for TILE.
* linux/tile/syscallent.h: New file.
* Makefile.am (EXTRA_DIST): Add linux/tile/syscallent.h
* process.c (change_syscall, struct_user_offsets): Add TILE support.
* syscall.c (get_scno, get_error, syscall_enter): Likewise.
* mem.c (mmap_flags, print_mmap): Add MAP_CACHE_xxx TILE extensions
support.
* signal.c (sigact_flags): Add SA_NOPTRACE.
(sys_sigreturn): Add TILE support.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
2010-02-05 22:09:30 +00:00
e5e6085806 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.
2010-02-04 22:40:57 +00:00
Mike Frysinger
8566c50025 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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-10-12 19:54:21 +00:00
Carlos O'Donell
4677c8af94 Fix SA_HANDLER function pointer comparisons for hppa
* signal.c (sys_sigaction): Cast SA_HANDLER function pointers to long.
(sys_rt_sigaction): Likewise.
2009-10-05 22:50:39 +00:00
9d2ee3d6aa * signal.c (do_signalfd): Fix typo in output format. 2009-10-05 14:31:28 +00:00
Roland McGrath
eb9e2e8904 Revert unapproved commits. 2009-06-02 16:49:22 -07:00
4bcd5ef922 * bjm.c (sys_query_module): Fix format warning reported by
gcc -Wformat-security.
* file.c (tprint_open_modes): Likewise.
* process.c (printargv): Likewise.
* signal.c (printsignal): Likewise.
2009-06-01 10:32:27 +00:00
Denys Vlasenko
b1a78cf3ee * signal (sys_rt_sigtimedwait): Fix sigtimedwait syscall decoding. 2009-04-15 13:31:59 +00:00
Denys Vlasenko
7a862d7620 * 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.
2009-04-15 13:22:59 +00:00
Denys Vlasenko
1d632468c0 * signal.c: Whitespace, comment, and style fixes, no code changes.
* file.c: Ditto.
* time.c: Ditto.
* process.c: Ditto.
* resource.c: Ditto.
2009-04-14 12:51:00 +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
ea0e6e8026 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.
2009-02-25 17:08:40 +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
Roland McGrath
587c7b50ad 2009-02-10 Roland McGrath <roland@redhat.com>
* configure.ac: Check for struct sigcontext.
	* signal.c [LINUX] [M68K] (struct sigcontext): Don't define it if
	[HAVE_STRUCT_SIGCONTEXT].
	From Muttley Meen <muttley.meen@gmail.com>.
2009-02-11 03:03:28 +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
73ce40e9c7 two instances of s/sa_handler == SIG_DFL/sa_handler == SIG_IGN/ 2008-12-17 17:22:03 +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
4371b10b30 2008-10-23 Dmitry V. Levin <ldv@altlinux.org>
Implement parsers for new linux syscalls.
	* desc.c (do_dup2, [LINUX] sys_dup3): New functions.
	(sys_dup2): Use do_dup2.
	[LINUX] (sys_epoll_create1): New function.
	[LINUX] (do_eventfd, sys_eventfd2): New functions.
	[LINUX] (sys_eventfd): Use do_eventfd.
	* net.c (do_pipe, [LINUX] sys_pipe2): New functions.
	(sys_pipe): Use do_pipe.
	* signal.c [LINUX] (do_signalfd, sys_signalfd4): New functions.
	[LINUX] (sys_signalfd): Use do_signalfd.
	* linux/syscall.h: Declare new sys_* functions.
	* linux/syscallent.h: Hook up signalfd4, eventfd2, epoll_create1,
	dup3, pipe2, inotify_init1.
	* linux/x86_64/syscallent.h: Hook up paccept, signalfd4, eventfd2,
	epoll_create1, dup3, pipe2, inotify_init1.
2008-11-10 22:53:02 +00:00
21a7534745 2008-04-19 Dmitry V. Levin <ldv@altlinux.org>
* desc.c (sys_fcntl): Do not initialize auxstr for failed syscall.
	* process.c (sys_fork, sys_rfork) [USE_PROCFS]: Likewise.
	* signal.c (sys_signal): Likewise.
	* stream.c (internal_stream_ioctl): Likewise.
	* time.c (sys_adjtimex): Likewise.
	* syscall.c (trace_syscall): If RVAL_STR is set, then
	print auxstr for failed syscall as well.
2008-09-03 01:22:18 +00:00
Roland McGrath
5f20681a25 2008-08-19 Roland McGrath <roland@redhat.com>
* signal.c (sys_sigaction, sys_rt_sigaction): Don't omit the rest of
	the struct after sa_handler is a known constant.  Some sa_flags bits
	have meaning even for SIG_IGN/SIG_DFL.
2008-08-20 01:59:40 +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
Roland McGrath
4fef51d948 2008-07-17 Roland McGrath <roland@redhat.com>
* signal.c (sigact_flags): Prefer SA_NODEFER to SA_NOMASK,
	SA_RESETHAND to SA_ONESHOT.
	Fixes RH#455821.
2008-07-18 01:02:41 +00:00
Roland McGrath
4d7ed02fbc 2008-05-19 Roland McGrath <roland@redhat.com>
* signal.c (sys_kill): When current personality's wordsize is smaller
	than native, sign-extend the PID argument from 32 bits.
	Fixes RH#430585.
2008-05-20 01:43:09 +00:00