def reduce_timeout_with_windbg(target_cmd, timeout=_common.DEFAULT_TIMEOUT, init_wait=None,
                               symbols=None, env=None, callback=None, callback_args=None):
    """
    Uses a super-sekrit algorithm to minimize a command which results
    in TIMEOUT classifications using nothing but WinDBG and raw nerve.
    It returns a :class:`FuzzResult`.

    Note: A timeout limit of less than 30 seconds may not produce
    accurate results.

    TODO: Add support for callback

    Availability: Windows.
    """
    if callback is not None:
        #TODO: Add support for callback
        raise RuntimeError("callback support not implemented")
    if timeout <= 0:
        raise ValueError("timeout must be greater than zero")

    if init_wait is None:
        init_wait = timeout / 4

    if env is None:
        env = dict(os.environ)
    env["LIBC_FATAL_STDERR_"] = "1"
    if symbols is not None:
        env["_NT_ALT_SYMBOL_PATH"] = symbols
    elif target_cmd:
        env["_NT_ALT_SYMBOL_PATH"] = os.path.abspath(os.path.dirname(target_cmd[0]))
    dbg_script = os.path.join(_common.PATH_DBG, "scripts", "WinDBGTrace.py")
    timeout_time = time.time() + init_wait
    cdb_cmd = [TOOL_CDB, "-x", "-y",
               "SRV*c:\\websymbols*http://msdl.microsoft.com/download/symbols",
               "-c", ".load pykd.pyd;g;!py %s -t %d -v;q" % (dbg_script, timeout)]
    gflags_args = _common._disable_gflags(target_cmd[0]) # we want to run as quickly as possible
    with tempfile.TemporaryFile(mode="w+t") as f:
        f.write("Timeout: %0.2f\n" % (timeout))
        if timeout < 30:
            f.write("A timeout less than 30 seconds may not produce accurate results\n")
        f.write("Init wait: %0.2f\n" % (init_wait))
        p = subprocess.Popen(cdb_cmd + target_cmd, stderr=f, stdout=f, env=env,
                             stdin=subprocess.PIPE, creationflags=_common.POPEN_FLAGS)
        kill_debugger = False
        while p.poll() is None:
            if time.time() > timeout_time:
                if not kill_debugger:
                    timeout_time = time.time() + (timeout * 5)
                    kill_debugger = True
                    try:
                        os.kill(p.pid, signal.CTRL_C_EVENT)
                    except OSError:
                        pass
                else:
                    with open(os.devnull, "w") as fp:
                        subprocess.call(["taskkill", "/pid", str(p.pid), "/f"],
                                        stdout=fp, stderr=fp)
                    p.wait()
            time.sleep(0.5) # no hurry, less cpu hogging is better

        f.seek(0, os.SEEK_SET)
        output = []
        for line in f.readlines():
            if ["Breakpoint 0 hit", "Breakpoint 1 hit"] not in line.strip():
                output.append(line)
    if gflags_args is not None:
        _common._set_gflags(target_cmd[0], **gflags_args)
    output = ''.join(output)
    has_tb = output.find("Traceback (most recent call last):")
    if has_tb != -1:
        raise RuntimeError("CDB Python Failure\n%s\n%s" % ("-"*80, output[has_tb:]))
    call_stack = _common.process_exploitable_output(output)[0]
    if not call_stack:
        return _common.FuzzResult(text=output)
    return _common.FuzzResult(classification=_common.TIMEOUT, text=output, backtrace=call_stack)
dataset/ETHPy150Open blackberry/ALF/alf/debug/_cdb.py/reduce_timeout_with_windbg/swapped operands of `not in`