[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [csmith-dev] csmith and libc



Hi Timotej,

On 2015-07-28 13:55, Kapus, Timotej wrote:

 Also how would I increase the number of times builtin functions are
called? I am currently running with these flags: --builtins
--builtin-function-prob 100 --no-unions --max-expr-complexity 3
--no-arrays --max-funcs 50 --no-structs --no-pointers
--no-comma-operators --no-embedded-assigns --no-compound-assignment,
but I am still not happy with the density of bultin functions.


I think a small Csmith bug prevented us from producing more builtin functions. Can you apply the patch below and try again? Note that the crucial modification is adding "&& !CGOptions::builtins()". Roughly, it tells csmith to *not* keep choosing safe_math functions if we want to exercise builtins. The other changes are just for increasing the chance of generating function calls. For example, after I applied the patch, I got something below:

$ ./csmith --builtins --builtin-function-prob 100 --max-funcs 50 > 2.c
$ grep "__builtin" ./2.c | wc -l
319

- Yang

diff --git a/src/ExpressionFuncall.cpp b/src/ExpressionFuncall.cpp
index 2f3ae9f..a177ca2 100644
--- a/src/ExpressionFuncall.cpp
+++ b/src/ExpressionFuncall.cpp
@@ -55,10 +55,10 @@
 static bool
 ExpressionFunctionProbability(const CGContext &/*cg_context*/)
 {
-       if (Function::reach_max_functions_cnt()) {
+ if (Function::reach_max_functions_cnt() && !CGOptions::builtins()) {
                return true;
        }
-       return rnd_flipcoin(80);
+       return rnd_flipcoin(5);
 }

 /*
diff --git a/src/FunctionInvocation.cpp b/src/FunctionInvocation.cpp
index 229185a..54b9d2c 100644
--- a/src/FunctionInvocation.cpp
+++ b/src/FunctionInvocation.cpp
@@ -83,7 +83,7 @@ FunctionInvocation::make_random(bool is_std_func,
// If we are looking for a program-defined function, try to find one.
        if (!is_std_func) {
                Function* callee = NULL;
-               if (pure_rnd_flipcoin(50)) {
+               if (pure_rnd_flipcoin(80)) {
callee = Function::choose_func(get_all_functions(), cg_context, type, qfer);
                }
                if (callee != NULL) {