Skip to content

Commit 87dfaeb

Browse files
authored
Merge pull request #3195 from diffblue/goto-trace-colors
Goto trace colors
2 parents 2fc12b0 + 2ff1935 commit 87dfaeb

File tree

2 files changed

+42
-46
lines changed

2 files changed

+42
-46
lines changed

src/goto-programs/goto_trace.cpp

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void goto_trace_stept::output(
8282
}
8383

8484
if(is_assert() || is_assume() || is_goto())
85-
out << " (" << cond_value << ")";
85+
out << " (" << cond_value << ')';
8686
else if(is_function_call() || is_function_return())
8787
out << ' ' << function_identifier;
8888

@@ -233,7 +233,7 @@ std::string trace_numeric_value(
233233
}
234234

235235
void trace_value(
236-
std::ostream &out,
236+
messaget::mstreamt &out,
237237
const namespacet &ns,
238238
const optionalt<symbol_exprt> &lhs_object,
239239
const exprt &full_lhs,
@@ -245,49 +245,44 @@ void trace_value(
245245
if(lhs_object.has_value())
246246
identifier=lhs_object->get_identifier();
247247

248-
std::string value_string;
248+
out << " " << from_expr(ns, identifier, full_lhs) << '=';
249249

250250
if(value.is_nil())
251-
value_string="(assignment removed)";
251+
out << "(assignment removed)";
252252
else
253253
{
254-
value_string=from_expr(ns, identifier, value);
254+
out << from_expr(ns, identifier, value);
255255

256256
// the binary representation
257-
value_string += " (" + trace_numeric_value(value, ns, options) + ")";
257+
out << ' ' << messaget::faint << '('
258+
<< trace_numeric_value(value, ns, options) << ')' << messaget::reset;
258259
}
259260

260-
out << " "
261-
<< from_expr(ns, identifier, full_lhs)
262-
<< "=" << value_string
263-
<< "\n";
261+
out << '\n';
264262
}
265263

266264
void show_state_header(
267-
std::ostream &out,
265+
messaget::mstreamt &out,
268266
const namespacet &ns,
269267
const goto_trace_stept &state,
270268
const source_locationt &source_location,
271269
unsigned step_nr,
272270
const trace_optionst &options)
273271
{
274-
out << "\n";
272+
out << '\n';
275273

276274
if(step_nr == 0)
277275
out << "Initial State";
278276
else
279277
out << "State " << step_nr;
280278

281-
out << " " << source_location << " thread " << state.thread_nr << "\n";
282-
out << "----------------------------------------------------"
283-
<< "\n";
279+
out << ' ' << source_location << " thread " << state.thread_nr << '\n';
280+
out << "----------------------------------------------------" << '\n';
284281

285282
if(options.show_code)
286283
{
287-
out << as_string(ns, *state.pc)
288-
<< "\n";
289-
out << "----------------------------------------------------"
290-
<< "\n";
284+
out << as_string(ns, *state.pc) << '\n';
285+
out << "----------------------------------------------------" << '\n';
291286
}
292287
}
293288

@@ -304,7 +299,7 @@ bool is_index_member_symbol(const exprt &src)
304299
}
305300

