]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Replace --wait-for-gdb=yes memory loop by a call to VG_(poll) (5000 milliseconds)
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 1 Oct 2016 13:46:53 +0000 (13:46 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 1 Oct 2016 13:46:53 +0000 (13:46 +0000)
Depending on the cpu speed, this loop was way too fast or too slow.
=> replace by a syscall that will always give the same waiting time.

A few notes:
  A VG_(poll) is available on all supported OS
  B no signals are supposed to interrupt the syscall, as at that place, nothing works yet.
  C gdb can attach to a process blocked in a syscall.

If ever B or C would not be true on some setups, then we could instead do a loop
of e.g. 50 * VG_(poll) (100 milli-seconds)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15999

coregrind/m_main.c

index 09badd70d379487583f887d80f08f337115a9087..9f3b8e41a8ccb8a9c310c59ab24b3c9ba83fd3e7 100644 (file)
@@ -2166,36 +2166,10 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
    /* Hook to delay things long enough so we can get the pid and
       attach GDB in another shell. */
    if (VG_(clo_wait_for_gdb)) {
-      ULong iters, q;
-      VG_(debugLog)(1, "main", "Wait for GDB\n");
-      VG_(printf)("pid=%d, entering delay loop\n", VG_(getpid)());
-
-#     if defined(VGP_x86_linux)
-      iters = 10;
-#     elif defined(VGP_amd64_linux) || defined(VGP_ppc64be_linux) \
-         || defined(VGP_ppc64le_linux) || defined(VGP_tilegx_linux)
-      iters = 10;
-#     elif defined(VGP_ppc32_linux)
-      iters = 5;
-#     elif defined(VGP_arm_linux)
-      iters = 5;
-#     elif defined(VGP_arm64_linux)
-      iters = 5;
-#     elif defined(VGP_s390x_linux)
-      iters = 10;
-#     elif defined(VGP_mips32_linux) || defined(VGP_mips64_linux)
-      iters = 10;
-#     elif defined(VGO_darwin)
-      iters = 3;
-#     elif defined(VGO_solaris)
-      iters = 10;
-#     else
-#       error "Unknown plat"
-#     endif
-
-      iters *= 1000ULL * 1000 * 1000;
-      for (q = 0; q < iters; q++) 
-         __asm__ __volatile__("" ::: "memory","cc");
+      const int ms = 5000; // milliseconds
+      VG_(debugLog)(1, "main", "Wait for GDB during %d ms\n", ms);
+      VG_(printf)("pid=%d, entering delay %d ms loop\n", VG_(getpid)(), ms);
+      VG_(poll)(NULL, 0, ms);
    }
 
    //--------------------------------------------------------------