c++ - klee execute the Objectfile, the function "sleep()" does not work? -
first, extended klee support multiple threads, , implement functions of pthread.h in klee. now, use llvm-gcc compile c source file test.c, generate objectfile test.o, use klee test.o
execute .o file. function printf
can print strings on screen, function sleep()
not work, program execute fast, not pause. klee web can use uclibc link c lib, when add argument --libc=uclibc
, klee --libc=uclibc test.o
, result wrong , weird, klee not execute test.o, instead execute klee itself!!! how can make function sleep() work?
the c source follow
#define os_globals #include <stdio.h> #include <pthread.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <signal.h> //#include "record_monitor.h" int num; int global; void * fun1(void *arg) { printf("1fun1 num = %d\n",num); printf("fun1 gol = %d\n",global); num = 8; printf("2fun1 num = %d\n",num); sleep(10); printf("over fun1\n"); return 0; } void *fun2(void *arg) { printf("1fun2 num =%d\n",num); global++; num = 5; printf("2fun2 glo = %d\n",global); sleep(6); printf("over fun2\n"); return 0; } int main() { pthread_t npid1,npid2; num = 1; pthread_create(&npid1,null,fun1,null); pthread_create(&npid2,null,fun2,null); sleep(5); printf("1main num = %d\n",num); global = 7; num++; printf("2main num = %d\n",num); pthread_join(npid1,null); pthread_join(npid2,null); return 0; }
Comments
Post a Comment