CBMC
goto_trace.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Traces of GOTO Programs
4 
5 Author: Daniel Kroening
6 
7  Date: July 2005
8 
9 \*******************************************************************/
10 
13 
14 #include "goto_trace.h"
15 
16 #include <ostream>
17 
18 #include <util/arith_tools.h>
19 #include <util/byte_operators.h>
20 #include <util/c_types.h>
21 #include <util/format_expr.h>
22 #include <util/merge_irep.h>
23 #include <util/range.h>
24 #include <util/string_utils.h>
25 #include <util/symbol.h>
26 
27 #include <langapi/language_util.h>
28 
29 #include "printf_formatter.h"
30 
32 {
33  if(src.id()==ID_symbol)
34  return to_symbol_expr(src);
35  else if(src.id()==ID_member)
36  return get_object_rec(to_member_expr(src).struct_op());
37  else if(src.id()==ID_index)
38  return get_object_rec(to_index_expr(src).array());
39  else if(src.id()==ID_typecast)
40  return get_object_rec(to_typecast_expr(src).op());
41  else if(
42  src.id() == ID_byte_extract_little_endian ||
43  src.id() == ID_byte_extract_big_endian)
44  {
45  return get_object_rec(to_byte_extract_expr(src).op());
46  }
47  else
48  return {}; // give up
49 }
50 
52 {
53  return get_object_rec(full_lhs);
54 }
55 
57  const class namespacet &ns,
58  std::ostream &out) const
59 {
60  for(const auto &step : steps)
61  step.output(ns, out);
62 }
63 
65  const namespacet &,
66  std::ostream &out) const
67 {
68  out << "*** ";
69 
70  // clang-format off
71  switch(type)
72  {
73  case goto_trace_stept::typet::ASSERT: out << "ASSERT"; break;
74  case goto_trace_stept::typet::ASSUME: out << "ASSUME"; break;
75  case goto_trace_stept::typet::LOCATION: out << "LOCATION"; break;
76  case goto_trace_stept::typet::ASSIGNMENT: out << "ASSIGNMENT"; break;
77  case goto_trace_stept::typet::GOTO: out << "GOTO"; break;
78  case goto_trace_stept::typet::DECL: out << "DECL"; break;
79  case goto_trace_stept::typet::DEAD: out << "DEAD"; break;
80  case goto_trace_stept::typet::OUTPUT: out << "OUTPUT"; break;
81  case goto_trace_stept::typet::INPUT: out << "INPUT"; break;
83  out << "ATOMIC_BEGIN";
84  break;
85  case goto_trace_stept::typet::ATOMIC_END: out << "ATOMIC_END"; break;
86  case goto_trace_stept::typet::SHARED_READ: out << "SHARED_READ"; break;
87  case goto_trace_stept::typet::SHARED_WRITE: out << "SHARED WRITE"; break;
88  case goto_trace_stept::typet::FUNCTION_CALL: out << "FUNCTION CALL"; break;
90  out << "FUNCTION RETURN"; break;
91  case goto_trace_stept::typet::MEMORY_BARRIER: out << "MEMORY_BARRIER"; break;
92  case goto_trace_stept::typet::SPAWN: out << "SPAWN"; break;
93  case goto_trace_stept::typet::CONSTRAINT: out << "CONSTRAINT"; break;
94  case goto_trace_stept::typet::NONE: out << "NONE"; break;
95  }
96  // clang-format on
97 
98  if(is_assert() || is_assume() || is_goto())
99  out << " (" << cond_value << ')';
100  else if(is_function_call())
101  out << ' ' << called_function;
102 
103  if(hidden)
104  out << " hidden";
105 
106  out << '\n';
107 
108  if(is_assignment())
109  {
110  out << " " << format(full_lhs)
111  << " = " << format(full_lhs_value)
112  << '\n';
113  }
114 
115  if(!pc->source_location().is_nil())
116  out << pc->source_location() << '\n';
117 
118  out << pc->type() << '\n';
119 
120  if(pc->is_assert())
121  {
122  if(!cond_value)
123  {
124  out << "Violated property:" << '\n';
125  if(pc->source_location().is_nil())
126  out << " " << pc->source_location() << '\n';
127 
128  if(!comment.empty())
129  out << " " << comment << '\n';
130 
131  out << " " << format(pc->condition()) << '\n';
132  out << '\n';
133  }
134  }
135 
136  out << '\n';
137 }
138 
140 {
141  dest(cond_expr);
142  dest(full_lhs);
143  dest(full_lhs_value);
144 
145  for(auto &io_arg : io_args)
146  dest(io_arg);
147 
148  for(auto &function_arg : function_arguments)
149  dest(function_arg);
150 }
151 
161 static std::string numeric_representation(
162  const constant_exprt &expr,
163  const namespacet &ns,
164  const trace_optionst &options)
165 {
166  std::string result;
167  std::string prefix;
168 
169  const typet &expr_type = expr.type();
170 
171  const typet &underlying_type =
172  expr_type.id() == ID_c_enum_tag
173  ? ns.follow_tag(to_c_enum_tag_type(expr_type)).underlying_type()
174  : expr_type;
175 
176  const irep_idt &value = expr.get_value();
177 
178  const auto width = to_bitvector_type(underlying_type).get_width();
179 
180  const mp_integer value_int = bvrep2integer(id2string(value), width, false);
181 
182  if(options.hex_representation)
183  {
184  result = integer2string(value_int, 16);
185  prefix = "0x";
186  }
187  else
188  {
189  result = integer2binary(value_int, width);
190  prefix = "0b";
191  }
192 
193  std::ostringstream oss;
195  for(const auto c : result)
196  {
197  oss << c;
198  if(++i % 8 == 0 && result.size() != i)
199  oss << ' ';
200  }
201  if(options.base_prefix)
202  return prefix + oss.str();
203  else
204  return oss.str();
205 }
206 
208  const exprt &expr,
209  const namespacet &ns,
210  const trace_optionst &options)
211 {
212  const typet &type = expr.type();
213 
214  if(expr.id()==ID_constant)
215  {
216  if(type.id()==ID_unsignedbv ||
217  type.id()==ID_signedbv ||
218  type.id()==ID_bv ||
219  type.id()==ID_fixedbv ||
220  type.id()==ID_floatbv ||
221  type.id()==ID_pointer ||
222  type.id()==ID_c_bit_field ||
223  type.id()==ID_c_bool ||
224  type.id()==ID_c_enum ||
225  type.id()==ID_c_enum_tag)
226  {
227  return numeric_representation(to_constant_expr(expr), ns, options);
228  }
229  else if(type.id()==ID_bool)
230  {
231  return expr.is_true()?"1":"0";
232  }
233  else if(type.id()==ID_integer)
234  {
235  const auto i = numeric_cast<mp_integer>(expr);
236  if(i.has_value() && *i >= 0)
237  {
238  if(options.hex_representation)
239  return "0x" + integer2string(*i, 16);
240  else
241  return "0b" + integer2string(*i, 2);
242  }
243  }
244  }
245  else if(expr.id() == ID_annotated_pointer_constant)
246  {
247  const auto &annotated_pointer_constant =
249  auto width = to_pointer_type(expr.type()).get_width();
250  auto &value = annotated_pointer_constant.get_value();
251  auto c = constant_exprt(value, unsignedbv_typet(width));
252  return numeric_representation(c, ns, options);
253  }
254  else if(expr.id()==ID_array)
255  {
256  std::string result;
257 
258  forall_operands(it, expr)
259  {
260  if(result.empty())
261  result="{ ";
262  else
263  result+=", ";
264  result+=trace_numeric_value(*it, ns, options);
265  }
266 
267  return result+" }";
268  }
269  else if(expr.id()==ID_struct)
270  {
271  std::string result="{ ";
272 
273  forall_operands(it, expr)
274  {
275  if(it!=expr.operands().begin())
276  result+=", ";
277  result+=trace_numeric_value(*it, ns, options);
278  }
279 
280  return result+" }";
281  }
282  else if(expr.id()==ID_union)
283  {
284  return trace_numeric_value(to_union_expr(expr).op(), ns, options);
285  }
286 
287  return "?";
288 }
289 
290 static void trace_value(
291  messaget::mstreamt &out,
292  const namespacet &ns,
293  const optionalt<symbol_exprt> &lhs_object,
294  const exprt &full_lhs,
295  const exprt &value,
296  const trace_optionst &options)
297 {
298  irep_idt identifier;
299 
300  if(lhs_object.has_value())
301  identifier=lhs_object->get_identifier();
302 
303  out << from_expr(ns, identifier, full_lhs) << '=';
304 
305  if(value.is_nil())
306  out << "(assignment removed)";
307  else
308  {
309  out << from_expr(ns, identifier, value);
310 
311  // the binary representation
312  out << ' ' << messaget::faint << '('
313  << trace_numeric_value(value, ns, options) << ')' << messaget::reset;
314  }
315 
316  out << '\n';
317 }
318 
319 static std::string
321 {
322  std::string result;
323 
324  const auto &source_location = state.pc->source_location();
325 
326  if(!source_location.get_file().empty())
327  result += "file " + id2string(source_location.get_file());
328 
329  if(!state.function_id.empty())
330  {
331  const symbolt &symbol = ns.lookup(state.function_id);
332  if(!result.empty())
333  result += ' ';
334  result += "function " + id2string(symbol.display_name());
335  }
336 
337  if(!source_location.get_line().empty())
338  {
339  if(!result.empty())
340  result += ' ';
341  result += "line " + id2string(source_location.get_line());
342  }
343 
344  if(!result.empty())
345  result += ' ';
346  result += "thread " + std::to_string(state.thread_nr);
347 
348  return result;
349 }
350 
352  messaget::mstreamt &out,
353  const namespacet &ns,
354  const goto_trace_stept &state,
355  unsigned step_nr,
356  const trace_optionst &options)
357 {
358  out << '\n';
359 
360  if(step_nr == 0)
361  out << "Initial State";
362  else
363  out << "State " << step_nr;
364 
365  out << ' ' << state_location(state, ns) << '\n';
366  out << "----------------------------------------------------" << '\n';
367 
368  if(options.show_code)
369  {
370  out << as_string(ns, state.function_id, *state.pc) << '\n';
371  out << "----------------------------------------------------" << '\n';
372  }
373 }
374 
376 {
377  if(src.id()==ID_index)
378  return is_index_member_symbol(to_index_expr(src).array());
379  else if(src.id()==ID_member)
380  return is_index_member_symbol(to_member_expr(src).compound());
381  else if(src.id()==ID_symbol)
382  return true;
383  else
384  return false;
385 }
386 
393  messaget::mstreamt &out,
394  const namespacet &ns,
395  const goto_tracet &goto_trace,
396  const trace_optionst &options)
397 {
398  std::size_t function_depth = 0;
399 
400  for(const auto &step : goto_trace.steps)
401  {
402  if(step.is_function_call())
403  function_depth++;
404  else if(step.is_function_return())
405  function_depth--;
406 
407  // hide the hidden ones
408  if(step.hidden)
409  continue;
410 
411  switch(step.type)
412  {
414  if(!step.cond_value)
415  {
416  out << '\n';
417  out << messaget::red << "Violated property:" << messaget::reset << '\n';
418  if(!step.pc->source_location().is_nil())
419  out << " " << state_location(step, ns) << '\n';
420 
421  out << " " << messaget::red << step.comment << messaget::reset << '\n';
422 
423  if(step.pc->is_assert())
424  {
425  out << " " << from_expr(ns, step.function_id, step.pc->condition())
426  << '\n';
427  }
428 
429  out << '\n';
430  }
431  break;
432 
434  if(
435  step.assignment_type ==
437  {
438  break;
439  }
440 
441  out << " ";
442 
443  if(!step.pc->source_location().get_line().empty())
444  {
445  out << messaget::faint << step.pc->source_location().get_line() << ':'
446  << messaget::reset << ' ';
447  }
448 
449  trace_value(
450  out,
451  ns,
452  step.get_lhs_object(),
453  step.full_lhs,
454  step.full_lhs_value,
455  options);
456  break;
457 
459  // downwards arrow
460  out << '\n' << messaget::faint << u8"\u21b3" << messaget::reset << ' ';
461  if(!step.pc->source_location().get_file().empty())
462  {
463  out << messaget::faint << step.pc->source_location().get_file();
464 
465  if(!step.pc->source_location().get_line().empty())
466  {
467  out << messaget::faint << ':'
468  << step.pc->source_location().get_line();
469  }
470 
471  out << messaget::reset << ' ';
472  }
473 
474  {
475  // show the display name
476  const auto &f_symbol = ns.lookup(step.called_function);
477  out << f_symbol.display_name();
478  }
479 
480  {
481  auto arg_strings = make_range(step.function_arguments)
482  .map([&ns, &step](const exprt &arg) {
483  return from_expr(ns, step.function_id, arg);
484  });
485 
486  out << '(';
487  join_strings(out, arg_strings.begin(), arg_strings.end(), ", ");
488  out << ")\n";
489  }
490 
491  break;
492 
494  // upwards arrow
495  out << messaget::faint << u8"\u21b5" << messaget::reset << '\n';
496  break;
497 
512  break;
513 
515  UNREACHABLE;
516  }
517  }
518 }
519 
521  messaget::mstreamt &out,
522  const namespacet &ns,
523  const goto_tracet &goto_trace,
524  const trace_optionst &options)
525 {
526  unsigned prev_step_nr=0;
527  bool first_step=true;
528  std::size_t function_depth=0;
529 
530  for(const auto &step : goto_trace.steps)
531  {
532  // hide the hidden ones
533  if(step.hidden)
534  continue;
535 
536  switch(step.type)
537  {
539  if(!step.cond_value)
540  {
541  out << '\n';
542  out << messaget::red << "Violated property:" << messaget::reset << '\n';
543  if(!step.pc->source_location().is_nil())
544  {
545  out << " " << state_location(step, ns) << '\n';
546  }
547 
548  out << " " << messaget::red << step.comment << messaget::reset << '\n';
549 
550  if(step.pc->is_assert())
551  {
552  out << " " << from_expr(ns, step.function_id, step.pc->condition())
553  << '\n';
554  }
555 
556  out << '\n';
557  }
558  break;
559 
561  if(step.cond_value && step.pc->is_assume())
562  {
563  out << "\n";
564  out << "Assumption:\n";
565 
566  if(!step.pc->source_location().is_nil())
567  out << " " << step.pc->source_location() << '\n';
568 
569  out << " " << from_expr(ns, step.function_id, step.pc->condition())
570  << '\n';
571  }
572  break;
573 
575  break;
576 
578  break;
579 
581  if(
582  step.pc->is_assign() ||
583  step.pc->is_set_return_value() || // returns have a lhs!
584  step.pc->is_function_call() ||
585  (step.pc->is_other() && step.full_lhs.is_not_nil()))
586  {
587  if(prev_step_nr!=step.step_nr || first_step)
588  {
589  first_step=false;
590  prev_step_nr=step.step_nr;
591  show_state_header(out, ns, step, step.step_nr, options);
592  }
593 
594  out << " ";
595  trace_value(
596  out,
597  ns,
598  step.get_lhs_object(),
599  step.full_lhs,
600  step.full_lhs_value,
601  options);
602  }
603  break;
604 
606  if(prev_step_nr!=step.step_nr || first_step)
607  {
608  first_step=false;
609  prev_step_nr=step.step_nr;
610  show_state_header(out, ns, step, step.step_nr, options);
611  }
612 
613  out << " ";
614  trace_value(
615  out, ns, step.get_lhs_object(), step.full_lhs, step.full_lhs_value, options);
616  break;
617 
619  if(step.formatted)
620  {
621  printf_formattert printf_formatter(ns);
622  printf_formatter(id2string(step.format_string), step.io_args);
623  printf_formatter.print(out);
624  out << '\n';
625  }
626  else
627  {
628  show_state_header(out, ns, step, step.step_nr, options);
629  out << " OUTPUT " << step.io_id << ':';
630 
631  for(std::list<exprt>::const_iterator
632  l_it=step.io_args.begin();
633  l_it!=step.io_args.end();
634  l_it++)
635  {
636  if(l_it!=step.io_args.begin())
637  out << ';';
638 
639  out << ' ' << from_expr(ns, step.function_id, *l_it);
640 
641  // the binary representation
642  out << " (" << trace_numeric_value(*l_it, ns, options) << ')';
643  }
644 
645  out << '\n';
646  }
647  break;
648 
650  show_state_header(out, ns, step, step.step_nr, options);
651  out << " INPUT " << step.io_id << ':';
652 
653  for(std::list<exprt>::const_iterator
654  l_it=step.io_args.begin();
655  l_it!=step.io_args.end();
656  l_it++)
657  {
658  if(l_it!=step.io_args.begin())
659  out << ';';
660 
661  out << ' ' << from_expr(ns, step.function_id, *l_it);
662 
663  // the binary representation
664  out << " (" << trace_numeric_value(*l_it, ns, options) << ')';
665  }
666 
667  out << '\n';
668  break;
669 
671  function_depth++;
672  if(options.show_function_calls)
673  {
674  out << "\n#### Function call: " << step.called_function;
675  out << '(';
676 
677  bool first = true;
678  for(auto &arg : step.function_arguments)
679  {
680  if(first)
681  first = false;
682  else
683  out << ", ";
684 
685  out << from_expr(ns, step.function_id, arg);
686  }
687 
688  out << ") (depth " << function_depth << ") ####\n";
689  }
690  break;
691 
693  function_depth--;
694  if(options.show_function_calls)
695  {
696  out << "\n#### Function return from " << step.function_id << " (depth "
697  << function_depth << ") ####\n";
698  }
699  break;
700 
706  break;
707 
712  UNREACHABLE;
713  }
714  }
715 }
716 
718  messaget::mstreamt &out,
719  const namespacet &ns,
720  const goto_tracet &goto_trace)
721 {
722  // map from thread number to a call stack
723  std::map<unsigned, std::vector<goto_tracet::stepst::const_iterator>>
724  call_stacks;
725 
726  // by default, we show thread 0
727  unsigned thread_to_show = 0;
728 
729  for(auto s_it = goto_trace.steps.begin(); s_it != goto_trace.steps.end();
730  s_it++)
731  {
732  const auto &step = *s_it;
733  auto &stack = call_stacks[step.thread_nr];
734 
735  if(step.is_assert())
736  {
737  if(!step.cond_value)
738  {
739  stack.push_back(s_it);
740  thread_to_show = step.thread_nr;
741  }
742  }
743  else if(step.is_function_call())
744  {
745  stack.push_back(s_it);
746  }
747  else if(step.is_function_return())
748  {
749  stack.pop_back();
750  }
751  }
752 
753  const auto &stack = call_stacks[thread_to_show];
754 
755  // print in reverse order
756  for(auto s_it = stack.rbegin(); s_it != stack.rend(); s_it++)
757  {
758  const auto &step = **s_it;
759  if(step.is_assert())
760  {
761  out << " assertion failure";
762  if(!step.pc->source_location().is_nil())
763  out << ' ' << step.pc->source_location();
764  out << '\n';
765  }
766  else if(step.is_function_call())
767  {
768  out << " " << step.called_function;
769  out << '(';
770 
771  bool first = true;
772  for(auto &arg : step.function_arguments)
773  {
774  if(first)
775  first = false;
776  else
777  out << ", ";
778 
779  out << from_expr(ns, step.function_id, arg);
780  }
781 
782  out << ')';
783 
784  if(!step.pc->source_location().is_nil())
785  out << ' ' << step.pc->source_location();
786 
787  out << '\n';
788  }
789  }
790 }
791 
793  messaget::mstreamt &out,
794  const namespacet &ns,
795  const goto_tracet &goto_trace,
796  const trace_optionst &options)
797 {
798  if(options.stack_trace)
799  show_goto_stack_trace(out, ns, goto_trace);
800  else if(options.compact_trace)
801  show_compact_goto_trace(out, ns, goto_trace, options);
802  else
803  show_full_goto_trace(out, ns, goto_trace, options);
804 }
805 
807 
808 std::set<irep_idt> goto_tracet::get_failed_property_ids() const
809 {
810  std::set<irep_idt> property_ids;
811  for(const auto &step : steps)
812  {
813  if(step.is_assert() && !step.cond_value)
814  property_ids.insert(step.property_id);
815  }
816  return property_ids;
817 }
UNREACHABLE
#define UNREACHABLE
This should be used to mark dead code.
Definition: invariant.h:503
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
trace_optionst::compact_trace
bool compact_trace
Give a compact trace.
Definition: goto_trace.h:232
goto_tracet::get_failed_property_ids
std::set< irep_idt > get_failed_property_ids() const
Returns the property IDs of all failed assertions in the trace.
Definition: goto_trace.cpp:808
format
static format_containert< T > format(const T &o)
Definition: format.h:37
goto_trace_stept::typet::LOCATION
@ LOCATION
goto_trace_stept::full_lhs_value
exprt full_lhs_value
Definition: goto_trace.h:132
goto_trace_stept::get_lhs_object
optionalt< symbol_exprt > get_lhs_object() const
Definition: goto_trace.cpp:51
goto_trace_stept::comment
std::string comment
Definition: goto_trace.h:123
mp_integer
BigInt mp_integer
Definition: smt_terms.h:17
show_full_goto_trace
void show_full_goto_trace(messaget::mstreamt &out, const namespacet &ns, const goto_tracet &goto_trace, const trace_optionst &options)
Definition: goto_trace.cpp:520
goto_trace_stept::typet::ASSUME
@ ASSUME
arith_tools.h
printf_formattert
Definition: printf_formatter.h:19
messaget::reset
static const commandt reset
return to default formatting, as defined by the terminal
Definition: message.h:343
printf_formatter.h
merge_irep.h
string_utils.h
trace_optionst::base_prefix
bool base_prefix
Use prefix (0b or 0x) for distinguishing the base of the representation.
Definition: goto_trace.h:226
symbolt::display_name
const irep_idt & display_name() const
Return language specific display name if present.
Definition: symbol.h:55
typet
The type of an expression, extends irept.
Definition: type.h:28
to_byte_extract_expr
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
Definition: byte_operators.h:57
state_location
static std::string state_location(const goto_trace_stept &state, const namespacet &ns)
Definition: goto_trace.cpp:320
u8
uint64_t u8
Definition: bytecode_info.h:58
trace_optionst::show_code
bool show_code
Show original code in plain text trace.
Definition: goto_trace.h:230
to_index_expr
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
Definition: std_expr.h:1478
to_annotated_pointer_constant_expr
const annotated_pointer_constant_exprt & to_annotated_pointer_constant_expr(const exprt &expr)
Cast an exprt to an annotated_pointer_constant_exprt.
Definition: pointer_expr.h:868
goto_trace_stept::is_assert
bool is_assert() const
Definition: goto_trace.h:57
goto_trace_stept::type
typet type
Definition: goto_trace.h:97
goto_tracet::steps
stepst steps
Definition: goto_trace.h:178
exprt
Base class for all expressions.
Definition: expr.h:55
to_union_expr
const union_exprt & to_union_expr(const exprt &expr)
Cast an exprt to a union_exprt.
Definition: std_expr.h:1754
namespace_baset::follow_tag
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
Definition: namespace.cpp:63
to_string
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
Definition: string_constraint.cpp:58
exprt::is_true
bool is_true() const
Return whether the expression is a constant representing true.
Definition: expr.cpp:34
goto_trace_stept
Step of the trace of a GOTO program.
Definition: goto_trace.h:49
to_bitvector_type
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
Definition: bitvector_types.h:32
goto_trace_stept::is_function_call
bool is_function_call() const
Definition: goto_trace.h:60
goto_trace_stept::called_function
irep_idt called_function
Definition: goto_trace.h:141
unsignedbv_typet
Fixed-width bit-vector with unsigned binary interpretation.
Definition: bitvector_types.h:158
goto_trace_stept::is_assignment
bool is_assignment() const
Definition: goto_trace.h:55
goto_trace.h
printf_formattert::print
void print(std::ostream &out)
Definition: printf_formatter.cpp:38
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
exprt::type
typet & type()
Return the type of the expression.
Definition: expr.h:84
namespacet::lookup
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Definition: namespace.cpp:138
byte_operators.h
Expression classes for byte-level operators.
goto_trace_stept::typet::OUTPUT
@ OUTPUT
goto_trace_stept::typet::FUNCTION_RETURN
@ FUNCTION_RETURN
show_compact_goto_trace
void show_compact_goto_trace(messaget::mstreamt &out, const namespacet &ns, const goto_tracet &goto_trace, const trace_optionst &options)
show a compact variant of the goto trace on the console
Definition: goto_trace.cpp:392
messaget::faint
static const commandt faint
render text with faint font
Definition: message.h:385
goto_trace_stept::typet::DECL
@ DECL
goto_trace_stept::output
void output(const class namespacet &ns, std::ostream &out) const
Outputs the trace step in ASCII to a given stream.
Definition: goto_trace.cpp:64
id2string
const std::string & id2string(const irep_idt &d)
Definition: irep.h:47
goto_trace_stept::typet::ASSERT
@ ASSERT
goto_trace_stept::cond_expr
exprt cond_expr
Definition: goto_trace.h:119
messaget::mstreamt::source_location
source_locationt source_location
Definition: message.h:247
to_c_enum_tag_type
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
Definition: c_types.h:344
forall_operands
#define forall_operands(it, expr)
Definition: expr.h:20
language_util.h
goto_trace_stept::typet::NONE
@ NONE
join_strings
Stream & join_strings(Stream &&os, const It b, const It e, const Delimiter &delimiter, TransformFunc &&transform_func)
Prints items to an stream, separated by a constant delimiter.
Definition: string_utils.h:62
trace_value
static void trace_value(messaget::mstreamt &out, const namespacet &ns, const optionalt< symbol_exprt > &lhs_object, const exprt &full_lhs, const exprt &value, const trace_optionst &options)
Definition: goto_trace.cpp:290
goto_trace_stept::full_lhs
exprt full_lhs
Definition: goto_trace.h:126
goto_trace_stept::function_arguments
std::vector< exprt > function_arguments
Definition: goto_trace.h:144
goto_trace_stept::pc
goto_programt::const_targett pc
Definition: goto_trace.h:112
is_index_member_symbol
bool is_index_member_symbol(const exprt &src)
Definition: goto_trace.cpp:375
to_pointer_type
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
Definition: pointer_expr.h:79
get_object_rec
static optionalt< symbol_exprt > get_object_rec(const exprt &src)
Definition: goto_trace.cpp:31
goto_trace_stept::typet::ASSIGNMENT
@ ASSIGNMENT
goto_tracet::output
void output(const class namespacet &ns, std::ostream &out) const
Outputs the trace in ASCII to a given stream.
Definition: goto_trace.cpp:56
to_symbol_expr
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition: std_expr.h:222
symbol.h
Symbol table entry.
irept::is_nil
bool is_nil() const
Definition: irep.h:376
irept::id
const irep_idt & id() const
Definition: irep.h:396
range.h
dstringt::empty
bool empty() const
Definition: dstring.h:88
goto_trace_stept::assignment_typet::ACTUAL_PARAMETER
@ ACTUAL_PARAMETER
goto_trace_stept::typet::INPUT
@ INPUT
goto_trace_stept::typet::ATOMIC_END
@ ATOMIC_END
optionalt
nonstd::optional< T > optionalt
Definition: optional.h:35
goto_trace_stept::thread_nr
unsigned thread_nr
Definition: goto_trace.h:115
goto_trace_stept::typet::SPAWN
@ SPAWN
show_state_header
void show_state_header(messaget::mstreamt &out, const namespacet &ns, const goto_trace_stept &state, unsigned step_nr, const trace_optionst &options)
Definition: goto_trace.cpp:351
bitvector_typet::get_width
std::size_t get_width() const
Definition: std_types.h:876
goto_trace_stept::typet::MEMORY_BARRIER
@ MEMORY_BARRIER
goto_trace_stept::typet::SHARED_WRITE
@ SHARED_WRITE
goto_trace_stept::merge_ireps
void merge_ireps(merge_irept &dest)
Use dest to establish sharing among ireps.
Definition: goto_trace.cpp:139
goto_trace_stept::cond_value
bool cond_value
Definition: goto_trace.h:118
bvrep2integer
mp_integer bvrep2integer(const irep_idt &src, std::size_t width, bool is_signed)
convert a bit-vector representation (possibly signed) to integer
Definition: arith_tools.cpp:402
trace_optionst::hex_representation
bool hex_representation
Represent plain trace values in hex.
Definition: goto_trace.h:223
trace_optionst::stack_trace
bool stack_trace
Give a stack trace only.
Definition: goto_trace.h:234
format_expr.h
goto_trace_stept::typet::GOTO
@ GOTO
merge_irept
Definition: merge_irep.h:105
show_goto_trace
void show_goto_trace(messaget::mstreamt &out, const namespacet &ns, const goto_tracet &goto_trace, const trace_optionst &options)
Output the trace on the given stream out.
Definition: goto_trace.cpp:792
messaget::red
static const commandt red
render text with red foreground color
Definition: message.h:346
trace_optionst
Options for printing the trace using show_goto_trace.
Definition: goto_trace.h:218
trace_optionst::show_function_calls
bool show_function_calls
Show function calls in plain text trace.
Definition: goto_trace.h:228
trace_optionst::default_options
static const trace_optionst default_options
Definition: goto_trace.h:236
symbolt
Symbol table entry.
Definition: symbol.h:27
numeric_representation
static std::string numeric_representation(const constant_exprt &expr, const namespacet &ns, const trace_optionst &options)
Returns the numeric representation of an expression, based on options.
Definition: goto_trace.cpp:161
to_typecast_expr
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
Definition: std_expr.h:2051
goto_trace_stept::typet::ATOMIC_BEGIN
@ ATOMIC_BEGIN
goto_trace_stept::hidden
bool hidden
Definition: goto_trace.h:100
trace_numeric_value
std::string trace_numeric_value(const exprt &expr, const namespacet &ns, const trace_optionst &options)
Definition: goto_trace.cpp:207
goto_tracet
Trace of a GOTO program.
Definition: goto_trace.h:174
show_goto_stack_trace
static void show_goto_stack_trace(messaget::mstreamt &out, const namespacet &ns, const goto_tracet &goto_trace)
Definition: goto_trace.cpp:717
as_string
std::string as_string(const ai_verifier_statust &status)
Makes a status message string from a status.
Definition: static_verifier.cpp:23
messaget::mstreamt
Definition: message.h:223
to_member_expr
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
Definition: std_expr.h:2886
goto_trace_stept::is_assume
bool is_assume() const
Definition: goto_trace.h:56
exprt::operands
operandst & operands()
Definition: expr.h:94
goto_trace_stept::typet::SHARED_READ
@ SHARED_READ
goto_trace_stept::is_goto
bool is_goto() const
Definition: goto_trace.h:58
integer2binary
const std::string integer2binary(const mp_integer &n, std::size_t width)
Definition: mp_arith.cpp:64
goto_trace_stept::typet::FUNCTION_CALL
@ FUNCTION_CALL
size_type
unsignedbv_typet size_type()
Definition: c_types.cpp:68
constant_exprt
A constant literal expression.
Definition: std_expr.h:2941
constant_exprt::get_value
const irep_idt & get_value() const
Definition: std_expr.h:2950
goto_trace_stept::io_args
io_argst io_args
Definition: goto_trace.h:137
make_range
ranget< iteratort > make_range(iteratort begin, iteratort end)
Definition: range.h:524
goto_trace_stept::function_id
irep_idt function_id
Definition: goto_trace.h:111
c_types.h
from_expr
std::string from_expr(const namespacet &ns, const irep_idt &identifier, const exprt &expr)
Definition: language_util.cpp:38
goto_trace_stept::typet::DEAD
@ DEAD
goto_trace_stept::typet::CONSTRAINT
@ CONSTRAINT
to_constant_expr
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
Definition: std_expr.h:2992
integer2string
const std::string integer2string(const mp_integer &n, unsigned base)
Definition: mp_arith.cpp:103