Skip to content

Basic placeholder information about cprover printing. #3392

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

Merged

Conversation

sonodtt
Copy link
Contributor

@sonodtt sonodtt commented Nov 13, 2018

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Basic information about Cprover printing.
Placeholder in util folder readme for some generic information about the types of classes / locations where Cprover can provide output.

Exceptions also print to std::cerr - and have a standard 'what()' interface. More information on exceptions can be found in `exception_utils.h`.

* messages - filtered by a 'verbosity' level.
\ref messaget provides messages with a built-in verbosity 'level'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe provide a link to the appropriate header file as well, and not just to the type?

* output from invariants / exceptions
Invariants output to std::cerr - and provide a backtrace and optionally some diagnostic information.
For more information on invariants, see `invariant.h`
Exceptions also print to std::cerr - and have a standard 'what()' interface. More information on exceptions can be found in `exception_utils.h`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same of json_ui and xml_ui?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don't think exceptions print directly? If we ever (it would be a bug) let them propagate all the way to the entry point then the OS will do whatever it thinks is right. We actually ought to catch them and put the information (from what()) into a message handler.

Copy link
Contributor Author

@sonodtt sonodtt Nov 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterschrammel
I'll add a few notes about the json and xml output.

To answer the specifics:
In the case of cbmc_parse_optionst (I haven't looked at all the other drivers, I'd hope they all behave in similar fashion - because... well, why wouldn't they)

• uit::PLAIN
then ui_message_handlert::message_handler
is not left as nullptr but is initialised to
message_handler = &*console_message_handler; (with relevant 'flush' type)

void console_message_handlert::print(
...
if(level>=4)
{
std::cout << message << '\n';
}
else
std::cerr << message << '\n';

• for uit:: XML_UI

void ui_message_handlert::xml_ui_msg(
...
xmlt result;
...
out << result;
(where out has been initialised to std::cout)

• for uit:: JSON_UI
json_stream =
std::unique_ptr<json_stream_arrayt>(new json_stream_arrayt(out));
where out has been initialised to std::cout

So I left that part vague...

Copy link
Collaborator

@tautschnig tautschnig Nov 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ Tautschnig

"Hmm, are we trying to document

  1. the interface that the developer should use (don't use cout/cerr),
  2. the implementation behind any of those interfaces (uses cout/cerr), or
  3. the effect (prints something on cout/cerr)?"

I thought that this was a little too essential (and complex) to have no documentation/information of current state - so I wrote a little, not least to get this kind of debate going.
My intention was to overview briefly 'what's there'.
As an aside - I feel the same about the invariant header file - if these macros are to be used often, then surely a few usage examples and better overview of edge cases would be useful. It's quite a hefty file for a new developer - to add a few invariants, they'll have to read it thoroughly. Hmmm, come to think of it - perhaps that's a feature... (?)
But I tend to think of that as a risky assumption.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tautschnig w.r. to exception printing
This is how I unwrap what's happening. Clarified here, because I genuinely would like to be pointed in the right direction if I got it wrong.
There's a fair bit of unravelling before you actually get to the bottom of it.
provisos as above - cbmc_parse_options only considered.

A)
parse_options.cpp

int parse_options_baset::main()

catch(const invalid_command_line_argument_exceptiont &e)
{
std::cerr << e.what() << "\n";
return CPROVER_EXIT_USAGE_ERROR;
}
catch(const cprover_exception_baset &e)
{
std::cerr << e.what() << '\n';
return CPROVER_EXIT_EXCEPTION;
}

B)
cbmc_parse_optionst

int cbmc_parse_optionst::get_goto_program(

catch(incorrect_goto_program_exceptiont &e)
{
log.error() << e.what() << log.eom;
return CPROVER_EXIT_EXCEPTION;
}
catch(const char *e)
{
log.error() << e << log.eom;
return CPROVER_EXIT_EXCEPTION;
}

cbmc_parse_optionst::cbmc_parse_optionst(int argc, const char **argv)
: parse_options_baset(CBMC_OPTIONS, argc, argv),
xml_interfacet(cmdline),
messaget(ui_message_handler),
ui_message_handler(cmdline, std::string("CBMC ") + CBMC_VERSION),

path_strategy_chooser()
{
}

int get_goto_program_ret =
get_goto_program(goto_model, options, cmdline, *this, ui_message_handler);

*this initialises log with cbmc_parse_optionst, which is subclassed from messaget

• The exceptions print to log.error() , i.e. are given a level 1
then if the output is plain ->

void console_message_handlert::print(
...
if(level>=4)
{
std::cout << message << '\n';
}
else
std::cerr << message << '\n';

So in the case of JSON and XML output - the output will be to std::cout, but otherwise, its out to std::cerr

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies that I'll keep belabouring the same point: please decide on the target audience first. I believe we've even got open issues about the mess that output is at the moment. Front-ends (aka driver programs), such as "cbmc", should provide documentation on what the user can expect (i.e., exceptions and errors will be shown on stderr, etc.). Documentation aimed at developers should provide guidance on how to do it right. To them, it shouldn't really matter where or how it ends up printed, because they should reasonably be able to assume that the right thing will happen if they follow the guidelines spelled out in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tautschnig
Belabour away if you think it'll improve things. We have a common objective :)
I pulled Chris over for a quick review - and that clarified things a little.

I've rewritten the section to put forward 'what people really should be doing', i.e. using the messaging interface - with a little bit of an introduction to its objectives.

I've kept a subsection for 'how some things are at the moment, but this is not how we should do them going forward'.

@@ -329,3 +329,18 @@ serialisation queries save only that integer hash code of the string.

\subsubsection irep-serialization-ireps Serialization of `irept` Instances


\subsection CProver-output CProver output - printing
Cprover has 3 principal types of output:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there consistency in how "cprover"/"Cprover"/"CProver"/"CPROVER" is being written across the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.... excellent point. I've now posted on internal slack to raise that issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with CProver. That's most readable IMO.

\subsection CProver-output CProver output - printing
Cprover has 3 principal types of output:

* direct output via std::cout & std::cerr (these are in the process of being removed).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this last, it's how it should not be done.

* output from invariants / exceptions
Invariants output to std::cerr - and provide a backtrace and optionally some diagnostic information.
For more information on invariants, see `invariant.h`
Exceptions also print to std::cerr - and have a standard 'what()' interface. More information on exceptions can be found in `exception_utils.h`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don't think exceptions print directly? If we ever (it would be a bug) let them propagate all the way to the entry point then the OS will do whatever it thinks is right. We actually ought to catch them and put the information (from what()) into a message handler.

For more information on invariants, see `invariant.h`
Exceptions also print to std::cerr - and have a standard 'what()' interface. More information on exceptions can be found in `exception_utils.h`.

* messages - filtered by a 'verbosity' level.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really, this is the only acceptable form of generating output (other than writing information to a file).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tautschnig

int parse_options_baset::main()
catch(const invalid_command_line_argument_exceptiont &e)
{
std::cerr << e.what() << "\n";
return CPROVER_EXIT_USAGE_ERROR;
}
catch(const cprover_exception_baset &e)
{
std::cerr << e.what() << '\n';
return CPROVER_EXIT_EXCEPTION;
}

Otherwise it seems that we are going through a message handler (verified via a quick search - not foolproof 'std::cerr ?<<.+what' ).


* messages - filtered by a 'verbosity' level.
\ref messaget provides messages with a built-in verbosity 'level'.
These are then processed by a subclass of \ref message_handlert - which filters out all messages above a set verbosity level. An example of this is \ref stream_message_handlert and its subtypes, which directs messages to an output stream (std::cout & std::cerr - std::log is not used).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is std::log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The natural (base e) logarithm. But that doesn't help us a great deal here.
std::clog.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 270222b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/91529880

@sonodtt sonodtt force-pushed the doc-day-cprover-printing-overview branch from 270222b to f5bd587 Compare November 15, 2018 16:03
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: f5bd587).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/91548851

@tautschnig tautschnig merged commit 23932b8 into diffblue:develop Nov 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants