Skip to content

Commit 9ed7fde

Browse files
author
Remi Delmas
committed
CONTRACTS: cleanup failure and debug output
1 parent 4e6aec2 commit 9ed7fde

9 files changed

+31
-316
lines changed

src/goto-instrument/contracts/dynamic-frames/dfcc.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,6 @@ void dfcct::check_transform_goto_model_preconditions(
126126
const bool apply_loop_contracts,
127127
const std::set<std::string> &to_exclude_from_nondet_static)
128128
{
129-
log.debug() << "harness_id " << harness_id << messaget::eom;
130-
131-
for(const auto &pair : to_check)
132-
{
133-
log.debug() << "to check " << pair.first << "->" << pair.second
134-
<< messaget::eom;
135-
}
136-
137-
for(const auto &pair : to_replace)
138-
{
139-
log.debug() << "to replace " << pair.first << "->" << pair.second
140-
<< messaget::eom;
141-
}
142-
143129
// TODO reactivate this once I understand how entry points work
144130
// Check that the goto_model entry point matches the given harness_id
145131
// if(!config.main.has_value())

src/goto-instrument/contracts/dynamic-frames/dfcc_dsl_contract_functions.cpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,13 @@ const std::size_t dfcc_dsl_contract_functionst::get_nof_frees_targets() const
9595

9696
void dfcc_dsl_contract_functionst::gen_spec_assigns_function()
9797
{
98-
log.debug() << "->dfcc_dsl_contract_functionst::gen_spec_assigns_functions("
99-
<< pure_contract_symbol.name << ")" << messaget::eom;
100-
10198
const auto &spec_function_symbol = utils.clone_and_rename_function(
10299
pure_contract_symbol.name, spec_assigns_function_id, empty_typet());
103100

104101
const auto &spec_function_id = spec_function_symbol.name;
105102

106103
auto &spec_code_type = to_code_type(spec_function_symbol.type);
107104

108-
for(auto &param : spec_code_type.parameters())
109-
{
110-
log.debug()
111-
<< "dfcc_dsl_contract_functionst::gen_spec_assigns_functions: new param "
112-
<< param.get_identifier() << messaget::eom;
113-
}
114-
115105
exprt::operandst lambda_parameters;
116106

117107
if(code_with_contract.return_type().id() != ID_empty)
@@ -151,16 +141,6 @@ void dfcc_dsl_contract_functionst::gen_spec_assigns_function()
151141

152142
goto_model.goto_functions.update();
153143

154-
// debug print the generated body
155-
log.debug() << "->dfcc_dsl_contract_functionst::gen_spec_assigns_functions("
156-
<< pure_contract_symbol.name
157-
<< ") before inlining :" << messaget::eom;
158-
159-
forall_goto_program_instructions(iter, body)
160-
{
161-
body.output_instruction(ns, spec_function_id, log.debug(), *iter);
162-
}
163-
164144
inline_and_check_warnings(spec_function_id);
165145

166146
PRECONDITION_WITH_DIAGNOSTICS(
@@ -169,16 +149,6 @@ void dfcc_dsl_contract_functionst::gen_spec_assigns_function()
169149
"model instrumentation");
170150

171151
goto_model.goto_functions.update();
172-
173-
// debug print the generated body
174-
log.debug() << "->dfcc_dsl_contract_functionst::gen_spec_assigns_functions("
175-
<< pure_contract_symbol.name
176-
<< ") after inlining :" << messaget::eom;
177-
178-
forall_goto_program_instructions(iter, body)
179-
{
180-
body.output_instruction(ns, spec_function_id, log.debug(), *iter);
181-
}
182152
}
183153

184154
void dfcc_dsl_contract_functionst::encode_assignable_target_group(
@@ -208,10 +178,6 @@ void dfcc_dsl_contract_functionst::encode_assignable_target(
208178
const exprt &target,
209179
goto_programt &dest)
210180
{
211-
log.debug() << "->dfcc_dsl_contract_functionst::encode_assignable_target("
212-
<< from_expr_using_mode(ns, language_mode, target) << ")"
213-
<< messaget::eom;
214-
215181
const source_locationt &source_location = target.source_location();
216182

217183
if(can_cast_expr<side_effect_expr_function_callt>(target))
@@ -283,17 +249,10 @@ void dfcc_dsl_contract_functionst::encode_assignable_target(
283249
from_expr_using_mode(ns, language_mode, target),
284250
target.source_location());
285251
}
286-
log.debug() << "<-dfcc_dsl_contract_functionst::encode_assignable_target("
287-
<< from_expr_using_mode(ns, language_mode, target) << ")"
288-
<< messaget::eom;
289252
}
290253

291254
void dfcc_dsl_contract_functionst::gen_spec_frees_function()
292255
{
293-
log.debug()
294-
<< "dfcc_dsl_contract_functionst::create_spec_frees_function_from_contract("
295-
<< pure_contract_symbol.name << ")" << messaget::eom;
296-
297256
// fetch pure contract symbol
298257
const auto &code_with_contract =
299258
to_code_with_contract_type(pure_contract_symbol.type);
@@ -305,13 +264,6 @@ void dfcc_dsl_contract_functionst::gen_spec_frees_function()
305264

306265
auto &spec_code_type = to_code_type(spec_function_symbol.type);
307266

308-
for(auto &param : spec_code_type.parameters())
309-
{
310-
log.debug()
311-
<< "dfcc_dsl_contract_functionst::gen_spec_frees_function: param "
312-
<< param.get_identifier() << messaget::eom;
313-
}
314-
315267
exprt::operandst lambda_parameters;
316268

317269
if(code_with_contract.return_type().id() != ID_empty)
@@ -361,12 +313,6 @@ void dfcc_dsl_contract_functionst::gen_spec_frees_function()
361313
"model instrumentation");
362314

363315
goto_model.goto_functions.update();
364-
365-
// debug print instructions
366-
forall_goto_program_instructions(iter, body)
367-
{
368-
body.output_instruction(ns, spec_function_id, log.debug(), *iter);
369-
}
370316
}
371317

