Exemplo n.º 1
0
 def _get_preamble(self):
     preamble = ''
     preamble += "struct _IO_FILE;\ntypedef struct _IO_FILE FILE;\n"
     preamble += "extern struct _IO_FILE *stdin;\n"
     preamble += "extern struct _IO_FILE *stderr;\n"
     # preamble += "typedef long unsigned int size_t;\n"
     # preamble += "extern void abort (void) __attribute__ ((__nothrow__ , __leaf__))\n"
     # preamble += "    __attribute__ ((__noreturn__));\n"
     # preamble += "extern void exit (int __status) __attribute__ ((__nothrow__ , __leaf__))\n"
     # preamble += "     __attribute__ ((__noreturn__));\n"
     # preamble += "extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream);\n"
     # preamble += "extern int sscanf (const char *__restrict __s,\n"
     # preamble += "    const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));\n"
     # preamble += "extern size_t strlen (const char *__s)\n"
     # preamble += "    __attribute__ ((__nothrow__ , __leaf__))\n"
     # preamble += "    __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\n"
     # preamble += "extern int fprintf (FILE *__restrict __stream,\n"
     # preamble += "    const char *__restrict __format, ...);\n"
     # preamble += "extern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__))\n"
     # preamble += "    __attribute__ ((__malloc__));\n"
     # preamble += "\n"
     preamble += utils.get_assume_method() + "\n"
     preamble = preamble.encode()
     preamble += self._get_vector_read_method()
     return preamble
Exemplo n.º 2
0
 def _get_preamble(self):
     preamble = ''
     preamble += utils.EXTERNAL_DECLARATIONS
     preamble += "\n"
     preamble += utils.get_assume_method() + "\n"
     preamble = preamble.encode()
     preamble += self._get_vector_read_method()
     return preamble
Exemplo n.º 3
0
 def prepare0(self, filecontent):
     content = filecontent
     content = utils.rewrite_cproblems(content)
     nondet_methods_used = utils.get_nondet_methods()
     content += '\n'
     content += 'struct _IO_FILE;\ntypedef struct _IO_FILE FILE;\n'
     content += "extern struct _IO_FILE *stdin;\n"
     content += "extern struct _IO_FILE *stderr;\n"
     content += self._get_error_method_dummy()
     content += utils.get_assume_method()
     return self.prepare(content, nondet_methods_used)
Exemplo n.º 4
0
 def prepare(self, filecontent, nondet_methods_used, error_method=None):
     content = filecontent
     content += '\n'
     content += utils.EXTERNAL_DECLARATIONS
     content += '\n'
     content += utils.get_assume_method()
     if error_method:
         content += utils.get_error_method_definition(error_method)
     for method in nondet_methods_used:
         # append method definition at end of file content
         nondet_method_definition = self._get_nondet_method_definition(
             method['name'], method['type'], method['params'])
         content += nondet_method_definition
     return content
Exemplo n.º 5
0
    def prepare(self, filecontent, nondet_methods_used, error_method=None):
        content = filecontent
        content += '\n'
        content += utils.EXTERNAL_DECLARATIONS
        content += '\n'
        content += utils.get_assume_method()
        content += '\n'
        if error_method:
            content += self._get_error_method_definition(error_method)

        # FShell ignores methods starting with 'nondet' and '__VERIFIER_nondet'.
        # => rename them so that they are analyzed correctly
        content = content.replace("nondet", "_nondet")

        return content