// Did the result correspond to the expected path for the test?
// Did the result correspond to the expected path for the test?
//
//
// [your answer here]
// [your answer here]
/*
No, the returncode was 255 not -1
*/
//
//
// Why not? Confer to shell error codes:
// Why not? Confer to shell error codes:
//
//
// [your answer here]
// [your answer here]
/*
The return codes in bash is only between 0-255. Negative numbers gets mapped to 256 - [The negative number], in our case 256 - 1 = 255 which was our returncode.
*/
//
//
// D) Debugging
// D) Debugging
//
//
...
@@ -153,6 +185,10 @@ int main()
...
@@ -153,6 +185,10 @@ int main()
// What value do you get, and why?
// What value do you get, and why?
//
//
// [your answer here]
// [your answer here]
/*
$1 = 0
We got a zero because we ran the klee test where the input value was zero.
*/
//
//
// Step the code
// Step the code
// > (gdb) next
// > (gdb) next
...
@@ -160,6 +196,9 @@ int main()
...
@@ -160,6 +196,9 @@ int main()
// What path did it take, and why?
// What path did it take, and why?
//
//
// [your answer here]
// [your answer here]
/*
It took the path where x == 0 because this was the test where the input values was zero.
*/
//
//
// Now we can try with another test:
// Now we can try with another test:
//
//
...
@@ -173,6 +212,9 @@ int main()
...
@@ -173,6 +212,9 @@ int main()
// Which path did it take, and why?
// Which path did it take, and why?
//
//
// [your answer here]
// [your answer here]
/*
It took the path where x was a positive number, because this was the test where the input values was 255.
*/
//
//
// And finally:
// And finally:
//
//
...
@@ -181,6 +223,9 @@ int main()
...
@@ -181,6 +223,9 @@ int main()
// Which path did it take, and why?
// Which path did it take, and why?
//
//
// [your answer here]
// [your answer here]
/*
It took the path where x was a negative number, because this was the test where the input values was negative.
*/
//
//
// E) Under the hood.
// E) Under the hood.
//
//
...
@@ -190,6 +235,11 @@ int main()
...
@@ -190,6 +235,11 @@ int main()
//
//
// [your answer here]
// [your answer here]
// (hint, mark memory region as symbolic)
// (hint, mark memory region as symbolic)
/*
I had a hard time finding good resources for this information.
But my best guess is that, as the hint says, klee makes the memory region defined from the &a pointer and the size of the region as symbolic.
This in turn will allow klee to try any bitcode that fits in this memory region.
*/
//
//
// Explain in your own words how
// Explain in your own words how
// `klee_make_symbolic(&a, sizeof(a), "a");`
// `klee_make_symbolic(&a, sizeof(a), "a");`
...
@@ -198,3 +248,6 @@ int main()
...
@@ -198,3 +248,6 @@ int main()
// [your answer here]
// [your answer here]
// (hint, KTEST_FILE points to a concrete assignment
// (hint, KTEST_FILE points to a concrete assignment
// of the memory region)
// of the memory region)
/*
When you replay the testcases klee will replace the functioncall with an assignment of the variable a, corresonding to the testcase.