372318
void dfcc_dsl_contract_functionst::inline_and_check_warnings(

src/goto-instrument/contracts/dynamic-frames/dfcc_dsl_contract_handler.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ const symbolt *dfcc_dsl_contract_handlert::get_pure_contract_symbol_ptr(
112112
auto pure_contract_id = "contract::" + id2string(contract_id);
113113
if(!ns.lookup(pure_contract_id, pure_contract_symbol))
114114
{
115-
log.debug() << "contract_symbol: " << contract_symbol.name << messaget::eom;
116-
log.debug() << contract_symbol.type.pretty() << messaget::eom;
117-
log.debug() << "pure_contract_symbol: " << pure_contract_id
118-
<< messaget::eom;
119-
log.debug() << pure_contract_symbol->type.pretty() << messaget::eom;
120-
121115
check_signature_compat(
122116
contract_id,
123117
to_code_type(contract_symbol.type),

src/goto-instrument/contracts/dynamic-frames/dfcc_dsl_wrapper_program.cpp

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,6 @@ void dfcc_dsl_wrapper_programt::add_to_dest(goto_programt &dest)
218218

219219
void dfcc_dsl_wrapper_programt::encode_requires_write_set()
220220
{
221-
log.debug() << "->dfcc_dsl_wrapper_programt::encode_requires_write_set()"
222-
<< messaget::eom;
223-
224221
PRECONDITION(requires_write_set_symbol_opt);
225222
PRECONDITION(addr_of_requires_write_set_symbol_opt);
226223

@@ -326,15 +323,10 @@ void dfcc_dsl_wrapper_programt::encode_requires_write_set()
326323
postamble.add(goto_programt::make_function_call(call));
327324
postamble.add(goto_programt::make_dead(write_set));
328325
}
329-
log.debug() << "<-dfcc_dsl_wrapper_programt::encode_requires_write_set()"
330-
<< messaget::eom;
331326
}
332327

333328
void dfcc_dsl_wrapper_programt::encode_ensures_write_set()
334329
{
335-
log.debug() << "->dfcc_dsl_wrapper_programt::encode_ensures_write_set()"
336-
<< messaget::eom;
337-
338330
PRECONDITION(ensures_write_set_symbol_opt);
339331
PRECONDITION(addr_of_ensures_write_set_symbol_opt);
340332

@@ -451,15 +443,10 @@ void dfcc_dsl_wrapper_programt::encode_ensures_write_set()
451443

452444
// declare write set DEAD
453445
postamble.add(goto_programt::make_dead(write_set));
454-
log.debug() << "<-dfcc_dsl_wrapper_programt::encode_ensures_write_set()"
455-
<< messaget::eom;
456446
}
457447

458448
void dfcc_dsl_wrapper_programt::encode_contract_write_set()
459449
{
460-
log.debug() << "->dfcc_dsl_wrapper_programt::encode_contract_write_set()"
461-
<< messaget::eom;
462-
463450
PRECONDITION(contract_write_set_symbol_opt);
464451

465452
const auto write_set = contract_write_set_symbol_opt->symbol_expr();
@@ -576,15 +563,10 @@ void dfcc_dsl_wrapper_programt::encode_contract_write_set()
576563
postamble.add(goto_programt::make_function_call(call));
577564
postamble.add(goto_programt::make_dead(write_set));
578565
}
579-
log.debug() << "<-dfcc_dsl_wrapper_programt::encode_contract_write_set()"
580-
<< messaget::eom;
581566
}
582567

583568
void dfcc_dsl_wrapper_programt::encode_is_fresh_set()
584569
{
585-
log.debug() << "->dfcc_dsl_wrapper_programt::encode_is_fresh_set()"
586-
<< messaget::eom;
587-
588570
PRECONDITION(is_fresh_set_symbol_opt);
589571
PRECONDITION(addr_of_is_fresh_set_symbol_opt);
590572

@@ -622,15 +604,10 @@ void dfcc_dsl_wrapper_programt::encode_is_fresh_set()
622604

623605
// DEAD instructions in postamble
624606
postamble.add(goto_programt::make_dead(object_set));
625-
626-
log.debug() << "<-dfcc_dsl_wrapper_programt::encode_is_fresh_set()"
627-
<< messaget::eom;
628607
}
629608

630609
void dfcc_dsl_wrapper_programt::encode_requires_clauses()
631610
{
632-
log.debug() << "->dfcc_dsl_wrapper_programt::encode_requires_clauses()"
633-
<< messaget::eom;
634611
// we use this empty requires write set to check for the absence of side
635612
// effects in the requires clauses
636613
PRECONDITION(addr_of_requires_write_set_symbol_opt);
@@ -700,14 +677,10 @@ void dfcc_dsl_wrapper_programt::encode_requires_clauses()
700677

701678
// append resulting program to preconditions section
702679
preconditions.destructive_append(requires_program);
703-
log.debug() << "<-dfcc_dsl_wrapper_programt::encode_requires_clauses()"
704-
<< messaget::eom;
705680
}
706681

707682
void dfcc_dsl_wrapper_programt::encode_ensures_clauses()
708683
{
709-
log.debug() << "->dfcc_dsl_wrapper_programt::encode_ensures_clauses()"
710-
<< messaget::eom;
711684
// we need the contract write set for the freed predicates
712685
PRECONDITION(addr_of_contract_write_set_symbol_opt);
713686
// we need the ensures write set to check for side effects
@@ -799,16 +772,10 @@ void dfcc_dsl_wrapper_programt::encode_ensures_clauses()
799772

800773
// add the ensures program to the postconditions section
801774
postconditions.destructive_append(ensures_program);
802-
log.debug() << "<-dfcc_dsl_wrapper_programt::encode_ensures_clauses()"
803-
<< messaget::eom;
804775
}
805776

806777
void dfcc_dsl_wrapper_programt::encode_requires_contract_clauses()
807778
{
808-
log.debug()
809-
<< "->dfcc_dsl_wrapper_programt::encode_requires_contract_clauses()"
810-
<< messaget::eom;
811-
812779
const auto &requires_contract = contract_code_type.requires_contract();
813780

814781
if(contract_mode == dfcc_contract_modet::CHECK)
@@ -841,17 +808,10 @@ void dfcc_dsl_wrapper_programt::encode_requires_contract_clauses()
841808
preconditions);
842809
}
843810
}
844-
log.debug()
845-
<< "<-dfcc_dsl_wrapper_programt::encode_requires_contract_clauses()"
846-
<< messaget::eom;
847811
}
848812

