From: Julian Seward Date: Mon, 19 Nov 2007 02:01:01 +0000 (+0000) Subject: Minor tidyings to the debugger-attach code, as part of a failed X-Git-Tag: svn/VALGRIND_3_3_0~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5343a25e2beac38599a11463ec539b8067f42261;p=thirdparty%2Fvalgrind.git Minor tidyings to the debugger-attach code, as part of a failed 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 --- diff --git a/coregrind/m_debugger.c b/coregrind/m_debugger.c index d58f919628..2bc442d457 100644 --- a/coregrind/m_debugger.c +++ b/coregrind/m_debugger.c @@ -170,13 +170,20 @@ static Int ptrace_setregs(Int pid, VexGuestArchState* vex) 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; diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index b719dcba91..994d50ba3e 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -455,7 +455,7 @@ void do_actions_on_error(Error* err, Bool allow_db_attach) 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? */