Skip to content

Commit e8e3ed2

Browse files
committed
Add options to store and rerun execution states during execution
1 parent 24156e1 commit e8e3ed2

File tree

21 files changed

+737
-452
lines changed

21 files changed

+737
-452
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66
branches: [main, utbot-main]
77
push:
8-
branches: [main, utbot-main]
8+
branches: [main, utbot-main, testheheh]
99

1010
# Defaults for building KLEE
1111
env:

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
@@ -13,6 +13,7 @@
1313
#include <cstdio>
1414
#include <cstdlib>
1515
#include <cstring>
16+
#include <fstream>
1617

1718
#define KTEST_VERSION 4
1819
#define KTEST_MAGIC_SIZE 5
@@ -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 += std::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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ ExecutionState::ExecutionState(const ExecutionState &state)
170170
coveredNew(state.coveredNew), coveredNewError(state.coveredNewError),
171171
forkDisabled(state.forkDisabled), returnValue(state.returnValue),
172172
gepExprBases(state.gepExprBases), multiplexKF(state.multiplexKF),
173-
prevTargets_(state.prevTargets_), targets_(state.targets_),
174-
prevHistory_(state.prevHistory_), history_(state.history_),
175-
isTargeted_(state.isTargeted_) {
173+
isSeeded(state.isSeeded), prevTargets_(state.prevTargets_),
174+
targets_(state.targets_), prevHistory_(state.prevHistory_),
175+
history_(state.history_), isTargeted_(state.isTargeted_) {
176176
queryMetaData.id = state.id;
177177
}
178178

lib/Core/ExecutionState.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ class ExecutionState {
421421
// Temp: to know which multiplex path this state has taken
422422
KFunction *multiplexKF = nullptr;
423423

424+
bool isSeeded = false;
425+
424426
private:
425427
PersistentSet<ref<Target>> prevTargets_;
426428
PersistentSet<ref<Target>> targets_;

0 commit comments

Comments
 (0)