306301
void show_full_goto_trace(
307-
std::ostream &out,
302+
messaget::mstreamt &out,
308303
const namespacet &ns,
309304
const goto_tracet &goto_trace,
310305
const trace_optionst &options)
@@ -324,33 +319,33 @@ void show_full_goto_trace(
324319
case goto_trace_stept::typet::ASSERT:
325320
if(!step.cond_value)
326321
{
327-
out << "\n";
328-
out << "Violated property:" << "\n";
322+
out << '\n';
323+
out << messaget::red << "Violated property:" << messaget::reset << '\n';
329324
if(!step.pc->source_location.is_nil())
330-
out << " " << step.pc->source_location << "\n";
331-
out << " " << step.comment << "\n";
325+
out << " " << step.pc->source_location << '\n';
326+
out << " " << messaget::red << step.comment << messaget::reset << '\n';
332327

333328
if(step.pc->is_assert())
334329
out << " " << from_expr(ns, step.pc->function, step.pc->guard)
335330
<< '\n';
336331

337-
out << "\n";
332+
out << '\n';
338333
}
339334
break;
340335

341336
case goto_trace_stept::typet::ASSUME:
342337
if(!step.cond_value)
343338
{
344-
out << "\n";
345-
out << "Violated assumption:" << "\n";
339+
out << '\n';
340+
out << "Violated assumption:" << '\n';
346341
if(!step.pc->source_location.is_nil())
347-
out << " " << step.pc->source_location << "\n";
342+
out << " " << step.pc->source_location << '\n';
348343

349344
if(step.pc->is_assume())
350345
out << " " << from_expr(ns, step.pc->function, step.pc->guard)
351346
<< '\n';
352347

353-
out << "\n";
348+
out << '\n';
354349
}
355350
break;
356351

@@ -403,50 +398,50 @@ void show_full_goto_trace(
403398
printf_formattert printf_formatter(ns);
404399
printf_formatter(id2string(step.format_string), step.io_args);
405400
printf_formatter.print(out);
406-
out << "\n";
401+
out << '\n';
407402
}
408403
else
409404
{
410405
show_state_header(
411406
out, ns, step, step.pc->source_location, step.step_nr, options);
412-
out << " OUTPUT " << step.io_id << ":";
407+
out << " OUTPUT " << step.io_id << ':';
413408

414409
for(std::list<exprt>::const_iterator
415410
l_it=step.io_args.begin();
416411
l_it!=step.io_args.end();
417412
l_it++)
418413
{
419414
if(l_it!=step.io_args.begin())
420-
out << ";";
421-
out << " " << from_expr(ns, step.pc->function, *l_it);
415+
out << ';';
416+
out << ' ' << from_expr(ns, step.pc->function, *l_it);
422417

423418
// the binary representation
424-
out << " (" << trace_numeric_value(*l_it, ns, options) << ")";
419+
out << " (" << trace_numeric_value(*l_it, ns, options) << ')';
425420
}
426421

427-
out << "\n";
422+
out << '\n';
428423
}
429424
break;
430425

431426
case goto_trace_stept::typet::INPUT:
432427
show_state_header(
433428
out, ns, step, step.pc->source_location, step.step_nr, options);
434-
out << " INPUT " << step.io_id << ":";
429+
out << " INPUT " << step.io_id << ':';
435430

436431
for(std::list<exprt>::const_iterator
437432
l_it=step.io_args.begin();
438433
l_it!=step.io_args.end();
439434
l_it++)
440435
{
441436
if(l_it!=step.io_args.begin())
442-
out << ";";
443-
out << " " << from_expr(ns, step.pc->function, *l_it);
437+
out << ';';
438+
out << ' ' << from_expr(ns, step.pc->function, *l_it);
444439

445440
// the binary representation
446-
out << " (" << trace_numeric_value(*l_it, ns, options) << ")";
441+
out << " (" << trace_numeric_value(*l_it, ns, options) << ')';
447442
}
448443

449-
out << "\n";
444+
out << '\n';
450445
break;
451446

452447
case goto_trace_stept::typet::FUNCTION_CALL:
@@ -497,7 +492,7 @@ void show_full_goto_trace(
497492
}
498493

499494
void show_goto_stack_trace(
500-
std::ostream &out,
495+
messaget::mstreamt &out,
501496
const namespacet &ns,
502497
const goto_tracet &goto_trace,
503498
const trace_optionst &options)
@@ -573,7 +568,7 @@ void show_goto_stack_trace(
573568
}
574569

575570
void show_goto_trace(
576-
std::ostream &out,
571+
messaget::mstreamt &out,
577572
const namespacet &ns,
578573
const goto_tracet &goto_trace,
579574
const trace_optionst &options)
@@ -585,7 +580,7 @@ void show_goto_trace(
585580
}
586581

587582
void show_goto_trace(
588-
std::ostream &out,
583+
messaget::mstreamt &out,
589584
const namespacet &ns,
590585
const goto_tracet &goto_trace)
591586
{

src/goto-programs/goto_trace.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Date: July 2005
1717
#include <iosfwd>
1818
#include <vector>
1919

20+
#include <util/message.h>
2021
#include <util/namespace.h>
2122
#include <util/options.h>
2223
#include <util/ssa_expr.h>
@@ -223,18 +224,18 @@ struct trace_optionst
223224
};
224225

225226
void show_goto_trace(
226-
std::ostream &out,
227+
messaget::mstreamt &out,
227228
const namespacet &,
228229
const goto_tracet &);
229230

230231
void show_goto_trace(
231-
std::ostream &out,
232+
messaget::mstreamt &out,
232233
const namespacet &,
233234
const goto_tracet &,
234235
const trace_optionst &);
235236

236237
void trace_value(
237-
std::ostream &out,
238+
messaget::mstreamt &out,
238239
const namespacet &,
239240
const optionalt<symbol_exprt> &lhs_object,
240241
const exprt &full_lhs,

0 commit comments

Comments
 (0)