[llvm] r296425 - This script was meant to be committed with the DebugCounter changes.

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 18:19:11 PST 2017


Author: dannyb
Date: Mon Feb 27 20:19:11 2017
New Revision: 296425

URL: http://llvm.org/viewvc/llvm-project?rev=296425&view=rev
Log:
This script was meant to be committed with the DebugCounter changes.

Added:
    llvm/trunk/utils/bisect-skip-count   (with props)

Added: llvm/trunk/utils/bisect-skip-count
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/bisect-skip-count?rev=296425&view=auto
==============================================================================
--- llvm/trunk/utils/bisect-skip-count (added)
+++ llvm/trunk/utils/bisect-skip-count Mon Feb 27 20:19:11 2017
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+# This script is used to bisect skip and count arguments for --debug-counter.
+# It is similar to bisect, except it understands how to increase skip and decrease count
+import os
+import sys
+import argparse
+# This is for timeout support. Use the recommended way of import.
+# We do timeouts because when doing, execution testing, we have a habit
+# of finding variants that infinite loop
+if os.name == 'posix' and sys.version_info[0] < 3:
+  import subprocess32 as subprocess
+else:
+  import subprocess
+parser = argparse.ArgumentParser()
+
+parser.add_argument('--skipstart', type=int, default=0)
+parser.add_argument('--skipend', type=int, default=(1 << 32))
+parser.add_argument('--countstart', type=int, default=0)
+parser.add_argument('--countend', type=int, default=(1 << 32))
+parser.add_argument('--timeout', type=int, default=None)
+# Use shell support if you need to use complex shell expressions in your command
+parser.add_argument('--shell', type=bool, default=False)
+parser.add_argument('command', nargs='+')
+
+args = parser.parse_args()
+
+start = args.skipstart
+end = args.skipend
+
+print("Bisect of Skip starting!")
+print("Start: %d" % start)
+print("End: %d" % end)
+
+last = None
+while start != end and start != end-1:
+    count = start + (end - start)/2
+    print("Visiting Skip: %d with (Start, End) = (%d,%d)" % (count, start, end))
+    cmd = [x % {'skip':count, 'count':-1} for x in args.command]
+    print cmd
+    try:
+        result = subprocess.call(cmd, shell=args.shell, timeout=args.timeout)
+        if result == 0:
+           print("    PASSES! Setting end to count")
+           end = count
+        else:
+           print("    FAILS! Setting start to count")
+           start = count
+    except:
+        print(" TIMEOUT, setting end to count")
+        end = count
+firstcount = start
+print("Last good skip: %d" % start)
+start = args.countstart
+end = args.countend
+print("Bisect of Count starting!")
+print("Start: %d" % start)
+print("End: %d" % end)
+while start != end and start != end-1:
+    count = start + (end - start)/2
+    print("Visiting Count: %d with (Start, End) = (%d,%d)" % (count, start, end))
+    cmd = [x % {'count':count, 'skip':firstcount } for x in args.command]
+    print cmd
+    try:
+        result = subprocess.call(cmd, shell=True, timeout=20)
+        if result == 0:
+           print("    PASSES! Setting start to count")
+           start = count
+        else:
+           print("    FAILS! Setting end to count")
+           end = count
+    except:
+        print(" TIMEOUT, setting start to count")
+        start = count
+
+print("Last good count: %d" % start)

Propchange: llvm/trunk/utils/bisect-skip-count
------------------------------------------------------------------------------
    svn:executable = *




More information about the llvm-commits mailing list