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>
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>
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>
Show PTRACE_EVENT_STOP correctly in debug output

Signed-off-by: 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>
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>
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>
In -f mode, do not assume that new pid is stopped - handle exits too

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Update build_static_example.sh

Now it also contains a tested example of i686 build on 64-bit host.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Manpage update

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Another manpage tweak

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
powerpc: Use PTRACE_GETREGS to fetch all registers

* defs.h: declare ppc_regs and get_regs_error.
* signal.c (sys_sigreturn): Use ppc_regs instead of upeek.
* syscall.c: define ppc_regs.
(printcall): Use ppc_regs instead of upeek.
(get_scno): Replace multiple upeek calls with one PTRACE_GETREGS call.
(get_syscall_result): Likewise.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
powerpc: Provide a fallback for old kernels without PTRACE_GETREGS

PTRACE_GETREGS was added to the ppc kernel in 2.6.23. In order to
provide backward compatibility for very old kernels, add a manual
fallback.

* syscall.c (powerpc_getreg, powerpc_getregs_old): New functions.
(get_regs): Call powerpc_getregs_old if PTRACE_GETREGS is not supported.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: 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>
Get rid of powerpc_getreg(), it's a copy of upeek()

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
POWERPC: if GETREGS fails with EIO, don't try it again

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
POWERPC: read ppc_regs.nip if -i

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
POWERPC: get rid of "static long ppc_result"

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
sys_clone: add a comment about CLONE_PTRACE and CLONE_UNTRACED

No code changes.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Update qemu_multiarch_testing/README

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>