Skip to content

Commit e699dd6

Browse files
committed
Add options to store and rerun execution states during execution
1 parent 78f5095 commit e699dd6

20 files changed

+729
-450
lines changed

include/klee/ADT/KTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ unsigned kTest_numBytes(KTest *);
6666

6767
void kTest_free(KTest *);
6868

69+
unsigned getkTestMemoryUsage(KTest *ktest);
6970
#ifdef __cplusplus
7071
}
7172
#endif

include/klee/Core/BranchTypes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
BTYPE(Realloc, 8U) \
2626
BTYPE(Free, 9U) \
2727
BTYPE(GetVal, 10U) \
28-
BMARK(END, 10U)
28+
BTYPE(InitialBranch, 11U) \
29+
BMARK(END, 11U)
2930
/// \endcond
3031

3132
/** @enum BranchType

include/klee/Core/Interpreter.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ class InterpreterHandler {
5858

5959
virtual void processTestCase(const ExecutionState &state, const char *message,
6060
const char *suffix, bool isError = false) = 0;
61-
6261
virtual ToolJson info() const = 0;
62+
63+
// used for writing .ktest files
64+
virtual int argc() = 0;
65+
virtual char **argv() = 0;
6366
};
6467

6568
/// [File][Line][Column] -> Opcode
@@ -209,10 +212,6 @@ class Interpreter {
209212
// a user specified path. use null to reset.
210213
virtual void setReplayPath(const std::vector<bool> *path) = 0;
211214

212-
// supply a set of symbolic bindings that will be used as "seeds"
213-
// for the search. use null to reset.
214-
virtual void useSeeds(const std::vector<struct KTest *> *seeds) = 0;
215-
216215
virtual void runFunctionAsMain(llvm::Function *f, int argc, char **argv,
217216
char **envp) = 0;
218217

@@ -237,7 +236,10 @@ class Interpreter {
237236
virtual void getConstraintLog(const ExecutionState &state, std::string &res,
238237
LogType logFormat = STP) = 0;
239238

240-
virtual bool getSymbolicSolution(const ExecutionState &state, KTest &res) = 0;
239+
virtual void getSteppedInstructions(const ExecutionState &state,
240+
unsigned &res) = 0;
241+
242+
virtual bool getSymbolicSolution(const ExecutionState &state, KTest *res) = 0;
241243

242244
virtual void addSARIFReport(const ExecutionState &state) = 0;
243245

lib/Basic/KTest.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "klee/ADT/KTest.h"
1111

12+
#include <fstream>
1213
#include <stdint.h>
1314
#include <stdio.h>
1415
#include <stdlib.h>
@@ -295,3 +296,13 @@ void kTest_free(KTest *bo) {
295296
free(bo->objects);
296297
free(bo);
297298
}
299+
300+
unsigned getkTestMemoryUsage(KTest *ktest) {
301+
size_t size = 0;
302+
for (unsigned i = 0; i < ktest->numObjects; i++) {
303+
size += strlen(ktest->objects[i].name) * sizeof(char);
304+
size += ktest->objects[i].numBytes * sizeof(unsigned char);
305+
size += ktest->objects[i].numPointers * sizeof(Pointer);
306+
}
307+
return size;
308+
}

lib/Core/ExecutionState.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ ExecutionState::ExecutionState(const ExecutionState &state)
178178
gepExprBases(state.gepExprBases), multiplexKF(state.multiplexKF),
179179
prevTargets_(state.prevTargets_), targets_(state.targets_),
180180
prevHistory_(state.prevHistory_), history_(state.history_),
181-
isTargeted_(state.isTargeted_) {
181+
isTargeted_(state.isTargeted_), isSeeded(state.isSeeded) {
182182
queryMetaData.id = state.id;
183183
}
184184

lib/Core/ExecutionState.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ class ExecutionState {
300300
public:
301301
using stack_ty = ExecutionStack;
302302

303+
bool isSeeded = false;
303304
// Execution - Control Flow specific
304305

305306
/// @brief Pointer to initial instruction

0 commit comments

Comments
 (0)