cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
goto_symex_fault_localizer.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Fault Localization for Goto Symex
4
5
Author: Peter Schrammel
6
7
\*******************************************************************/
8
11
12
#include "
goto_symex_fault_localizer.h
"
13
14
#include <
util/ui_message.h
>
15
16
#include <
goto-symex/symex_target_equation.h
>
17
18
#include <
solvers/stack_decision_procedure.h
>
19
20
goto_symex_fault_localizert::goto_symex_fault_localizert
(
21
const
optionst
&
options
,
22
ui_message_handlert
&
ui_message_handler
,
23
const
symex_target_equationt
&
equation
,
24
stack_decision_proceduret
&
solver
)
25
:
options
(
options
),
26
ui_message_handler
(
ui_message_handler
),
27
equation
(
equation
),
28
solver
(
solver
)
29
{
30
}
31
32
fault_location_infot
goto_symex_fault_localizert::
33
operator()
(
const
irep_idt
&failed_property_id)
34
{
35
fault_location_infot
fault_location;
36
localization_pointst
localization_points;
37
const
auto
&failed_step =
38
collect_guards
(failed_property_id, localization_points, fault_location);
39
40
if
(!localization_points.empty())
41
{
42
messaget
log(
ui_message_handler
);
43
log.
status
() <<
"Localizing fault"
<<
messaget::eom
;
44
45
// pick localization method
46
// if(options.get_option("localize-faults-method")=="TBD")
47
localize_linear
(failed_step, localization_points);
48
}
49
50
return
fault_location;
51
}
52
53
const
SSA_stept
&
goto_symex_fault_localizert::collect_guards
(
54
const
irep_idt
&failed_property_id,
55
localization_pointst
&localization_points,
56
fault_location_infot
&fault_location)
57
{
58
for
(
const
auto
&step :
equation
.SSA_steps)
59
{
60
if
(
61
step.is_assignment() &&
62
step.assignment_type ==
symex_targett::assignment_typet::STATE
&&
63
!step.ignore)
64
{
65
exprt
l =
solver
.handle(step.guard_handle);
66
if
(!l.
is_constant
())
67
{
68
auto
emplace_result = fault_location.
scores
.emplace(step.source.pc, 0);
69
localization_points.emplace(l, emplace_result.first);
70
}
71
}
72
else
if
(step.is_assert() && step.property_id == failed_property_id)
73
{
74
return
step;
75
}
76
}
77
UNREACHABLE
;
78
}
79
80
bool
goto_symex_fault_localizert::check
(
81
const
SSA_stept
&failed_step,
82
const
localization_pointst
&localization_points,
83
const
localization_points_valuet
&value)
84
{
85
PRECONDITION
(value.size() == localization_points.size());
86
std::vector<exprt> assumptions;
87
localization_points_valuet::const_iterator v_it = value.begin();
88
for
(
const
auto
&l : localization_points)
89
{
90
if
(v_it->is_true())
91
assumptions.push_back(l.first);
92
else
if
(v_it->is_false())
93
assumptions.push_back(
solver
.handle(
not_exprt
(l.first)));
94
++v_it;
95
}
96
97
// lock the failed assertion
98
assumptions.push_back(
not_exprt
(failed_step.
cond_handle
));
99
100
solver
.push(assumptions);
101
102
return
solver
() !=
decision_proceduret::resultt::D_SATISFIABLE
;
103
}
104
105
void
goto_symex_fault_localizert::update_scores
(
106
const
localization_pointst
&localization_points)
107
{
108
for
(
auto
&l : localization_points)
109
{
110
auto
&score = l.second->second;
111
if
(
solver
.get(l.first) ==
true
)
112
{
113
score++;
114
}
115
else
if
(
solver
.get(l.first) ==
false
&& score > 0)
116
{
117
score--;
118
}
119
}
120
}
121
122
void
goto_symex_fault_localizert::localize_linear
(
123
const
SSA_stept
&failed_step,
124
const
localization_pointst
&localization_points)
125
{
126
localization_points_valuet
v(localization_points.size(),
tvt::unknown
());
127
128
for
(std::size_t i = 0; i < v.size(); ++i)
129
{
130
v[i] =
tvt
(
tvt::tv_enumt::TV_TRUE
);
131
if
(!
check
(failed_step, localization_points, v))
132
update_scores
(localization_points);
133
134
v[i] =
tvt
(
tvt::tv_enumt::TV_FALSE
);
135
if
(!
check
(failed_step, localization_points, v))
136
update_scores
(localization_points);
137
138
v[i] =
tvt::unknown
();
139
}
140
141
// clear assumptions
142
solver
.pop();
143
}
SSA_stept
Single SSA step in the equation.
Definition
ssa_step.h:47
SSA_stept::cond_handle
exprt cond_handle
Definition
ssa_step.h:146
decision_proceduret::resultt::D_SATISFIABLE
@ D_SATISFIABLE
Definition
decision_procedure.h:46
exprt
Base class for all expressions.
Definition
expr.h:57
exprt::is_constant
bool is_constant() const
Return whether the expression is a constant.
Definition
expr.h:213
goto_symex_fault_localizert::ui_message_handler
ui_message_handlert & ui_message_handler
Definition
goto_symex_fault_localizer.h:38
goto_symex_fault_localizert::check
bool check(const SSA_stept &failed_step, const localization_pointst &, const localization_points_valuet &)
Definition
goto_symex_fault_localizer.cpp:80
goto_symex_fault_localizert::localization_pointst
std::map< exprt, fault_location_infot::score_mapt::iterator > localization_pointst
A localization point is a goto instruction that is potentially at fault.
Definition
goto_symex_fault_localizer.h:44
goto_symex_fault_localizert::goto_symex_fault_localizert
goto_symex_fault_localizert(const optionst &options, ui_message_handlert &ui_message_handler, const symex_target_equationt &equation, stack_decision_proceduret &solver)
Definition
goto_symex_fault_localizer.cpp:20
goto_symex_fault_localizert::operator()
fault_location_infot operator()(const irep_idt &failed_property_id)
Definition
goto_symex_fault_localizer.cpp:33
goto_symex_fault_localizert::collect_guards
const SSA_stept & collect_guards(const irep_idt &failed_property_id, localization_pointst &localization_points, fault_location_infot &fault_location)
Collects the guards as localization_points up to failed_property_id and initializes fault_location_in...
Definition
goto_symex_fault_localizer.cpp:53
goto_symex_fault_localizert::solver
stack_decision_proceduret & solver
Definition
goto_symex_fault_localizer.h:40
goto_symex_fault_localizert::update_scores
void update_scores(const localization_pointst &)
Definition
goto_symex_fault_localizer.cpp:105
goto_symex_fault_localizert::localize_linear
void localize_linear(const SSA_stept &failed_step, const localization_pointst &)
Definition
goto_symex_fault_localizer.cpp:122
goto_symex_fault_localizert::equation
const symex_target_equationt & equation
Definition
goto_symex_fault_localizer.h:39
goto_symex_fault_localizert::localization_points_valuet
std::vector< tvt > localization_points_valuet
Definition
goto_symex_fault_localizer.h:55
goto_symex_fault_localizert::options
const optionst & options
Definition
goto_symex_fault_localizer.h:37
messaget
Class that provides messages with a built-in verbosity 'level'.
Definition
message.h:154
messaget::eom
static eomt eom
Definition
message.h:289
messaget::status
mstreamt & status() const
Definition
message.h:406
not_exprt
Boolean negation.
Definition
std_expr.h:2378
optionst
Definition
options.h:23
stack_decision_proceduret
Definition
stack_decision_procedure.h:58
symex_target_equationt
Inheriting the interface of symex_targett this class represents the SSA form of the input program as ...
Definition
symex_target_equation.h:34
symex_targett::assignment_typet::STATE
@ STATE
Definition
symex_target.h:70
tvt
Definition
threeval.h:20
tvt::unknown
static tvt unknown()
Definition
threeval.h:33
tvt::tv_enumt::TV_TRUE
@ TV_TRUE
Definition
threeval.h:23
tvt::tv_enumt::TV_FALSE
@ TV_FALSE
Definition
threeval.h:23
ui_message_handlert
Definition
ui_message.h:22
goto_symex_fault_localizer.h
Fault Localization for Goto Symex.
UNREACHABLE
#define UNREACHABLE
This should be used to mark dead code.
Definition
invariant.h:525
PRECONDITION
#define PRECONDITION(CONDITION)
Definition
invariant.h:463
stack_decision_procedure.h
Decision procedure with incremental solving with contexts and assumptions.
fault_location_infot
Definition
fault_localization_provider.h:23
fault_location_infot::scores
score_mapt scores
Definition
fault_localization_provider.h:29
symex_target_equation.h
Generate Equation using Symbolic Execution.
ui_message.h
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
goto-checker
goto_symex_fault_localizer.cpp
Generated by
1.17.0