CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
path_storage.h
Go to the documentation of this file.
1
4
5#ifndef CPROVER_GOTO_SYMEX_PATH_STORAGE_H
6#define CPROVER_GOTO_SYMEX_PATH_STORAGE_H
7
8#include <util/invariant.h>
9
10#include <analyses/dirty.h>
11#include <analyses/local_safe_pointers.h> // IWYU pragma: keep
12
13#include "goto_symex_state.h"
15
16#include <memory>
17
18class cmdlinet;
19class optionst;
20
23{
24public:
26
27private:
28 std::size_t nondet_count = 0;
29};
30
38{
39public:
41 struct patht
42 {
45
47 : equation(e), state(s, &equation)
48 {
49 }
50
51 explicit patht(const patht &other)
52 : equation(other.equation), state(other.state, &equation)
53 {
54 }
55 };
56
57 virtual ~path_storaget() = default;
58
61 {
63 return private_peek();
64 }
65
72 virtual void clear() = 0;
73
75 virtual void push(const patht &) = 0;
76
78 void pop()
79 {
82 }
83
85 virtual std::size_t size() const = 0;
86
88 bool empty() const
89 {
90 return size() == 0;
91 };
92
95
100 std::unordered_map<irep_idt, local_safe_pointerst> safe_pointers;
101
104 std::size_t get_unique_l1_index(const irep_idt &id, std::size_t minimum_index)
105 {
107 }
108
109 std::size_t get_unique_l2_index(const irep_idt &id)
110 {
111 return get_unique_index(l2_indices, id, 1);
112 }
113
117
120 void add_function_loops(const irep_idt &identifier, const goto_programt &body)
121 {
122 auto loop_iter = loop_analysis_map.find(identifier);
123 if(loop_iter == loop_analysis_map.end())
124 {
125 loop_analysis_map[identifier] =
126 std::make_shared<lexical_loopst>(lexical_loopst(body));
127 }
128 }
129
130 inline std::shared_ptr<lexical_loopst>
131 get_loop_analysis(const irep_idt &function_id)
132 {
133 return loop_analysis_map.at(function_id);
134 }
135
136private:
137 std::unordered_map<irep_idt, std::shared_ptr<lexical_loopst>>
139
140 // Derived classes should override these methods, allowing the base class to
141 // enforce preconditions.
142 virtual patht &private_peek() = 0;
143 virtual void private_pop() = 0;
144
145 typedef std::unordered_map<irep_idt, std::size_t> name_index_mapt;
146
147 std::size_t get_unique_index(
149 const irep_idt &id,
150 std::size_t minimum_index)
151 {
152 auto entry = unique_index_map.emplace(id, minimum_index);
153
154 if(!entry.second)
155 entry.first->second = std::max(entry.first->second + 1, minimum_index);
156
157 return entry.first->second;
158 }
159
163};
164
167{
168public:
169 void push(const patht &) override;
170 std::size_t size() const override;
171 void clear() override;
172
173protected:
174 std::list<path_storaget::patht>::iterator last_peeked;
175 std::list<patht> paths;
176
177private:
178 patht &private_peek() override;
179 void private_pop() override;
180};
181
184{
185public:
186 void push(const patht &) override;
187 std::size_t size() const override;
188 void clear() override;
189
190protected:
191 std::list<patht> paths;
192
193private:
194 patht &private_peek() override;
195 void private_pop() override;
196};
197
199std::string show_path_strategies();
200
202bool is_valid_path_strategy(const std::string strategy);
203
206std::unique_ptr<path_storaget> get_path_strategy(const std::string strategy);
207
211 const cmdlinet &,
212 optionst &,
214
215#endif /* CPROVER_GOTO_SYMEX_PATH_STORAGE_H */
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
A generic container class for the GOTO intermediate representation of one function.
Central data structure: state.
Wrapper for dirtyt that permits incremental population, ensuring each function is analysed exactly on...
Definition dirty.h:118
Expression to hold a nondeterministic choice.
Definition std_expr.h:292
FIFO save queue: paths are resumed in the order that they were saved.
void clear() override
Clear all saved paths.
void private_pop() override
patht & private_peek() override
std::list< patht > paths
void push(const patht &) override
Add a path to resume to the storage.
std::size_t size() const override
How many paths does this storage contain?
LIFO save queue: depth-first search, try to finish paths.
std::list< patht > paths
void private_pop() override
std::list< path_storaget::patht >::iterator last_peeked
void push(const patht &) override
Add a path to resume to the storage.
patht & private_peek() override
std::size_t size() const override
How many paths does this storage contain?
void clear() override
Clear all saved paths.
Storage for symbolic execution paths to be resumed later.
std::size_t get_unique_l2_index(const irep_idt &id)
incremental_dirtyt dirty
Local variables are considered 'dirty' if they've had an address taken and therefore may be referred ...
std::size_t get_unique_l1_index(const irep_idt &id, std::size_t minimum_index)
Provide a unique L1 index for a given id, starting from minimum_index.
std::shared_ptr< lexical_loopst > get_loop_analysis(const irep_idt &function_id)
std::unordered_map< irep_idt, std::shared_ptr< lexical_loopst > > loop_analysis_map
virtual void clear()=0
Clear all saved paths.
virtual void private_pop()=0
std::unordered_map< irep_idt, local_safe_pointerst > safe_pointers
Map function identifiers to local_safe_pointerst instances.
virtual void push(const patht &)=0
Add a path to resume to the storage.
std::unordered_map< irep_idt, std::size_t > name_index_mapt
std::size_t get_unique_index(name_index_mapt &unique_index_map, const irep_idt &id, std::size_t minimum_index)
virtual patht & private_peek()=0
void pop()
Remove the next path to resume from the storage.
virtual std::size_t size() const =0
How many paths does this storage contain?
name_index_mapt l1_indices
Storage used by get_unique_index.
virtual ~path_storaget()=default
patht & peek()
Reference to the next path to resume.
void add_function_loops(const irep_idt &identifier, const goto_programt &body)
Generates a loop analysis for the instructions in goto_programt and keys it against function ID.
symex_nondet_generatort build_symex_nondet
Counter for nondet objects, which require unique names.
name_index_mapt l2_indices
bool empty() const
Is this storage empty?
Functor generating fresh nondet symbols.
nondet_symbol_exprt operator()(typet type, source_locationt location)
Inheriting the interface of symex_targett this class represents the SSA form of the input program as ...
The type of an expression, extends irept.
Definition type.h:29
Variables whose address is taken.
Symbolic Execution.
lexical_loops_templatet< const goto_programt, goto_programt::const_targett, goto_programt::target_less_than > lexical_loopst
Local safe pointer analysis.
std::unique_ptr< path_storaget > get_path_strategy(const std::string strategy)
Ensure that is_valid_strategy() returns true for a particular string before calling this function on ...
void parse_path_strategy_options(const cmdlinet &, optionst &, message_handlert &)
add paths and exploration-strategy option, suitable to be invoked from front-ends.
bool is_valid_path_strategy(const std::string strategy)
is there a factory constructor for the named strategy?
std::string show_path_strategies()
suitable for displaying as a front-end help message
#define PRECONDITION(CONDITION)
Definition invariant.h:463
Information saved at a conditional goto to resume execution.
symex_target_equationt equation
patht(const symex_target_equationt &e, const goto_symex_statet &s)
patht(const patht &other)
goto_symex_statet state
Generate Equation using Symbolic Execution.