849813
void dfcc_dsl_wrapper_programt::encode_ensures_contract_clauses()
850814
{
851-
log.debug()
852-
<< "->dfcc_dsl_wrapper_programt::encode_ensures_contract_clauses()"
853-
<< messaget::eom;
854-
855815
const auto &ensures_contract = contract_code_type.ensures_contract();
856816

857817
if(contract_mode == dfcc_contract_modet::CHECK)
@@ -875,9 +835,6 @@ void dfcc_dsl_wrapper_programt::encode_ensures_contract_clauses()
875835
postconditions);
876836
}
877837
}
878-
log.debug()
879-
<< "<-dfcc_dsl_wrapper_programt::encode_ensures_contract_clauses()"
880-
<< messaget::eom;
881838
}
882839

883840
void dfcc_dsl_wrapper_programt::assert_function_pointer_obeys_contract(
@@ -910,11 +867,6 @@ void dfcc_dsl_wrapper_programt::assume_function_pointer_obeys_contract(
910867
const function_pointer_obeys_contract_exprt &expr,
911868
goto_programt &dest)
912869
{
913-
log.debug()
914-
<< "->dfcc_dsl_wrapper_programt::assume_function_pointer_obeys_contract("
915-
<< from_expr_using_mode(ns, contract_symbol.mode, expr) << ")"
916-
<< messaget::eom;
917-
918870
function_pointer_contracts.insert(
919871
expr.contract_symbol_expr().get_identifier());
920872

@@ -930,11 +882,6 @@ void dfcc_dsl_wrapper_programt::assume_function_pointer_obeys_contract(
930882
loc.set_comment(comment.str());
931883
dest.add(goto_programt::make_assignment(
932884
expr.function_pointer(), expr.address_of_contract(), loc));
933-
934-
log.debug()
935-
<< "<-dfcc_dsl_wrapper_programt::assume_function_pointer_obeys_contract("
936-
<< from_expr_using_mode(ns, contract_symbol.mode, expr) << ")"
937-
<< messaget::eom;
938885
}
939886

940887
void dfcc_dsl_wrapper_programt::encode_function_call()
@@ -947,9 +894,6 @@ void dfcc_dsl_wrapper_programt::encode_function_call()
947894

948895
void dfcc_dsl_wrapper_programt::encode_checked_function_call()
949896
{
950-
log.debug() << "->dfcc_dsl_wrapper_programt::encode_checked_function_call("
951-
<< wrapped_symbol.name << ")" << messaget::eom;
952-
953897
PRECONDITION(contract_write_set_symbol_opt);
954898

955899
// build call to the wrapped function
@@ -986,16 +930,10 @@ void dfcc_dsl_wrapper_programt::encode_checked_function_call()
986930
addr_of_contract_write_set_symbol_opt->symbol_expr());
987931

988932
function_call.add(goto_programt::make_function_call(call));
989-
990-
log.debug() << "<-dfcc_dsl_wrapper_programt::encode_checked_function_call()"
991-
<< messaget::eom;
992933
}
993934

994935
void dfcc_dsl_wrapper_programt::encode_havoced_function_call()
995936
{
996-
log.debug() << "->dfcc_dsl_wrapper_programt::encode_havoced_function_call()"
997-
<< messaget::eom;
998-
999937
PRECONDITION(contract_write_set_symbol_opt);
1000938

1001939
// generate local write set and add as parameter to the call
@@ -1134,6 +1072,4 @@ void dfcc_dsl_wrapper_programt::encode_havoced_function_call()
11341072
.symbol_expr(),
11351073
{address_of_contract_write_set, caller_write_set});
11361074
function_call.add(goto_programt::make_function_call(deallocate_call));
1137-
log.debug() << "<-dfcc_dsl_wrapper_programt::encode_havoced_function_call()"
1138-
<< messaget::eom;
11391075
}

0 commit comments

Comments
 (0)