ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
symex_target.h
Go to the documentation of this file.
1#ifndef CPROVER_GOTO_SYMEX_SYMEX_TARGET_H
2#define CPROVER_GOTO_SYMEX_SYMEX_TARGET_H
3
5#include <util/irep/expr.h>
6#include <irep2/irep2_guard.h>
7#include <irep2/irep2.h>
9#include <vector>
10
11class stack_framet;
12
14{
15public:
16 virtual ~symex_targett() = default;
17
18 // The kind of an SSA step, and of the counterexample step built from it.
29
30 struct sourcet
31 {
32 unsigned thread_nr;
35 bool is_set;
36
37 sourcet() : thread_nr(0), prog(nullptr), is_set(false)
38 {
39 }
40
42 : thread_nr(0), pc(_pc), prog(_prog), is_set(true)
43 {
44 is_set = true;
45 }
46 };
47
48 // write to a variable - lhs must be a symbol
49 virtual void assignment(
50 const expr2tc &guard,
51 const expr2tc &lhs,
52 const expr2tc &original_lhs,
53 const expr2tc &rhs,
54 const expr2tc &original_rhs,
55 const sourcet &source,
56 std::vector<stack_framet> stack_trace,
57 const bool hidden,
58 unsigned loop_number) = 0;
59
60 // record output
61 virtual void output(
62 const expr2tc &guard,
63 const sourcet &source,
64 const std::string &fmt,
65 const std::list<expr2tc> &args) = 0;
66
67 virtual void branching(
68 const expr2tc &guard,
69 const expr2tc &cond,
70 const sourcet &source,
71 const bool hidden,
72 unsigned loop_number) = 0;
73 // record an assumption
74 virtual void assumption(
75 const expr2tc &guard,
76 const expr2tc &cond,
77 const sourcet &source,
78 unsigned loop_number) = 0;
79
80 // record an assertion
84 virtual void assertion(
85 const expr2tc &guard,
86 const expr2tc &cond,
87 const expr2tc &cond_neg,
88 const std::string &msg,
89 std::vector<stack_framet> stack_trace,
90 const sourcet &source,
91 unsigned loop_number) = 0;
92
93 // Renumber the pointer object of a given symbol
94 virtual void renumber(
95 const expr2tc &guard,
96 const expr2tc &symbol,
97 const expr2tc &size,
98 const sourcet &source) = 0;
99
113 expr2tc &expr,
114 bool keep_local_variables) const = 0;
115
116 // Abstract method, with the purpose of duplicating a symex_targett from the
117 // subclass.
118 virtual std::shared_ptr<symex_targett> clone() const = 0;
119
120 virtual void push_ctx() = 0;
121 virtual void pop_ctx() = 0;
122};
123
125{
126public:
128 : function(func), _src(__src), src(&_src)
129 {
130 }
131 stack_framet(const irep_idt &func) : function(func), src(nullptr)
132 {
133 }
134
137 {
138 *this = ref;
139 if (src != nullptr)
140 src = &_src;
141 }
142
143 bool _cmp(const stack_framet &ref) const
144 {
145 if (function != ref.function)
146 return false;
147 if (src == nullptr && ref.src == src)
148 return true;
149 if (src == nullptr || ref.src == nullptr)
150 return false;
151
152 return src->pc->location_number == ref.src->pc->location_number;
153 }
154
158};
159
160bool operator<(
161 const symex_targett::sourcet &a,
162 const symex_targett::sourcet &b);
163
164// Can't remember how to get address of operator== defined inside class
165inline bool operator==(const stack_framet &a, const stack_framet &b)
166{
167 return a._cmp(b);
168}
169
170#endif
A generic container class for a control flow graph for one function, in the form of a goto-program.
Definition goto_program.h:63
instructionst::const_iterator const_targett
Definition goto_program.h:591
Definition irep_idt.h:12
Definition symex_target.h:125
irep_idt function
Definition symex_target.h:155
stack_framet(const stack_framet &ref)
Definition symex_target.h:136
bool _cmp(const stack_framet &ref) const
Definition symex_target.h:143
const symex_targett::sourcet * src
Definition symex_target.h:157
symex_targett::sourcet _src
Definition symex_target.h:156
stack_framet & operator=(const stack_framet &)=default
stack_framet(const irep_idt &func)
Definition symex_target.h:131
stack_framet(const irep_idt &func, const symex_targett::sourcet &__src)
Definition symex_target.h:127
Definition symex_target.h:14
virtual std::shared_ptr< symex_targett > clone() const =0
virtual void renumber(const expr2tc &guard, const expr2tc &symbol, const expr2tc &size, const sourcet &source)=0
virtual void assertion(const expr2tc &guard, const expr2tc &cond, const expr2tc &cond_neg, const std::string &msg, std::vector< stack_framet > stack_trace, const sourcet &source, unsigned loop_number)=0
cond_neg is cond with the claim negated under the same guards, so a probe can ask whether the claim h...
step_typet
Definition symex_target.h:20
@ OUTPUT
Definition symex_target.h:24
@ RENUMBER
Definition symex_target.h:26
@ ASSERT
Definition symex_target.h:23
@ SKIP
Definition symex_target.h:25
@ BREANCHING
Definition symex_target.h:27
@ ASSIGNMENT
Definition symex_target.h:21
@ ASSUME
Definition symex_target.h:22
virtual void output(const expr2tc &guard, const sourcet &source, const std::string &fmt, const std::list< expr2tc > &args)=0
virtual void branching(const expr2tc &guard, const expr2tc &cond, const sourcet &source, const bool hidden, unsigned loop_number)=0
virtual void assumption(const expr2tc &guard, const expr2tc &cond, const sourcet &source, unsigned loop_number)=0
virtual void assignment(const expr2tc &guard, const expr2tc &lhs, const expr2tc &original_lhs, const expr2tc &rhs, const expr2tc &original_rhs, const sourcet &source, std::vector< stack_framet > stack_trace, const bool hidden, unsigned loop_number)=0
virtual void reconstruct_symbolic_expression(expr2tc &expr, bool keep_local_variables) const =0
Replaces trace symbols from expression with their values.
virtual void pop_ctx()=0
virtual ~symex_targett()=default
virtual void push_ctx()=0
pthread_cond_t cond
Definition cuda.h:50
Classes and definitions for non-stringy internal representation.
irep_container< expr2t > expr2tc
Definition irep2.h:431
Definition format.h:30
#define true
Definition stdbool.h:11
#define false
Definition stdbool.h:10
Definition symex_target.h:31
unsigned thread_nr
Definition symex_target.h:32
sourcet(goto_programt::const_targett _pc, const goto_programt *_prog)
Definition symex_target.h:41
const goto_programt * prog
Definition symex_target.h:34
sourcet()
Definition symex_target.h:37
bool is_set
Definition symex_target.h:35
goto_programt::const_targett pc
Definition symex_target.h:33
bool operator==(const stack_framet &a, const stack_framet &b)
Definition symex_target.h:165
bool operator<(const symex_targett::sourcet &a, const symex_targett::sourcet &b)
Definition symex_target.cpp:3