Skip to content

Commit 341ca93

Browse files
committed
[feat] Add options to store and rerun execution states during execution
1 parent 400abb9 commit 341ca93

File tree

21 files changed

+238
-950
lines changed

21 files changed

+238
-950
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, testheheh]
8+
branches: [main, utbot-main, testheheh]
99
workflow_dispatch:
1010
inputs:
1111
warnings_as_errors:

include/klee/ADT/KTest.h

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

6767
void kTest_free(KTest *);
6868

69-
unsigned getkTestMemoryUsage(KTest *ktest);
69+
unsigned getKTestMemoryUsage(KTest *ktest);
7070
#ifdef __cplusplus
7171
}
7272
#endif

include/klee/ADT/SeedFromFile.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef KLEE_SEED_FROM_FILE_H
2+
#include <string>
3+
4+
class KTest;
5+
6+
namespace klee {
7+
8+
class SeedFromFile {
9+
public:
10+
KTest *ktest;
11+
unsigned maxInstructions;
12+
13+
SeedFromFile() {}
14+
SeedFromFile(std::string _path);
15+
};
16+
17+
} // namespace klee
18+
#define KLEE_SEED_FROM_FILE_H
19+
#endif

include/klee/Core/Interpreter.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define KLEE_INTERPRETER_H
1111

1212
#include "TerminationTypes.h"
13+
#include "klee/ADT/SeedFromFile.h"
1314
#include "klee/Module/Annotation.h"
1415

1516
#include "klee/Module/SarifReport.h"
@@ -58,11 +59,8 @@ class InterpreterHandler {
5859

5960
virtual void processTestCase(const ExecutionState &state, const char *message,
6061
const char *suffix, bool isError = false) = 0;
61-
virtual ToolJson info() const = 0;
6262

63-
// used for writing .ktest files
64-
virtual int argc() = 0;
65-
virtual char **argv() = 0;
63+
virtual ToolJson info() const = 0;
6664
};
6765

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

213+
// supply a set of symbolic bindings that will be used as "seeds"
214+
// for the search. use null to reset.
215+
virtual void useSeeds(std::vector<SeedFromFile> seeds) = 0;
216+
215217
virtual void runFunctionAsMain(llvm::Function *f, int argc, char **argv,
216218
char **envp) = 0;
217219

@@ -239,7 +241,7 @@ class Interpreter {
239241
virtual void getSteppedInstructions(const ExecutionState &state,
240242
unsigned &res) = 0;
241243

242-
virtual bool getSymbolicSolution(const ExecutionState &state, KTest *res) = 0;
244+
virtual bool getSymbolicSolution(const ExecutionState &state, KTest &res) = 0;
243245

244246
virtual void addSARIFReport(const ExecutionState &state) = 0;
245247

lib/ADT/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#===------------------------------------------------------------------------===#
99
add_library(kleeADT
1010
SparseStorage.cpp
11+
SeedFromFile.cpp
1112
)
1213

1314
llvm_config(kleeADT "${USE_LLVM_SHARED}" support)

lib/ADT/SeedFromFile.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "klee/ADT/SeedFromFile.h"
2+
#include "klee/ADT/KTest.h"
3+
4+
#include <fstream>
5+
6+
using namespace klee;
7+
8+
SeedFromFile::SeedFromFile(std::string _path)
9+
: ktest(kTest_fromFile((_path + "ktest").c_str())) {
10+
std::ifstream seedInfoStream(_path + "seedinfo");
11+
if (seedInfoStream.good()) {
12+
seedInfoStream >> maxInstructions;
13+
}
14+
}

lib/Basic/KTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <cstdio>
1414
#include <cstdlib>
1515
#include <cstring>
16-
#include <fstream>
1716

1817
#define KTEST_VERSION 4
1918
#define KTEST_MAGIC_SIZE 5
@@ -297,7 +296,7 @@ void kTest_free(KTest *bo) {
297296
free(bo);
298297
}
299298

300-
unsigned getkTestMemoryUsage(KTest *ktest) {
299+
unsigned getKTestMemoryUsage(KTest *ktest) {
301300
size_t size = 0;
302301
for (unsigned i = 0; i < ktest->numObjects; i++) {
303302
size += std::strlen(ktest->objects[i].name) * sizeof(char);

0 commit comments

Comments
 (0)