Ejemplo n.º 1
0
 def determine_result(self, returncode, returnsignal, output, isTimeout):
     res = self.tool.determine_result(returncode, returnsignal, output,
                                      isTimeout)
     dbg('Tool result: {0}'.format(res))
     if res == 'true' and self.tool.name() == 'nidhugg':
         res = 'unknown (bounded)'
     return res
Ejemplo n.º 2
0
def dump_error(bindir, ismem=False):
    abd = abspath(bindir)
    if ismem:
        pth = abspath('{0}/klee-last/test000001.ptr.err'.format(abd))
        if not isfile(pth):
            pth = abspath('{0}/klee-last/test000001.leak.err'.format(abd))
    else:
        pth = abspath('{0}/klee-last/test000001.assert.err'.format(abd))

    if not isfile(pth):
        from symbiotic.utils import dbg
        dbg("Couldn't find the file with error description")
        return

    try:
        f = open(pth, 'r')
        print('\n --- Error trace ---\n')
        for line in f:
            print_stdout(line, print_nl=False)
        print('\n --- ----------- ---')
    except OSError:
        from symbiotic.utils import dbg
        # this dumping is just for convenience,
        # so do not return any error
        dbg('Failed dumping the error')
Ejemplo n.º 3
0
def dump_error(pth):
    if not isfile(pth):
        from symbiotic.utils import dbg
        dbg("Couldn't find the file with error description")
        return

    try:
        f = open(pth, 'r')
        print('\n --- Error trace ---\n')
        for line in f:
            print_stdout(line, print_nl=False)
        print('\n --- ----------- ---')
    except OSError:
        from symbiotic.utils import dbg
        # this dumping is just for convenience,
        # so do not return any error
        dbg('Failed dumping the error')
Ejemplo n.º 4
0
def dump_error(pth):
    if not isfile(pth):
        dbg("Couldn't find the file with error description")
        return

    try:
        f = open(pth, 'r')
        print('\n --- Error trace ---\n')
        for line in f:
            print_stdout(line, print_nl = False)
        print('\n --- Sequence of non-deterministic values [function:file:line:col] ---\n')
        _dumpObjects(pth[:pth.find('.')+1]+'ktest')
        print('\n --- ----------- ---')
    except OSError as e:
        # this dumping is just for convenience,
        # so do not return any error
        dbg('Failed dumping the error: {0}'.format(str(e)))
Ejemplo n.º 5
0
    def actions_before_slicing(self, symbiotic):
        # check whether there are threads in the program
        cmd = [
            'opt', '-q', '-load', 'LLVMsbt.so', '-check-module',
            '-detect-calls=pthread_create', '-o=/dev/null', symbiotic.curfile
        ]
        retval, lines =\
        process_grep(cmd, 'Found call to function')
        if retval == 0:
            if lines:
                #self._has_threads = True
                #self.tool = NidhuggTool(self._options)
                #self.tool.set_environment(self._env, self._options)
                #dbg("Found threads, will use Nidhugg")
                raise SymbioticException('Found threads, giving up')
        else:
            dbg('Checking the module failed!')

        if hasattr(self.tool, 'actions_before_slicing'):
            self.tool.actions_before_slicing(symbiotic)
Ejemplo n.º 6
0
def generate_exec_witness(bindir, sources, opts, saveto = None):
    assert len(sources) == 1 and "Can not generate witnesses for more sources yet"
    if saveto is None:
        saveto = '{0}.exe'.format(sources[:sources.rfind('.')])
    print('Generating executable witness to : {0}'.format(saveto))

    if opts.test_comp:
        pth = get_harness_file(join(opts.testsuite_output))
    else:
        pth = get_harness_file(join(bindir, 'klee-last'))

    from symbiotic.exceptions import SymbioticException
    try:
        from symbiotic.transform import CompileWatch
        flags = ['-D__inline=']
        if opts.property.memsafety():
            flags+=['-fsanitize=address']
        elif opts.property.signedoverflow() or opts.property.undefinedness():
            flags+=['-fsanitize=undefined']
        runcmd(['clang', '-g', pth, sources[0], '-o', saveto] + flags,
               CompileWatch(), 'Generating executable witness failed')
    except SymbioticException as e:
        dbg(str(e))
Ejemplo n.º 7
0
 def actions_before_verification(self, symbiotic):
     if not symbiotic.check_llvmfile(symbiotic.llvmfile):
         dbg('Unsupported call (probably floating handling)')
         from symbiotic.exceptions import SymbioticExceptionalResult as Result
         raise Result('unknown (call to unsupported function)')