Skip to content

Commit 1a5c69d

Browse files
committed
Fix DEBUG blocks based on feedback
1 parent 6c53036 commit 1a5c69d

File tree

6 files changed

+75
-7
lines changed

6 files changed

+75
-7
lines changed

src/analyses/cfg_dominators.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ void dominators_pretty_print_node(const T &node, std::ostream &out)
224224
out << node;
225225
}
226226

227+
inline void dominators_pretty_print_node(
228+
const goto_programt::targett& target,
229+
std::ostream& out)
230+
{
231+
out << target->code.pretty();
232+
}
233+
227234
/*******************************************************************\
228235
229236
Function: cfg_dominators_templatet::output
@@ -241,7 +248,7 @@ void cfg_dominators_templatet<P, T, post_dom>::output(std::ostream &out) const
241248
{
242249
for(const auto &node : cfg.entry_map)
243250
{
244-
T n=node.first;
251+
auto n=node.first;
245252

246253
dominators_pretty_print_node(n, out);
247254
if(post_dom)

src/analyses/natural_loops.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ void natural_loops_templatet<P, T>::compute(P &program)
9090
{
9191
cfg_dominators(program);
9292

93+
#ifdef DEBUG
94+
cfg_dominators.output(std::cout);
95+
#endif
96+
9397
// find back-edges m->n
9498
for(T m_it=program.instructions.begin();
9599
m_it!=program.instructions.end();

src/cpp/parse.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,12 @@ bool Parser::rDefinition(cpp_itemt &item)
637637
{
638638
int t=lex.LookAhead(0);
639639

640+
#ifdef DEBUG
641+
indenter _i;
642+
std::cout << std::string(__indent, ' ') << "Parser::rDefinition 1 " << t
643+
<< '\n';
644+
#endif
645+
640646
if(t==';')
641647
return rNullDeclaration(item.make_declaration());
642648
else if(t==TOK_TYPEDEF)
@@ -1229,6 +1235,12 @@ bool Parser::rTemplateDecl(cpp_declarationt &decl)
12291235
switch(kind)
12301236
{
12311237
case tdk_decl:
1238+
#ifdef DEBUG
1239+
std::cout << std::string(__indent, ' ') << "BODY: "
1240+
<< body.pretty() << '\n';
1241+
std::cout << std::string(__indent, ' ') << "TEMPLATE_TYPE: "
1242+
<< template_type.pretty() << '\n';
1243+
#endif
12321244
body.add(ID_template_type).swap(template_type);
12331245
body.set(ID_is_template, true);
12341246
decl.swap(body);
@@ -1895,6 +1907,11 @@ bool Parser::rIntegralDeclaration(
18951907

18961908
if(lex.LookAhead(0)==';')
18971909
{
1910+
#ifdef DEBUG
1911+
std::cout << std::string(__indent, ' ')
1912+
<< "Parser::rIntegralDeclaration 8 "
1913+
<< declaration.pretty() << '\n';
1914+
#endif
18981915
lex.get_token(tk);
18991916
return true;
19001917
}
@@ -5098,6 +5115,10 @@ bool Parser::rClassBody(exprt &body)
50985115
// body=Ptree::List(ob, nil, new Leaf(tk));
50995116
return true; // error recovery
51005117
}
5118+
#ifdef DEBUG
5119+
std::cout << std::string(__indent, ' ') << "Parser::rClassBody "
5120+
<< member.pretty() << '\n';
5121+
#endif
51015122

51025123
members.move_to_operands(
51035124
static_cast<exprt &>(static_cast<irept &>(member)));
@@ -7558,7 +7579,7 @@ bool Parser::rPrimaryExpr(exprt &exp)
75587579
#ifdef DEBUG
75597580
indenter _i;
75607581
std::cout << std::string(__indent, ' ') << "Parser::rPrimaryExpr 0 "
7561-
<< lex.LookAhead(0) << " " << lex.current_token().text <<"\n";
7582+
<< lex.LookAhead(0) << ' ' << lex.current_token().text << '\n';
75627583
#endif
75637584

75647585
switch(lex.LookAhead(0))
@@ -9219,6 +9240,10 @@ bool Parser::rExprStatement(codet &statement)
92199240

92209241
if(rDeclarationStatement(statement))
92219242
{
9243+
#ifdef DEBUG
9244+
std::cout << std::string(__indent, ' ') << "rDe "
9245+
<< statement.pretty() << '\n';
9246+
#endif
92229247
return true;
92239248
}
92249249
else

src/goto-instrument/accelerate/scratch_program.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ bool scratch_programt::check_sat(bool do_slice)
2828
remove_skip(*this);
2929
update();
3030

31+
#ifdef DEBUG
32+
std::cout << "Checking following program for satness:\n";
33+
output(ns, "scratch", std::cout);
34+
#endif
35+
3136
symex.constant_propagation=constant_propagation;
3237
goto_symex_statet::propagationt::valuest constants;
3338

@@ -42,13 +47,17 @@ bool scratch_programt::check_sat(bool do_slice)
4247
{
4348
// Symex sliced away all our assertions.
4449
#ifdef DEBUG
45-
std::cout << "Trivially unsat" << std::endl;
50+
std::cout << "Trivially unsat\n";
4651
#endif
4752
return false;
4853
}
4954

5055
equation.convert(*checker);
5156

57+
#ifdef DEBUG
58+
std::cout << "Finished symex, invoking decision procedure.\n";
59+
#endif
60+
5261
return (checker->dec_solve()==decision_proceduret::D_SATISFIABLE);
5362
}
5463

src/goto-instrument/accelerate/trace_automaton.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ void trace_automatont::add_path(patht &path)
7575
{
7676
goto_programt::targett l=step.loc;
7777

78+
#ifdef DEBUG
79+
std::cout << ", " << l->location_number << ':'
80+
<< l->source_location.as_string();
81+
#endif
82+
7883
if(in_alphabet(l))
7984
{
8085
#ifdef DEBUG
@@ -103,6 +108,13 @@ void trace_automatont::add_path(patht &path)
103108
*/
104109
void trace_automatont::determinise()
105110
{
111+
#ifdef DEBUG
112+
std::cout << "Determinising automaton with " << nta.num_states
113+
<< " states and " << nta.accept_states.size()
114+
<< " accept states and " << nta.count_transitions()
115+
<< " transitions\n";
116+
#endif
117+
106118
dstates.clear();
107119
unmarked_dstates.clear();
108120
dta.clear();
@@ -111,6 +123,10 @@ void trace_automatont::determinise()
111123
init_states.insert(nta.init_state);
112124
epsilon_closure(init_states);
113125

126+
#ifdef DEBUG
127+
std::cout << "There are " << init_states.size() << " init states\n";
128+
#endif
129+
114130
dta.init_state=add_dstate(init_states);
115131

116132
while(!unmarked_dstates.empty())
@@ -371,7 +387,7 @@ void automatont::reverse(goto_programt::targett epsilon)
371387

372388
std::cout << "Reversing automaton, old init=" << init_state
373389
<< ", new init=" << new_init << ", old accept="
374-
<< *(accept_states.begin()) << "/" << accept_states.size()
390+
<< *(accept_states.begin()) << '/' << accept_states.size()
375391
<< " new accept=" << init_state << std::endl;
376392

377393
accept_states.clear();
@@ -455,7 +471,7 @@ void automatont::output(std::ostream &str)
455471
str << "Accept states: ";
456472

457473
for(const auto &state : accept_states)
458-
str << state << " ";
474+
str << state << ' ';
459475

460476
str << std::endl;
461477

src/java_bytecode/java_local_variable_table.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static void populate_predecessor_map(
352352
// handling is presently vague (any subroutine is assumed to
353353
// be able to return to any callsite)
354354
msg.warning() << "Local variable table: ignoring flow from "
355-
<< "out of range for " << it->var.name << " "
355+
<< "out of range for " << it->var.name << ' '
356356
<< pred << " -> " << amapit->first
357357
<< messaget::eom;
358358
continue;
@@ -375,7 +375,7 @@ static void populate_predecessor_map(
375375
// assumed to be able to return to any callsite)
376376
msg.warning() << "Local variable table: ignoring flow from "
377377
<< "clashing variable for "
378-
<< it->var.name << " " << pred << " -> "
378+
<< it->var.name << ' ' << pred << " -> "
379379
<< amapit->first << messaget::eom;
380380
continue;
381381
}
@@ -546,6 +546,13 @@ static void merge_variable_table_entries(
546546
merge_into.var.start_pc=found_dominator;
547547
merge_into.var.length=last_pc-found_dominator;
548548

549+
#ifdef DEBUG
550+
debug_out << "Merged " << merge_vars.size() << " variables named "
551+
<< merge_into.var.name << "; new live range "
552+
<< merge_into.var.start_pc << '-'
553+
<< merge_into.var.start_pc + merge_into.var.length << '\n';
554+
#endif
555+
549556
// Nuke the now-subsumed var-table entries:
550557
for(auto &v : merge_vars)
551558
if(v!=&merge_into)

0 commit comments

Comments
 (0)