\n";
+ break;
+
+ case goto_trace_stept::typet::SPAWN:
+ case goto_trace_stept::typet::MEMORY_BARRIER:
+ case goto_trace_stept::typet::ATOMIC_BEGIN:
+ case goto_trace_stept::typet::ATOMIC_END:
+ case goto_trace_stept::typet::DEAD:
+ break;
+
+ case goto_trace_stept::typet::CONSTRAINT:
+ UNREACHABLE;
+ break;
+
+ case goto_trace_stept::typet::SHARED_READ:
+ case goto_trace_stept::typet::SHARED_WRITE:
+ UNREACHABLE;
+ break;
+
+ default:
+ UNREACHABLE;
+ }
+ }
+ output_html_footer(out);
+}
+
+
diff --git a/src/goto-programs/html_goto_trace.h b/src/goto-programs/html_goto_trace.h
new file mode 100644
index 00000000000..23fd8eb617e
--- /dev/null
+++ b/src/goto-programs/html_goto_trace.h
@@ -0,0 +1,26 @@
+/*******************************************************************\
+
+Module: HTML Traces of GOTO Programs
+
+Author: elizabeth.polgreen@cs.ox.ac.uk
+
+ Date: October 2017
+
+\*******************************************************************/
+
+/// \file
+/// HTML races of GOTO Programs
+
+#ifndef CPROVER_GOTO_PROGRAMS_HTML_GOTO_TRACE_H_
+#define CPROVER_GOTO_PROGRAMS_HTML_GOTO_TRACE_H_
+
+#include
+
+void show_html_goto_trace(
+ std::ostream &,
+ const namespacet &,
+ const goto_tracet &);
+
+
+
+#endif /* CPROVER_GOTO_PROGRAMS_HTML_GOTO_TRACE_H_ */
From 6725c8c3b47a3beb563654eb1b48d8b6790dcbdc Mon Sep 17 00:00:00 2001
From: polgreen
Date: Wed, 18 Oct 2017 12:09:14 +0200
Subject: [PATCH 03/13] Output function calls in trace
if trace-verbosity is set to 3 or higher, output the function calls and function returns
NOTE: this command line interface is cleaned up in the future commit that introduces global trace_configurationt: 235bb01
---
src/goto-programs/goto_trace.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/goto-programs/goto_trace.cpp b/src/goto-programs/goto_trace.cpp
index 7fc27784b61..026d34a8e00 100644
--- a/src/goto-programs/goto_trace.cpp
+++ b/src/goto-programs/goto_trace.cpp
@@ -496,7 +496,14 @@ void show_goto_trace(
break;
case goto_trace_stept::typet::FUNCTION_CALL:
+ if(verbosity > 2)
+ out<< "Function call: " << as_string(ns, *step.pc) << "\n";
+ break;
case goto_trace_stept::typet::FUNCTION_RETURN:
+ if(verbosity > 2)
+ out<< "Function return from: " << as_string(ns, *step.pc) << "\n";
+ break;
+
case goto_trace_stept::typet::SPAWN:
case goto_trace_stept::typet::MEMORY_BARRIER:
case goto_trace_stept::typet::ATOMIC_BEGIN:
From 24a4875fcdbcf8b6b2d50dea56a5cc46c3f3d483 Mon Sep 17 00:00:00 2001
From: polgreen
Date: Fri, 20 Oct 2017 15:26:46 +0200
Subject: [PATCH 04/13] Change "violated assumption" to "assumption" in trace
CBMC doesn't violate assumptions, it violates assertions
---
src/goto-programs/goto_trace.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/goto-programs/goto_trace.cpp b/src/goto-programs/goto_trace.cpp
index 026d34a8e00..d8463c103f0 100644
--- a/src/goto-programs/goto_trace.cpp
+++ b/src/goto-programs/goto_trace.cpp
@@ -379,7 +379,7 @@ void show_goto_trace(
if(!step.cond_value)
{
out << "\n";
- out << "Violated assumption:" << "\n";
+ out << "Assumption:" << "\n";
if(!step.pc->source_location.is_nil())
out << " " << step.pc->source_location << "\n";
From 7a1dca753fb80174e7badb49454a41302665f46e Mon Sep 17 00:00:00 2001
From: polgreen
Date: Fri, 20 Oct 2017 15:28:29 +0200
Subject: [PATCH 05/13] Add trace_configuration struct to global config
Introduces trace_configurationt, which tidies up the multiple command line options introduced for configuring the trace output
Adds cmd line options to help file and to cbmc_parse_optionst
Note that this is only implemented for CBMC, I am working in a repository that doesn't contain symex.
---
src/cbmc/cbmc_parse_options.cpp | 59 ++++++++++++++++++++++++++++-----
src/cbmc/cbmc_parse_options.h | 6 ++--
src/util/config.h | 14 ++++++++
3 files changed, 69 insertions(+), 10 deletions(-)
diff --git a/src/cbmc/cbmc_parse_options.cpp b/src/cbmc/cbmc_parse_options.cpp
index a1431046224..47ccd9891c2 100644
--- a/src/cbmc/cbmc_parse_options.cpp
+++ b/src/cbmc/cbmc_parse_options.cpp
@@ -102,6 +102,47 @@ void cbmc_parse_optionst::eval_verbosity()
ui_message_handler.set_verbosity(v);
}
+void cbmc_parse_optionst::configure_trace_output()
+{
+
+ if(cmdline.isset("trace-hex"))
+ config.trace_config.numeric_representation =
+ configt::numeric_representationt::HEX;
+ else
+ config.trace_config.numeric_representation =
+ configt::numeric_representationt::BINARY;
+
+ if(cmdline.isset("trace-show-source-code"))
+ config.trace_config.show_source_code=true;
+ else
+ config.trace_config.show_source_code=false;
+
+ if(cmdline.isset("trace-hide-assignments"))
+ config.trace_config.show_value_assignments=false;
+ else
+ config.trace_config.show_value_assignments=true;
+
+ if(cmdline.isset("trace-hide-inputs"))
+ config.trace_config.show_inputs=false;
+ else
+ config.trace_config.show_inputs=true;
+
+ if(cmdline.isset("trace-hide-outputs"))
+ config.trace_config.show_outputs=false;
+ else
+ config.trace_config.show_outputs=true;
+
+ if(cmdline.isset("trace-show-function-calls"))
+ config.trace_config.show_function_calls=true;
+ else
+ config.trace_config.show_function_calls=false;
+
+ if(cmdline.isset("html-trace"))
+ config.trace_config.trace_format = configt::trace_formatt::HTML;
+ else
+ config.trace_config.trace_format = configt::trace_formatt::STANDARD;
+}
+
void cbmc_parse_optionst::get_command_line_options(optionst &options)
{
if(config.set(cmdline))
@@ -156,14 +197,7 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
cmdline.isset("stop-on-fail"))
{
options.set_option("trace", true);
- if(cmdline.isset("hex"))
- options.set_option("hex", true);
-
- if(cmdline.isset("trace-verbosity"))
- options.set_option("trace-verbosity",
- cmdline.get_value("trace-verbosity"));
- else
- options.set_option("trace-verbosity", 1);
+ configure_trace_output();
}
if(cmdline.isset("localize-faults"))
@@ -1034,5 +1068,14 @@ void cbmc_parse_optionst::help()
" --xml-interface bi-directional XML interface\n"
" --json-ui use JSON-formatted output\n"
" --verbosity # verbosity level\n"
+ "\n"
+ "Trace formatting options\n"
+ "--trace-show-function-calls show functions calls and returns in trace (default is to hide)\n" // NOLINT(*)
+ "--trace-hide-assignments show all assignments in trace (default is to show)\n" // NOLINT(*)
+ "--trace-hide-inputs show all inputs in trace (default is to show)\n" // NOLINT(*)
+ "--trace-hide-outputs show all outputs in trace (default is to show)\n" // NOLINT(*)
+ "--trace-show-source-code show lines of source code (default is to hide)\n" // NOLINT(*)
+ "--trace-hex outputs assignments to variables in hex (default is binary)\n" // NOLINT(*)
+ "--html-trace outputs trace in html format\n"
"\n";
}
diff --git a/src/cbmc/cbmc_parse_options.h b/src/cbmc/cbmc_parse_options.h
index b28c37d2d25..945b8137ee8 100644
--- a/src/cbmc/cbmc_parse_options.h
+++ b/src/cbmc/cbmc_parse_options.h
@@ -53,8 +53,9 @@ class optionst;
"(show-claims)(claim):(show-properties)" \
"(drop-unused-functions)" \
"(property):(stop-on-fail)(trace)" \
- "(hex)" \
- "(trace-verbosity):" \
+ "(trace-hex)(trace-show-source-code)(trace-hide-assignments)"\
+ "(trace-show-function-calls)(html-trace)(trace-hide-inputs)" \
+ "(trace-hide-outputs)" \
"(error-label):(verbosity):(no-library)" \
"(nondet-static)" \
"(version)" \
@@ -91,6 +92,7 @@ class cbmc_parse_optionst:
void eval_verbosity();
void register_languages();
void get_command_line_options(optionst &);
+ void configure_trace_output();
void preprocessing();
int get_goto_program(const optionst &);
bool process_goto_program(const optionst &);
diff --git a/src/util/config.h b/src/util/config.h
index 8031b872d3e..f392a1ec3e5 100644
--- a/src/util/config.h
+++ b/src/util/config.h
@@ -24,6 +24,20 @@ class namespacet;
class configt
{
public:
+ typedef enum { STANDARD, HTML } trace_formatt;
+ typedef enum { HEX, BINARY } numeric_representationt;
+
+ struct trace_configurationt
+ {
+ bool show_function_calls;
+ bool show_source_code;
+ bool show_inputs;
+ bool show_outputs;
+ bool show_value_assignments;
+ numeric_representationt numeric_representation;
+ trace_formatt trace_format;
+ } trace_config;
+
struct ansi_ct
{
// for ANSI-C
From cb560d3f92fd4682efb9ef27cb5f54e7f0ee19e0 Mon Sep 17 00:00:00 2001
From: polgreen
Date: Tue, 24 Oct 2017 11:29:03 +0200
Subject: [PATCH 06/13] Tidy up CBMC parse_options trace configuration
---
src/cbmc/cbmc_parse_options.cpp | 37 ++++++++++++---------------------
1 file changed, 13 insertions(+), 24 deletions(-)
diff --git a/src/cbmc/cbmc_parse_options.cpp b/src/cbmc/cbmc_parse_options.cpp
index 47ccd9891c2..32009b1b665 100644
--- a/src/cbmc/cbmc_parse_options.cpp
+++ b/src/cbmc/cbmc_parse_options.cpp
@@ -104,7 +104,6 @@ void cbmc_parse_optionst::eval_verbosity()
void cbmc_parse_optionst::configure_trace_output()
{
-
if(cmdline.isset("trace-hex"))
config.trace_config.numeric_representation =
configt::numeric_representationt::HEX;
@@ -112,30 +111,20 @@ void cbmc_parse_optionst::configure_trace_output()
config.trace_config.numeric_representation =
configt::numeric_representationt::BINARY;
- if(cmdline.isset("trace-show-source-code"))
- config.trace_config.show_source_code=true;
- else
- config.trace_config.show_source_code=false;
+ config.trace_config.show_source_code =
+ cmdline.isset("trace-show-source-code");
- if(cmdline.isset("trace-hide-assignments"))
- config.trace_config.show_value_assignments=false;
- else
- config.trace_config.show_value_assignments=true;
+ config.trace_config.show_value_assignments =
+ !cmdline.isset("trace-hide-assignments");
- if(cmdline.isset("trace-hide-inputs"))
- config.trace_config.show_inputs=false;
- else
- config.trace_config.show_inputs=true;
+ config.trace_config.show_inputs =
+ !cmdline.isset("trace-hide-inputs");
- if(cmdline.isset("trace-hide-outputs"))
- config.trace_config.show_outputs=false;
- else
- config.trace_config.show_outputs=true;
+ config.trace_config.show_outputs =
+ !cmdline.isset("trace-hide-ouputs");
- if(cmdline.isset("trace-show-function-calls"))
- config.trace_config.show_function_calls=true;
- else
- config.trace_config.show_function_calls=false;
+ config.trace_config.show_function_calls =
+ cmdline.isset("trace-show-function-calls");
if(cmdline.isset("html-trace"))
config.trace_config.trace_format = configt::trace_formatt::HTML;
@@ -1071,9 +1060,9 @@ void cbmc_parse_optionst::help()
"\n"
"Trace formatting options\n"
"--trace-show-function-calls show functions calls and returns in trace (default is to hide)\n" // NOLINT(*)
- "--trace-hide-assignments show all assignments in trace (default is to show)\n" // NOLINT(*)
- "--trace-hide-inputs show all inputs in trace (default is to show)\n" // NOLINT(*)
- "--trace-hide-outputs show all outputs in trace (default is to show)\n" // NOLINT(*)
+ "--trace-hide-assignments hide all assignments in trace (default is to show)\n" // NOLINT(*)
+ "--trace-hide-inputs hide all inputs in trace (default is to show)\n" // NOLINT(*)
+ "--trace-hide-outputs hide all outputs in trace (default is to show)\n" // NOLINT(*)
"--trace-show-source-code show lines of source code (default is to hide)\n" // NOLINT(*)
"--trace-hex outputs assignments to variables in hex (default is binary)\n" // NOLINT(*)
"--html-trace outputs trace in html format\n"
From d88d5d68c290df80367d924691a0d22f72bd6d30 Mon Sep 17 00:00:00 2001
From: polgreen
Date: Fri, 20 Oct 2017 15:31:21 +0200
Subject: [PATCH 07/13] switch show_goto_trace to use trace_configurationt
In this commit:
- switches goto_trace to use trace_configurationt
- rewrites trace_value to avoid passing 4 different members of the same struct goto_trace_stept by reference
- moves the code that displays source code into show_state_header
- modernises the for loops used in case INPUT and case OUTPUT
- replaces "\n" with '\n'
---
src/cbmc/all_properties.cpp | 4 +-
src/cbmc/bmc.cpp | 4 +-
src/goto-programs/goto_trace.cpp | 305 +++++++++++++++----------------
src/goto-programs/goto_trace.h | 26 +--
4 files changed, 153 insertions(+), 186 deletions(-)
diff --git a/src/cbmc/all_properties.cpp b/src/cbmc/all_properties.cpp
index fdedc051e19..cce96904495 100644
--- a/src/cbmc/all_properties.cpp
+++ b/src/cbmc/all_properties.cpp
@@ -175,9 +175,7 @@ void bmc_all_propertiest::report(const cover_goalst &cover_goals)
if(g.second.status==goalt::statust::FAILURE)
{
result() << "\n" << "Trace for " << g.first << ":" << "\n";
- show_goto_trace(result(), bmc.ns, g.second.goto_trace,
- bmc.options.get_signed_int_option("trace-verbosity"),
- bmc.options.get_bool_option("hex"));
+ show_goto_trace(result(), bmc.ns, g.second.goto_trace);
}
}
result() << eom;
diff --git a/src/cbmc/bmc.cpp b/src/cbmc/bmc.cpp
index 24b76872477..f9ede133877 100644
--- a/src/cbmc/bmc.cpp
+++ b/src/cbmc/bmc.cpp
@@ -56,9 +56,7 @@ void bmct::error_trace()
{
case ui_message_handlert::uit::PLAIN:
result() << "Counterexample:" << eom;
- show_goto_trace(result(), ns, goto_trace,
- options.get_signed_int_option("trace-verbosity"),
- options.get_bool_option("hex"));
+ show_goto_trace(result(), ns, goto_trace);
result() << eom;
break;
diff --git a/src/goto-programs/goto_trace.cpp b/src/goto-programs/goto_trace.cpp
index d8463c103f0..635b2814298 100644
--- a/src/goto-programs/goto_trace.cpp
+++ b/src/goto-programs/goto_trace.cpp
@@ -17,6 +17,7 @@ Author: Daniel Kroening
#include
#include
+#include
#include
#include
@@ -58,7 +59,7 @@ void goto_trace_stept::output(
case goto_trace_stept::typet::FUNCTION_RETURN:
out << "FUNCTION RETURN"; break;
default:
- out << "unknown type: " << static_cast(type) << "\n";
+ out << "unknown type: " << static_cast(type) << '\n';
UNREACHABLE;
}
@@ -68,10 +69,10 @@ void goto_trace_stept::output(
if(hidden)
out << " hidden";
- out << "\n";
+ out << '\n';
if(!pc->source_location.is_nil())
- out << pc->source_location << "\n";
+ out << pc->source_location << '\n';
if(pc->is_goto())
out << "GOTO ";
@@ -92,31 +93,31 @@ void goto_trace_stept::output(
else
out << "(?) ";
- out << "\n";
+ out << '\n';
if((pc->is_other() && lhs_object.is_not_nil()) || pc->is_assign())
{
irep_idt identifier=lhs_object.get_object_name();
out << " " << from_expr(ns, identifier, lhs_object.get_original_expr())
<< " = " << from_expr(ns, identifier, lhs_object_value)
- << "\n";
+ << '\n';
}
else if(pc->is_assert())
{
if(!cond_value)
{
- out << "Violated property:" << "\n";
+ out << "Violated property:" << '\n';
if(pc->source_location.is_nil())
- out << " " << pc->source_location << "\n";
+ out << " " << pc->source_location << '\n';
if(comment!="")
- out << " " << comment << "\n";
- out << " " << from_expr(ns, "", pc->guard) << "\n";
- out << "\n";
+ out << " " << comment << '\n';
+ out << " " << from_expr(ns, "", pc->guard) << '\n';
+ out << '\n';
}
}
- out << "\n";
+ out << '\n';
}
static std::string expr_to_hex(const exprt & expr)
@@ -254,100 +255,79 @@ std::string trace_value_binary(
return "?";
}
+static bool is_index_member_symbol(const exprt &src)
+{
+ if(src.id()==ID_index)
+ return is_index_member_symbol(src.op0());
+ else if(src.id()==ID_member)
+ return is_index_member_symbol(src.op0());
+ else if(src.id()==ID_symbol)
+ return true;
+ else
+ return false;
+}
+
void trace_value(
std::ostream &out,
const namespacet &ns,
- const ssa_exprt &lhs_object,
- const exprt &full_lhs,
- const exprt &value,
- bool hex)
+ const goto_trace_stept &step)
{
+ bool member_symbol = is_index_member_symbol(step.full_lhs);
+ exprt value = member_symbol ? step.full_lhs_value : step.lhs_object_value;
+
irep_idt identifier;
- if(lhs_object.is_not_nil())
- identifier=lhs_object.get_object_name();
+ if(step.lhs_object.is_not_nil())
+ identifier=step.lhs_object.get_object_name();
std::string value_string;
+
if(value.is_nil())
value_string="(assignment removed)";
else
{
value_string=from_expr(ns, identifier, value);
- // the binary representation
- if(hex)
+ if(config.trace_config.numeric_representation ==
+ configt::numeric_representationt::HEX)
value_string += " (" + trace_value_hex(value, ns) + ")";
else
value_string += " (" + trace_value_binary(value, ns) + ")";
}
out << " "
- << from_expr(ns, identifier, full_lhs)
- << "=" << value_string
- << "\n";
+ << from_expr(ns, identifier,
+ (member_symbol ? step.full_lhs : step.lhs_object))
+ << "=" << value_string << '\n';
}
-void trace_value(
- std::ostream &out,
- const namespacet &ns,
- const ssa_exprt &lhs_object,
- const exprt &full_lhs,
- const exprt &value)
-{
- // default use binary representation
- trace_value(out, ns, lhs_object, full_lhs, value, false);
-}
-void show_state_header(
+static void show_state_header(
std::ostream &out,
- const goto_trace_stept &state,
- const source_locationt &source_location,
- unsigned step_nr)
+ const namespacet &ns,
+ const goto_trace_stept &state)
{
- out << "\n";
+ out << '\n';
- if(step_nr==0)
+ if(state.step_nr==0)
out << "Initial State";
else
- out << "State " << step_nr;
+ out << "State " << state.step_nr;
- out << " " << source_location
- << " thread " << state.thread_nr << "\n";
- out << "----------------------------------------------------" << "\n";
-}
+ out << " " << state.pc->source_location
+ << " thread " << state.thread_nr << '\n';
+ out << "----------------------------------------------------" << '\n';
-bool is_index_member_symbol(const exprt &src)
-{
- if(src.id()==ID_index)
- return is_index_member_symbol(src.op0());
- else if(src.id()==ID_member)
- return is_index_member_symbol(src.op0());
- else if(src.id()==ID_symbol)
- return true;
- else
- return false;
+ if(config.trace_config.show_source_code)
+ out << "Code: " << as_string(ns, *state.pc) << '\n';
}
-void show_goto_trace(
- std::ostream &out,
- const namespacet &ns,
- const goto_tracet &goto_trace)
-{
- show_goto_trace(out, ns, goto_trace, 1, false);
-}
-
-void show_goto_trace(
+static void show_standard_goto_trace(
std::ostream &out,
const namespacet &ns,
- const goto_tracet &goto_trace,
- int verbosity,
- bool print_hex)
+ const goto_tracet &goto_trace)
{
- if(verbosity==10)
- show_html_goto_trace(out, ns, goto_trace);
- else
- {
unsigned prev_step_nr=0;
bool first_step=true;
@@ -362,31 +342,31 @@ void show_goto_trace(
case goto_trace_stept::typet::ASSERT:
if(!step.cond_value)
{
- out << "\n";
- out << "Violated property:" << "\n";
+ out << '\n';
+ out << "Violated property:" << '\n';
if(!step.pc->source_location.is_nil())
- out << " " << step.pc->source_location << "\n";
- out << " " << step.comment << "\n";
+ out << " " << step.pc->source_location << '\n';
+ out << " " << step.comment << '\n';
if(step.pc->is_assert())
- out << " " << from_expr(ns, "", step.pc->guard) << "\n";
+ out << " " << from_expr(ns, "", step.pc->guard) << '\n';
- out << "\n";
+ out << '\n';
}
break;
case goto_trace_stept::typet::ASSUME:
if(!step.cond_value)
{
- out << "\n";
- out << "Assumption:" << "\n";
+ out << '\n';
+ out << "Assumption:" << '\n';
if(!step.pc->source_location.is_nil())
- out << " " << step.pc->source_location << "\n";
+ out << " " << step.pc->source_location << '\n';
if(step.pc->is_assume())
- out << " " << from_expr(ns, "", step.pc->guard) << "\n";
+ out << " " << from_expr(ns, "", step.pc->guard) << '\n';
- out << "\n";
+ out << '\n';
}
break;
@@ -397,111 +377,105 @@ void show_goto_trace(
break;
case goto_trace_stept::typet::ASSIGNMENT:
- if(step.pc->is_assign() ||
- step.pc->is_return() || // returns have a lhs!
- step.pc->is_function_call() ||
- (step.pc->is_other() && step.lhs_object.is_not_nil()))
+ if(config.trace_config.show_value_assignments)
{
- if(prev_step_nr!=step.step_nr || first_step)
+ if(step.pc->is_assign() || step.pc->is_return()
+ || // returns have a lhs!
+ step.pc->is_function_call()
+ || (step.pc->is_other() && step.lhs_object.is_not_nil()))
{
- first_step=false;
- prev_step_nr=step.step_nr;
- show_state_header(out, step, step.pc->source_location, step.step_nr);
- if(verbosity>1)
- out << "Code: " << as_string(ns, *step.pc) << "\n";
+ if(prev_step_nr != step.step_nr || first_step)
+ {
+ first_step = false;
+ prev_step_nr = step.step_nr;
+ show_state_header(out, ns, step);
+ }
+ trace_value(out, ns, step);
}
-
- // see if the full lhs is something clean
- if(is_index_member_symbol(step.full_lhs))
- trace_value(
- out, ns, step.lhs_object, step.full_lhs,
- step.full_lhs_value, print_hex);
- else
- trace_value(
- out, ns, step.lhs_object, step.lhs_object,
- step.lhs_object_value, print_hex);
}
break;
case goto_trace_stept::typet::DECL:
- if(prev_step_nr!=step.step_nr || first_step)
+ if(config.trace_config.show_value_assignments)
{
- first_step=false;
- prev_step_nr=step.step_nr;
- show_state_header(out, step, step.pc->source_location, step.step_nr);
- if(verbosity>1)
- out << "Code: " << as_string(ns, *step.pc) << "\n";
- }
+ if(prev_step_nr != step.step_nr || first_step)
+ {
+ first_step = false;
+ prev_step_nr = step.step_nr;
+ show_state_header(out, ns, step);
+ }
- trace_value(out, ns, step.lhs_object, step.full_lhs,
- step.full_lhs_value, print_hex);
- break;
+ trace_value(out, ns, step);
+ }
+ break;
case goto_trace_stept::typet::OUTPUT:
- if(step.formatted)
+ if(config.trace_config.show_outputs)
{
- printf_formattert printf_formatter(ns);
- printf_formatter(id2string(step.format_string), step.io_args);
- printf_formatter.print(out);
- out << "\n";
- }
- else
- {
- show_state_header(out, step, step.pc->source_location, step.step_nr);
- if(verbosity>1)
- out << "Code: " << as_string(ns, *step.pc) << "\n";
- out << " OUTPUT " << step.io_id << ":";
-
- for(std::list::const_iterator
- l_it=step.io_args.begin();
- l_it!=step.io_args.end();
- l_it++)
+ if(step.formatted)
{
- if(l_it != step.io_args.begin())
- out << ";";
- out << " " << from_expr(ns, "", *l_it);
-
- if(print_hex)
- out << " (" << trace_value_hex(*l_it, ns) << ")";
- else
- out << " (" << trace_value_binary(*l_it, ns) << ")";
+ printf_formattert printf_formatter(ns);
+ printf_formatter(id2string(step.format_string), step.io_args);
+ printf_formatter.print(out);
+ out << '\n';
+ }
+ else
+ {
+ show_state_header(out, ns, step);
+ out << " OUTPUT " << step.io_id << ":";
+
+ bool first_output = true;
+ for(const auto &arg : step.io_args)
+ {
+ if(!first_output)
+ out << ";";
+ out << " " << from_expr(ns, "", arg);
+
+ if(config.trace_config.numeric_representation ==
+ configt::numeric_representationt::HEX)
+ out << " (" << trace_value_hex(arg, ns) << ")";
+ else
+ out << " (" << trace_value_binary(arg, ns) << ")";
+ first_output = false;
+ }
+
+ out << '\n';
}
-
- out << "\n";
}
break;
case goto_trace_stept::typet::INPUT:
- show_state_header(out, step, step.pc->source_location, step.step_nr);
- if(verbosity>1)
- out << "Code: " << as_string(ns, *step.pc) << "\n";
- out << " INPUT " << step.io_id << ":";
-
- for(std::list::const_iterator
- l_it=step.io_args.begin();
- l_it!=step.io_args.end();
- l_it++)
+ if(config.trace_config.show_inputs)
{
- if(l_it!=step.io_args.begin())
- out << ";";
- out << " " << from_expr(ns, "", *l_it);
+ show_state_header(out, ns, step);
+ out << " INPUT " << step.io_id << ":";
- if(print_hex)
- out << " (" << trace_value_hex(*l_it, ns) << ")";
- else
- out << " (" << trace_value_binary(*l_it, ns) << ")";
- }
+ bool first_input = true;
+ for(const auto &arg : step.io_args)
+ {
+ if(!first_input)
+ out << ";";
+ out << " " << from_expr(ns, "", arg);
+
+ if(config.trace_config.numeric_representation ==
+ configt::numeric_representationt::HEX)
+ out << " (" << trace_value_hex(arg, ns) << ")";
+ else
+ out << " (" << trace_value_binary(arg, ns) << ")";
+ first_input = false;
+ }
- out << "\n";
+ out << '\n';
+ }
break;
case goto_trace_stept::typet::FUNCTION_CALL:
- if(verbosity > 2)
- out<< "Function call: " << as_string(ns, *step.pc) << "\n";
+ if(config.trace_config.show_function_calls)
+ out << "Function call: " << as_string(ns, *step.pc) << '\n';
break;
case goto_trace_stept::typet::FUNCTION_RETURN:
- if(verbosity > 2)
- out<< "Function return from: " << as_string(ns, *step.pc) << "\n";
+ if(config.trace_config.show_function_calls)
+ out << "Function return from: " << as_string(ns, *step.pc) << '\n';
break;
case goto_trace_stept::typet::SPAWN:
@@ -518,5 +492,16 @@ void show_goto_trace(
UNREACHABLE;
}
}
- }
}
+
+void show_goto_trace(
+ std::ostream &out,
+ const namespacet &ns,
+ const goto_tracet &goto_trace)
+{
+ if(config.trace_config.trace_format == configt::trace_formatt::HTML)
+ show_html_goto_trace(out, ns, goto_trace);
+ else
+ show_standard_goto_trace(out, ns, goto_trace);
+}
+
diff --git a/src/goto-programs/goto_trace.h b/src/goto-programs/goto_trace.h
index 849d60e0d27..22e1801e7ff 100644
--- a/src/goto-programs/goto_trace.h
+++ b/src/goto-programs/goto_trace.h
@@ -29,6 +29,7 @@ Date: July 2005
#include
+//
/*! \brief TO_BE_DOCUMENTED
* \ingroup gr_goto_symex
*/
@@ -194,32 +195,19 @@ class goto_tracet
}
};
+/// \brief print the goto trace
+/// \param ostream, namespace, goto_trace
+/// trace_configuration.
void show_goto_trace(
std::ostream &out,
const namespacet &,
const goto_tracet &);
-void show_goto_trace(
- std::ostream &out,
- const namespacet &,
- const goto_tracet &,
- int verbosity,
- bool print_hex);
-
void trace_value(
- std::ostream &out,
+ std::ostream &,
const namespacet &,
- const ssa_exprt &lhs_object,
- const exprt &full_lhs,
- const exprt &value);
+ const goto_trace_stept &);
-void trace_value(
- std::ostream &out,
- const namespacet &,
- const ssa_exprt &lhs_object,
- const exprt &full_lhs,
- const exprt &value,
- bool use_hex);
std::string trace_value_binary(
const exprt &,
@@ -229,6 +217,4 @@ std::string trace_value_hex(
const exprt &,
const namespacet &);
-bool is_index_member_symbol(const exprt &);
-
#endif // CPROVER_GOTO_PROGRAMS_GOTO_TRACE_H
From c05ab1871e42cad54bbadc70376313b9c2a44fb2 Mon Sep 17 00:00:00 2001
From: polgreen
Date: Fri, 20 Oct 2017 15:32:58 +0200
Subject: [PATCH 08/13] Update html_goto_trace to use trace_configurationt
The HTML trace now has the same configuration options as the standard trace, and uses the global trace_config variable.
This commit also modernises some for loops used in case INPUT and case OUTPUT
---
src/goto-programs/html_goto_trace.cpp | 196 +++++++++++++-------------
src/goto-programs/html_goto_trace.h | 1 -
2 files changed, 97 insertions(+), 100 deletions(-)
diff --git a/src/goto-programs/html_goto_trace.cpp b/src/goto-programs/html_goto_trace.cpp
index 15a294f2336..fa15cd554fb 100644
--- a/src/goto-programs/html_goto_trace.cpp
+++ b/src/goto-programs/html_goto_trace.cpp
@@ -17,6 +17,7 @@ Author: elizabeth.polgreen@cs.ox.ac.uk
#include
#include
+#include
#include
#include
@@ -61,22 +62,25 @@ void output_html_footer(std::ostream &out)
void show_html_state_header(
- std::ostream &out,
- const goto_trace_stept &state,
- const source_locationt &source_location,
- unsigned step_nr)
+ std::ostream &out,
+ const namespacet &ns,
+ const goto_trace_stept &state)
{
out << "\n\n";
out << "
";
- if(step_nr==0)
+ if(state.step_nr==0)
out << "Initial State";
else
- out << "State " << step_nr << "";
+ out << "State " << state.step_nr << "";
- out << " " << source_location
+ out << " " << state.pc->source_location
<< " thread " << state.thread_nr
<< ">
\n";
+
+ if(config.trace_config.show_source_code)
+ out << "
Code: "
+ << as_string(ns, *state.pc) << "
\n";
}
@@ -88,7 +92,6 @@ void show_html_goto_trace(
unsigned prev_step_nr=0;
bool first_step=true;
bool use_panel1=true;
- bool use_hex=true; // at some point this will become a cmd line argument
output_html_header(out);
for(const auto &step : goto_trace.steps)
@@ -110,8 +113,8 @@ void show_html_goto_trace(
out << "