-
Notifications
You must be signed in to change notification settings - Fork 273
Trace output configuration options #1565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces cmd line options --hex and --trace-verbosity --hex outputs all trace values in hex instead of binary setting --trace-verbosity >1 will output the corresponding line of source code with each state If numbers stop being stored as binary, this implementation will need to change, but this also applies to the binary output. NOTE: The command line interfaces for this are tidied up in a future commit that introduces trace_configurationt: 235bb01
This outputs HTML to the command line. The trace is represented in a javascript accordion, with collapsible functions. NOTE: the command line interface is cleaned up in this future commit, to use the global trace_configurationt: 6b6098c
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
CBMC doesn't violate assumptions, it violates assertions
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.
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'
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
@polgreen Please adjust the assert to fix the linter faillure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nitpicks, plus two substantiative changes I'd recommend:
-
Deeptest has some fork of this file; I know they'd appreciate it if the changes to the plaintext goto-trace were restructured to minimise the diff size -- for example, omitting changing
"\n"
to'\n'
everywhere, and avoiding code structure that requires re-indenting every line -
At least JBMC should surely also support this feature, so I suggest moving the command-line options and help text into the feature header and including it in the same way as we already do for GOTO_CHECK_OPT and the similar argument spec for the Java frontend.
} | ||
|
||
static std::string expr_to_hex(const exprt & expr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: exprt &expr
} | ||
|
||
static std::string expr_to_hex(const exprt & expr) | ||
{ | ||
mp_integer value_int=binary2integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style:
binary2integer(
id2string(to_constant_expr(expr).get_value()),
false);
|
||
std::string value_string; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra line?
<< from_expr(ns, identifier, full_lhs) | ||
<< "=" << value_string | ||
<< "\n"; | ||
<< from_expr(ns, identifier, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: either
from_expr(
ns, identifier, (member_symbol ? step.full_lhs : step.lhs_object))
or
from_expr(
ns,
identifier,
(member_symbol ? step.full_lhs : step.lhs_object))
} | ||
|
||
void show_state_header( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra line
void show_goto_trace( | ||
std::ostream &out, | ||
const namespacet &, | ||
const goto_tracet &); | ||
|
||
void trace_value( | ||
std::ostream &out, | ||
std::ostream &, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the param name, it's (marginally) informative?
void output_html_header(std::ostream &out) | ||
{ | ||
out << "<!DOCTYPE html> \n" << "<html> \n" << "<head> \n" << "<style> \n" | ||
<< "button.function_call{ background-color: #eee; color: Black; cursor: pointer; \n" // NOLINT(*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest a break after each property to make this easier on people hand-editing the HTML or editing this code
<< "div.panel1 { padding: 0 18px; display: none; background-color: AliceBlue; border: 1px solid gray } \n" // NOLINT(*) | ||
<< "div.panel2 { padding: 0 18px; display: none; background-color: CornSilk; border: 1px solid gray} \n" // NOLINT(*) | ||
<< "div.property_panel { padding: 0 18px; display: block; background-color: LightGray; border: 1px red} \n" // NOLINT(*) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're doing style we should probably do so everywhere, and turn e.g. <strong><span style=\"color: Red;\">
below into <span class=\"violated_property\">
, rather than intermixing out-of-line and inline style.
|
||
out << " " << state.pc->source_location | ||
<< " thread " << state.thread_nr | ||
<< "</strong>></p>\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo >>
case goto_trace_stept::typet::ASSIGNMENT: | ||
if(config.trace_config.show_value_assignments) | ||
{ | ||
if(step.pc->is_assign() || step.pc->is_return() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One disjunct per line?
Ok, 1a) I added all the changes from "\n" to '\n' at Michael's request. I can revert them, but could you and Michael reach a consensus about that before I spend the time doing it?
I've currently got one failing java regression test, which I can fix if I give the trace_configurationt default values. Is using default values here acceptable? |
Inclusion of Similarly its help text is factored so it doesn't have to be duplicated across different driver programs: https://github.com/diffblue/cbmc/blob/develop/src/cbmc/cbmc_parse_options.cpp#L974 Basically I'd move the help text, the options and the parser function (https://github.com/diffblue/cbmc/pull/1565/files#diff-41db988013f70caad45ce489749c7df6R105) alongside the feature, then you can trivially include it in both |
@tautschnig willing to keep |
One more thing, there should be a couple of regression and/or unit tests for this, otherwise it's likely to moulder |
@polgreen @smowton As much as I think using |
strings-smoke-tests \ | ||
test-script \ | ||
DIRS = cbmc-java \ | ||
#cbmc-java-inheritance \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo this spurious change
config.trace_config.numeric_representation = | ||
configt::numeric_representationt::BINARY; | ||
|
||
config.trace_config.show_source_code = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using config
for this kind of settings is uncommon. Use options.
"--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(*) | ||
"--trace-html outputs trace in html format\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the result of using --trace-html
together with --json-ui
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json overrides. I don't know what the expected result should be, but the json trace doesn't use any of my new configuration options
@@ -17,10 +17,12 @@ Author: Daniel Kroening | |||
#include <ostream> | |||
|
|||
#include <util/arith_tools.h> | |||
#include <util/config.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following our efforts to get rid of the global config
eventually, this dependency should be avoided.
Further suggestions: use clang-format and add doxygen comments to newly introduced functions. |
The failing of some unit tests (which looks somehow unrelated) is concerning: https://travis-ci.org/diffblue/cbmc/jobs/298527593#L2227 |
The failing regression tests are java tests and it's because I haven't integrated this into the jbmc front end properly yet, will fix |
resurrecting this PR. @peterschrammel, you requested that I don't use config, and use options instead. That means I will have to change the function signature for several intermediate functions that options will need to be passed to. Is that ok? @tautschnig, I think we talked about this when i was originally implementing this and you suggested using config instead of options, I think for that reason? |
I suggest to turn |
Yes, using |
I'm redoing this PR. |
Closing as this appears to have been long abandoned. Please reopen and update if this closure is erroneous. |
This pull request adds the following configuration options for the trace output:
--trace-show-function-calls show functions calls and returns in trace (default is to hide)
--trace-hide-assignments hide all assignments in trace (default is to show)
--trace-hide-inputs hide all inputs in trace (default is to show)
--trace-hide-outputs hide all outputs in trace (default is to show)
--trace-show-source-code show lines of source code (default is to hide)
--trace-hex outputs assignments to variables in hex (default is binary)
--trace-html outputs trace in html format
The default, if no command line options are used, maintains the same output as before. The xml and json outputs are unaffected.