Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to store and rerun execution states during run #182

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
branches: [main, utbot-main]
push:
branches: [main, utbot-main]
branches: [main, utbot-main, testheheh]
workflow_dispatch:
inputs:
warnings_as_errors:
Expand Down
1 change: 1 addition & 0 deletions include/klee/ADT/KTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ unsigned kTest_numBytes(KTest *);

void kTest_free(KTest *);

unsigned getKTestMemoryUsage(KTest *ktest);
#ifdef __cplusplus
}
#endif
Expand Down
19 changes: 19 additions & 0 deletions include/klee/ADT/SeedFromFile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef KLEE_SEED_FROM_FILE_H
#include <string>

class KTest;

namespace klee {

class SeedFromFile {
public:
KTest *ktest;
unsigned maxInstructions;

SeedFromFile() {}
SeedFromFile(std::string _path);
};

} // namespace klee
#define KLEE_SEED_FROM_FILE_H
#endif
3 changes: 2 additions & 1 deletion include/klee/Core/BranchTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
BTYPE(Realloc, 8U) \
BTYPE(Free, 9U) \
BTYPE(GetVal, 10U) \
BMARK(END, 10U)
BTYPE(InitialBranch, 11U) \
BMARK(END, 11U)
/// \endcond

/** @enum BranchType
Expand Down
6 changes: 5 additions & 1 deletion include/klee/Core/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define KLEE_INTERPRETER_H

#include "TerminationTypes.h"
#include "klee/ADT/SeedFromFile.h"
#include "klee/Module/Annotation.h"

#include "klee/Module/SarifReport.h"
Expand Down Expand Up @@ -211,7 +212,7 @@ class Interpreter {

// supply a set of symbolic bindings that will be used as "seeds"
// for the search. use null to reset.
virtual void useSeeds(const std::vector<struct KTest *> *seeds) = 0;
virtual void useSeeds(std::vector<SeedFromFile> seeds) = 0;

virtual void runFunctionAsMain(llvm::Function *f, int argc, char **argv,
char **envp) = 0;
Expand All @@ -237,6 +238,9 @@ class Interpreter {
virtual void getConstraintLog(const ExecutionState &state, std::string &res,
LogType logFormat = STP) = 0;

virtual void getSteppedInstructions(const ExecutionState &state,
unsigned &res) = 0;

virtual bool getSymbolicSolution(const ExecutionState &state, KTest &res) = 0;

virtual void addSARIFReport(const ExecutionState &state) = 0;
Expand Down
1 change: 1 addition & 0 deletions lib/ADT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#===------------------------------------------------------------------------===#
add_library(kleeADT
SparseStorage.cpp
SeedFromFile.cpp
)

llvm_config(kleeADT "${USE_LLVM_SHARED}" support)
Expand Down
14 changes: 14 additions & 0 deletions lib/ADT/SeedFromFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "klee/ADT/SeedFromFile.h"
#include "klee/ADT/KTest.h"

#include <fstream>

using namespace klee;

SeedFromFile::SeedFromFile(std::string _path)
: ktest(kTest_fromFile((_path + "ktest").c_str())) {
std::ifstream seedInfoStream(_path + "seedinfo");
if (seedInfoStream.good()) {
seedInfoStream >> maxInstructions;
}
}
10 changes: 10 additions & 0 deletions lib/Basic/KTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,13 @@ void kTest_free(KTest *bo) {
free(bo->objects);
free(bo);
}

unsigned getKTestMemoryUsage(KTest *ktest) {
size_t size = 0;
for (unsigned i = 0; i < ktest->numObjects; i++) {
size += std::strlen(ktest->objects[i].name) * sizeof(char);
size += ktest->objects[i].numBytes * sizeof(unsigned char);
size += ktest->objects[i].numPointers * sizeof(Pointer);
}
return size;
}
6 changes: 3 additions & 3 deletions lib/Core/ExecutionState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ ExecutionState::ExecutionState(const ExecutionState &state)
coveredNew(state.coveredNew), coveredNewError(state.coveredNewError),
forkDisabled(state.forkDisabled), returnValue(state.returnValue),
gepExprBases(state.gepExprBases), multiplexKF(state.multiplexKF),
prevTargets_(state.prevTargets_), targets_(state.targets_),
prevHistory_(state.prevHistory_), history_(state.history_),
isTargeted_(state.isTargeted_) {
isSeeded(state.isSeeded), prevTargets_(state.prevTargets_),
targets_(state.targets_), prevHistory_(state.prevHistory_),
history_(state.history_), isTargeted_(state.isTargeted_) {
queryMetaData.id = state.id;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/Core/ExecutionState.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ class ExecutionState {
// Temp: to know which multiplex path this state has taken
KFunction *multiplexKF = nullptr;

bool isSeeded = false;

private:
PersistentSet<ref<Target>> prevTargets_;
PersistentSet<ref<Target>> targets_;
Expand Down
Loading
Loading