Skip to content

Commit 545bff8

Browse files
committed
Add clear() to path exploration worklist
Subclasses of path_storaget are now required to implement a clear() method. This is so that if we terminate path exploration early, the worklist can be cleared. This commit facilitates writing tests that ensure that the worklist is empty iff symbolic execution has finished; this should happen naturally if symex runs its course over the entire program, but might not happen if we terminate symex early. This commit is in preparation for a future commit that makes the --stop-on-fail flag terminate symbolic execution early.
1 parent 95d8d0f commit 545bff8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/goto-symex/path_storage.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ std::size_t path_lifot::size() const
4343
return paths.size();
4444
}
4545

46+
void path_lifot::clear()
47+
{
48+
paths.clear();
49+
}
50+
4651
// _____________________________________________________________________________
4752
// path_fifot
4853

@@ -69,6 +74,11 @@ std::size_t path_fifot::size() const
6974
return paths.size();
7075
}
7176

77+
void path_fifot::clear()
78+
{
79+
paths.clear();
80+
}
81+
7282
// _____________________________________________________________________________
7383
// path_strategy_choosert
7484

src/goto-symex/path_storage.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ class path_storaget
5050
return private_peek();
5151
}
5252

53+
/// \brief Clear all saved paths
54+
///
55+
/// This is typically used because we want to terminate symbolic execution
56+
/// early. It doesn't matter too much in terms of memory usage since CBMC
57+
/// typically exits soon after we do that, however it's nice to have tests
58+
/// that check that the worklist is always empty when symex finishes.
59+
virtual void clear() = 0;
60+
5361
/// \brief Add paths to resume to the storage
5462
///
5563
/// Symbolic execution is suspended when we reach a conditional goto
@@ -90,6 +98,7 @@ class path_lifot : public path_storaget
9098
public:
9199
void push(const patht &, const patht &) override;
92100
std::size_t size() const override;
101+
void clear() override;
93102

94103
protected:
95104
std::list<path_storaget::patht>::iterator last_peeked;
@@ -106,6 +115,7 @@ class path_fifot : public path_storaget
106115
public:
107116
void push(const patht &, const patht &) override;
108117
std::size_t size() const override;
118+
void clear() override;
109119

110120
protected:
111121
std::list<patht> paths;

0 commit comments

Comments
 (0)