attempt to fix debugger attach on ppc32-linux and ppc64-linux (see
#151908). The fork/ptrace-based mechanism works fine for x86-linux
and amd64-linux but not on ppc. I have no idea what is going on.
It seems like the forked child process (to which we will attach GDB)
does not stop when it does PTRACE_TRACE_ME and so things go downhill
very rapidly after that.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7184
void VG_(start_debugger) ( ThreadId tid )
{
# define N_BUF 4096
- Int pid;
+ Int pid, rc;
- if ((pid = VG_(fork)()) == 0) {
- VG_(ptrace)(VKI_PTRACE_TRACEME, 0, NULL, NULL);
- VG_(kill)(VG_(getpid)(), VKI_SIGSTOP);
+ pid = VG_(fork)();
+
+ if (pid == 0) {
+ vki_sigset_t set;
+ /* child */
+ rc = VG_(ptrace)(VKI_PTRACE_TRACEME, 0, NULL, NULL);
+ vg_assert(rc == 0);
+ rc = VG_(kill)(VG_(getpid)(), VKI_SIGSTOP);
+ vg_assert(rc == 0);
} else if (pid > 0) {
+ /* parent */
Int status;
Int res;
if (allow_db_attach &&
VG_(is_action_requested)( "Attach to debugger", & VG_(clo_db_attach) ))
{
- VG_(printf)("starting debugger\n");
+ if (0) VG_(printf)("starting debugger\n");
VG_(start_debugger)( err->tid );
}
/* Or maybe we want to generate the error's suppression? */