Skip to content

Commit fef1c5f

Browse files
Correction in debug model
This should take a generator argument to find char arrays used in the program. The previous version was not working correctly. This requieres adding a getter in the string_constraint_generator class for arrays_of_pointers.
1 parent 28590fe commit fef1c5f

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

src/solvers/refinement/string_constraint_generator.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,9 @@ class string_constraint_generatort final
8080

8181
symbol_exprt fresh_exist_index(const irep_idt &prefix, const typet &type);
8282

83-
void debug_arrays_of_pointers(std::ostream &out)
83+
const std::map<exprt, array_string_exprt> &get_arrays_of_pointers() const
8484
{
85-
out << "arrays_of_pointers:" << std::endl;
86-
for(auto pair : arrays_of_pointers_)
87-
{
88-
out << " * " << from_expr(m_ns, "", pair.first) << "\t--> "
89-
<< from_expr(m_ns, "", pair.second) << " : "
90-
<< from_type(m_ns, "", pair.second.type()) << std::endl;
91-
}
85+
return arrays_of_pointers_;
9286
}
9387

9488
exprt get_length_of_string_array(const array_string_exprt &s) const;

src/solvers/refinement/string_refinement.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ static exprt get_char_array_in_model(
821821
/// Display part of the current model by mapping the variables created by the
822822
/// solver to constant expressions given by the current model
823823
void debug_model(
824-
const union_find_replacet &symbol_resolve,
824+
const string_constraint_generatort &generator,
825825
messaget::mstreamt &stream,
826826
const namespacet &ns,
827827
const std::size_t max_string_length,
@@ -830,19 +830,18 @@ void debug_model(
830830
const std::vector<symbol_exprt> &index_symbols)
831831
{
832832
static const std::string indent(" ");
833-
std::set<array_string_exprt> char_array_in_axioms;
834-
#if 0
835-
generator.debug_arrays_of_pointers(stream);
836-
#endif
837-
for(const auto &pair : symbol_resolve.to_vector())
838-
char_array_in_axioms.insert(to_array_string_expr(pair.first));
839833

840-
for(const auto &arr : char_array_in_axioms)
834+
stream << "debug_model:" << '\n';
835+
for(const auto &pointer_array : generator.get_arrays_of_pointers())
841836
{
837+
const auto arr = pointer_array.second;
842838
const exprt model =
843839
get_char_array_in_model(super_get, ns, max_string_length, stream, arr);
844840

845-
stream << "- " << from_expr(ns, "", arr) << ": " << from_expr(ns, "", model)
841+
stream << "- " << from_expr(ns, "", arr) << ":\n"
842+
<< indent << "- pointer: " << from_expr(ns, "", pointer_array.first)
843+
<< "\n"
844+
<< indent << "- model: " << from_expr(ns, "", model)
846845
<< messaget::eom;
847846
}
848847

@@ -1221,6 +1220,7 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
12211220

12221221
#ifdef DEBUG
12231222
debug_model(
1223+
generator,
12241224
stream,
12251225
ns,
12261226
max_string_length,

0 commit comments

Comments
 (0)