]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
tests: Don't use ptrace detach stopped trick. Raise can return.
authorMark Wielaard <mjw@redhat.com>
Sat, 4 Jan 2014 22:28:33 +0000 (23:28 +0100)
committerMark Wielaard <mjw@redhat.com>
Sat, 4 Jan 2014 22:28:33 +0000 (23:28 +0100)
On older kernels the ptrace detach stop trick doesn't work reliably.
Just keep the child processes attached and stopped during the tests,
dwfl_linux_proc_attach will handle that fine now. Also on older kernels
raise would sometimes return anyway and cause a spurious assert. Just
ignore it.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
tests/ChangeLog
tests/backtrace-data.c
tests/backtrace-dwarf.c
tests/backtrace.c

index 0c112cf244b38b1374a0599b1e422bf8f45cf2f0..63b7bed736693ffaf94aeaf1807f9211d07a7088 100644 (file)
@@ -1,3 +1,15 @@
+2014-01-04  Mark Wielaard  <mjw@redhat.com>
+
+       * backtrace-data.c (main): Don't assert if raise returns.
+       * backtrace-dwarf.c (report_pid): Call dwfl_linux_proc_attach with
+       assume_ptrace_attached true.
+       (ptrace_detach_stopped): Removed function.
+       (main): Don't call ptrace_detach_stopped.
+       * backtrace.c (ptrace_detach_stopped): Removed function.
+       (report_pid): Call dwfl_linux_proc_attach with assume_ptrace_attached
+       true.
+       (exec_dump): Don't call ptrace_detach_stopped.
+
 2014-01-04  Mark Wielaard  <mjw@redhat.com>
 
        * backtrace-subr.sh (check_native_core): Skip, exit 77, the test
index 9fa3c4a942bbb4083ca5786aad4a3a7e464aa683..dd74160a11b1765757af98ab7642016ac4556647 100644 (file)
@@ -278,7 +278,7 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
       assert_perror (errno);
       assert (l == 0);
       raise (SIGUSR1);
-      assert (0);
+      return 0;
     default:
       break;
   }
index 3a3e76328e0c3dc74212ada98ec13e259d2ba00b..f75e12024dde232d7f2c215788f014e87c25538a 100644 (file)
@@ -42,7 +42,7 @@ report_pid (Dwfl *dwfl, pid_t pid)
   if (dwfl_report_end (dwfl, NULL, NULL) != 0)
     error (2, 0, "dwfl_report_end: %s", dwfl_errmsg (-1));
 
-  result = dwfl_linux_proc_attach (dwfl, pid, false);
+  result = dwfl_linux_proc_attach (dwfl, pid, true);
   if (result < 0)
     error (2, 0, "dwfl_linux_proc_attach: %s", dwfl_errmsg (-1));
   else if (result > 0)
@@ -106,15 +106,6 @@ thread_callback (Dwfl_Thread *thread, void *thread_arg)
   error (1, 0, "dwfl_thread_getframes: %s", dwfl_errmsg (-1));
 }
 
-static void
-ptrace_detach_stopped (pid_t pid)
-{
-  errno = 0;
-  long l = ptrace (PTRACE_DETACH, pid, NULL, (void *) (intptr_t) SIGSTOP);
-  assert_perror (errno);
-  assert (l == 0);
-}
-
 int
 main (int argc __attribute__ ((unused)), char **argv)
 {
@@ -151,8 +142,6 @@ main (int argc __attribute__ ((unused)), char **argv)
   assert (WIFSTOPPED (status));
   assert (WSTOPSIG (status) == SIGABRT);
 
-  ptrace_detach_stopped (pid);
-
   Dwfl *dwfl = pid_to_dwfl (pid);
   dwfl_getthreads (dwfl, thread_callback, NULL);
 
index 64f90c43318a6482d718555cb78625e1e4520a0c..758dfed6c9fc9d9179465c2790b7bba7f0dc0beb 100644 (file)
@@ -259,15 +259,6 @@ prepare_thread (pid_t pid2 __attribute__ ((unused)),
 #include <unistd.h>
 #define tgkill(pid, tid, sig) syscall (__NR_tgkill, (pid), (tid), (sig))
 
-static void
-ptrace_detach_stopped (pid_t pid)
-{
-  errno = 0;
-  long l = ptrace (PTRACE_DETACH, pid, NULL, (void *) (intptr_t) SIGSTOP);
-  assert_perror (errno);
-  assert (l == 0);
-}
-
 static void
 report_pid (Dwfl *dwfl, pid_t pid)
 {
@@ -280,7 +271,7 @@ report_pid (Dwfl *dwfl, pid_t pid)
   if (dwfl_report_end (dwfl, NULL, NULL) != 0)
     error (2, 0, "dwfl_report_end: %s", dwfl_errmsg (-1));
 
-  result = dwfl_linux_proc_attach (dwfl, pid, false);
+  result = dwfl_linux_proc_attach (dwfl, pid, true);
   if (result < 0)
     error (2, 0, "dwfl_linux_proc_attach: %s", dwfl_errmsg (-1));
   else if (result > 0)
@@ -397,8 +388,6 @@ exec_dump (const char *exec)
       prepare_thread (pid2, jmp);
     }
   dwfl_end (dwfl);
-  ptrace_detach_stopped (pid);
-  ptrace_detach_stopped (pid2);
   check_tid = pid2;
   dwfl = pid_to_dwfl (pid);
   dump (dwfl);