Skip to content

Commit

Permalink
Merge pull request diffblue#1712 from karkhaz/kk-flush-all
Browse files Browse the repository at this point in the history
Add --flush option to flush all output
  • Loading branch information
tautschnig authored May 2, 2018
2 parents e0bc5fd + 1ef0f41 commit 4948b70
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@ void cbmc_parse_optionst::help()
" --xml-interface bi-directional XML interface\n"
" --json-ui use JSON-formatted output\n"
HELP_GOTO_TRACE
HELP_FLUSH
" --verbosity # verbosity level\n"
HELP_TIMESTAMP
"\n";
Expand Down
1 change: 1 addition & 0 deletions src/cbmc/cbmc_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class optionst;
"(arrays-uf-always)(arrays-uf-never)" \
"(string-abstraction)(no-arch)(arch):" \
"(round-to-nearest)(round-to-plus-inf)(round-to-minus-inf)(round-to-zero)" \
OPT_FLUSH \
"(localize-faults)(localize-faults-method):" \
OPT_GOTO_TRACE \
"(claim):(show-claims)(fixedbv)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length)
Expand Down
1 change: 1 addition & 0 deletions src/goto-analyzer/goto_analyzer_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ void goto_analyzer_parse_optionst::help()
"\n"
"Other options:\n"
" --version show version and exit\n"
HELP_FLUSH
HELP_TIMESTAMP
"\n";
// clang-format on
Expand Down
1 change: 1 addition & 0 deletions src/goto-analyzer/goto_analyzer_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class optionst;
"(show-local-may-alias)" \
"(json):(xml):" \
"(text):(dot):" \
OPT_FLUSH \
OPT_TIMESTAMP \
"(unreachable-instructions)(unreachable-functions)" \
"(reachable-functions)" \
Expand Down
1 change: 1 addition & 0 deletions src/goto-diff/goto_diff_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ void goto_diff_parse_optionst::help()
"Other options:\n"
" --version show version and exit\n"
" --json-ui use JSON-formatted output\n"
HELP_FLUSH
HELP_TIMESTAMP
"\n";
// clang-format on
Expand Down
1 change: 1 addition & 0 deletions src/goto-diff/goto_diff_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class optionst;
OPT_GOTO_CHECK \
"(cover):" \
"(verbosity):(version)" \
OPT_FLUSH \
OPT_TIMESTAMP \
"u(unified)(change-impact)(forward-impact)(backward-impact)" \
"(compact-output)"
Expand Down
1 change: 1 addition & 0 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,7 @@ void goto_instrument_parse_optionst::help()
" --use-all-headers with --dump-c/--dump-cpp: generate C source with all includes\n" // NOLINT(*)
" --harness with --dump-c/--dump-cpp: include input generator in output\n" // NOLINT(*)
" --version show version and exit\n"
HELP_FLUSH
" --xml-ui use XML-formatted output\n"
" --json-ui use JSON-formatted output\n"
HELP_TIMESTAMP
Expand Down
1 change: 1 addition & 0 deletions src/goto-instrument/goto_instrument_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Author: Daniel Kroening, [email protected]
"(show-threaded)(list-calls-args)(print-path-lengths)" \
"(undefined-function-is-assume-false)" \
"(remove-function-body):"\
OPT_FLUSH \
"(splice-call):" \
OPT_REMOVE_CALLS_NO_BODY \
OPT_REPLACE_FUNCTION_BODY
Expand Down
1 change: 1 addition & 0 deletions src/jbmc/jbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,7 @@ void jbmc_parse_optionst::help()
" --xml-ui use XML-formatted output\n"
" --json-ui use JSON-formatted output\n"
HELP_GOTO_TRACE
HELP_FLUSH
" --verbosity # verbosity level\n"
HELP_TIMESTAMP
"\n";
Expand Down
1 change: 1 addition & 0 deletions src/jbmc/jbmc_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class optionst;
"(ppc-macos)" \
"(arrays-uf-always)(arrays-uf-never)" \
"(no-arch)(arch):" \
OPT_FLUSH \
JAVA_BYTECODE_LANGUAGE_OPTIONS \
"(java-unwind-enum-static)" \
"(localize-faults)(localize-faults-method):" \
Expand Down
2 changes: 1 addition & 1 deletion src/util/cout_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void console_message_handlert::flush(unsigned level)
// in particular when writing to NFS.
if(level>=4)
{
if(level<=6)
if(level <= 6 || always_flush)
std::cout << std::flush;
}
else
Expand Down
12 changes: 12 additions & 0 deletions src/util/cout_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ class console_message_handlert:public ui_message_handlert
const std::string &message) override;

