]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Minor tidyings to the debugger-attach code, as part of a failed
authorJulian Seward <jseward@acm.org>
Mon, 19 Nov 2007 02:01:01 +0000 (02:01 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 19 Nov 2007 02:01:01 +0000 (02:01 +0000)
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

coregrind/m_debugger.c
coregrind/m_errormgr.c

index d58f919628c28914506f2e6c63391e2373a54981..2bc442d457f7de049756b3cb2cac9cdce282ba7c 100644 (file)
@@ -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;
 
index b719dcba91d0cdbe4d8d14dfea44d86da892ee13..994d50ba3e94e899bd00598449ad59abfaeb8387 100644 (file)
@@ -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? */