virtual void flush(unsigned level) override;

console_message_handlert() : always_flush(false)
{
}

explicit console_message_handlert(bool always_flush)
: always_flush(always_flush)
{
}

protected:
const bool always_flush;
};

class gcc_message_handlert:public ui_message_handlert
Expand Down
12 changes: 10 additions & 2 deletions src/util/ui_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Author: Daniel Kroening, [email protected]

ui_message_handlert::ui_message_handlert()
: _ui(uit::PLAIN),
always_flush(false),
time(timestampert::make(timestampert::clockt::NONE)),
out(std::cout),
json_stream(nullptr)
Expand All @@ -30,8 +31,10 @@ ui_message_handlert::ui_message_handlert()
ui_message_handlert::ui_message_handlert(
uit __ui,
const std::string &program,
bool always_flush,
timestampert::clockt clock_type)
: _ui(__ui),
always_flush(always_flush),
time(timestampert::make(clock_type)),
out(std::cout),
json_stream(nullptr)
Expand Down Expand Up @@ -79,6 +82,7 @@ ui_message_handlert::ui_message_handlert(
? uit::JSON_UI
: uit::PLAIN,
program,
cmdline.isset("flush"),
cmdline.isset("timestamp")
? cmdline.get_value("timestamp") == "monotonic"
? timestampert::clockt::MONOTONIC
Expand Down Expand Up @@ -130,11 +134,13 @@ void ui_message_handlert::print(
{
case uit::PLAIN:
{
console_message_handlert console_message_handler;
console_message_handlert console_message_handler(always_flush);
std::stringstream ss;
const std::string timestamp = time->stamp();
ss << timestamp << (timestamp.empty() ? "" : " ") << message;
console_message_handler.print(level, ss.str());
if(always_flush)
console_message_handler.flush(level);
}
break;

Expand All @@ -144,6 +150,8 @@ void ui_message_handlert::print(
source_locationt location;
location.make_nil();
print(level, message, -1, location);
if(always_flush)
flush(level);
}
break;
}
Expand Down Expand Up @@ -302,7 +310,7 @@ void ui_message_handlert::flush(unsigned level)
{
case uit::PLAIN:
{
console_message_handlert console_message_handler;
console_message_handlert console_message_handler(always_flush);
console_message_handler.flush(level);
}
break;
Expand Down
6 changes: 6 additions & 0 deletions src/util/ui_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ui_message_handlert : public message_handlert
ui_message_handlert(
uit,
const std::string &program,
const bool always_flush,
timestampert::clockt clock_type);

ui_message_handlert(const class cmdlinet &, const std::string &program);
Expand Down Expand Up @@ -58,6 +59,7 @@ class ui_message_handlert : public message_handlert

protected:
uit _ui;
const bool always_flush;
std::unique_ptr<const timestampert> time;
std::ostream &out;
std::unique_ptr<json_stream_arrayt> json_stream;
Expand Down Expand Up @@ -101,4 +103,8 @@ class ui_message_handlert : public message_handlert
const char *level_string(unsigned level);
};

#define OPT_FLUSH "(flush)"

#define HELP_FLUSH " --flush flush every line of output\n"

#endif // CPROVER_UTIL_UI_MESSAGE_H

0 comments on commit 4948b70

Please sign in to comment.