-
Notifications
You must be signed in to change notification settings - Fork 286
Symex resource monitoring: per-function step counts, memory, callgrind output, and live progress display #8903
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
base: develop
Are you sure you want to change the base?
Changes from all commits
87069b0
4d7b5d9
2515923
7bc26ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| CORE | ||
| main.c | ||
| --unwind 7 --symex-callgrind ../callgrind_test.out | ||
| ^Symex callgrind data written to | ||
| ^EXIT=0$ | ||
| ^SIGNAL=0$ | ||
| -- | ||
| ^warning: ignoring | ||
| -- | ||
| Tests that --symex-callgrind produces a callgrind-format output file | ||
| that can be visualized with KCachegrind/QCachegrind. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| int factorial(int n) | ||
| { | ||
| if(n <= 1) | ||
| return 1; | ||
| return n * factorial(n - 1); | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| int x; | ||
| __CPROVER_assume(x >= 1 && x <= 5); | ||
| int result = factorial(x); | ||
| __CPROVER_assert(result >= 1, "positive"); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| CORE | ||
| main.c | ||
| --unwind 7 --show-symex-progress --verbosity 9 | ||
| ^Max call depth: [1-9]\d*, max active loops: \d+$ | ||
| ^EXIT=0$ | ||
| ^SIGNAL=0$ | ||
| -- | ||
| ^warning: ignoring | ||
| -- | ||
| Tests that --show-symex-progress reports max call depth and loop nesting. | ||
| The interactive terminal display is not tested here (requires a real | ||
| terminal), but the summary statistics are always emitted. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| CORE | ||
| main.c | ||
| --unwind 7 --verbosity 9 | ||
| ^Symex steps: \d+ total$ | ||
| ^ factorial: \d+ steps \(\d+%\)$ | ||
| ^Peak memory: \d+ MB$ | ||
| ^EXIT=0$ | ||
| ^SIGNAL=0$ | ||
| -- | ||
| ^warning: ignoring | ||
| -- | ||
| Tests that per-function symex step counts and peak memory are reported | ||
| at statistics verbosity level. | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,8 @@ Author: Daniel Kroening, Peter Schrammel | |||||||||||||||
| #include "counterexample_beautification.h" | ||||||||||||||||
| #include "goto_symex_fault_localizer.h" | ||||||||||||||||
|
|
||||||||||||||||
| #include <fstream> | ||||||||||||||||
|
|
||||||||||||||||
| multi_path_symex_checkert::multi_path_symex_checkert( | ||||||||||||||||
| const optionst &options, | ||||||||||||||||
| ui_message_handlert &ui_message_handler, | ||||||||||||||||
|
|
@@ -37,8 +39,8 @@ multi_path_symex_checkert::multi_path_symex_checkert( | |||||||||||||||
| PRECONDITION(!has_vector(goto_model.get_goto_functions())); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| incremental_goto_checkert::resultt multi_path_symex_checkert:: | ||||||||||||||||
| operator()(propertiest &properties) | ||||||||||||||||
| incremental_goto_checkert::resultt | ||||||||||||||||
| multi_path_symex_checkert::operator()(propertiest &properties) | ||||||||||||||||
| { | ||||||||||||||||
| resultt result(resultt::progresst::DONE); | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -60,6 +62,21 @@ operator()(propertiest &properties) | |||||||||||||||
| symex, | ||||||||||||||||
| ui_message_handler); | ||||||||||||||||
|
|
||||||||||||||||
| // Write callgrind-format symex profile if requested | ||||||||||||||||
| { | ||||||||||||||||
| const std::string callgrind_file = options.get_option("symex-callgrind"); | ||||||||||||||||
| if(!callgrind_file.empty()) | ||||||||||||||||
| { | ||||||||||||||||
| std::ofstream out(callgrind_file); | ||||||||||||||||
| if(out) | ||||||||||||||||
| { | ||||||||||||||||
| symex.write_callgrind(out); | ||||||||||||||||
| log.status() << "Symex callgrind data written to " << callgrind_file | ||||||||||||||||
| << messaget::eom; | ||||||||||||||||
| } | ||||||||||||||||
|
||||||||||||||||
| } | |
| } | |
| else | |
| { | |
| log.error() << "Failed to open symex callgrind output file '" | |
| << callgrind_file << "'" << messaget::eom; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,8 @@ Author: Daniel Kroening, Peter Schrammel | |||||||||||||||
|
|
||||||||||||||||
| #include "multi_path_symex_only_checker.h" | ||||||||||||||||
|
|
||||||||||||||||
| #include <util/console.h> | ||||||||||||||||
| #include <util/memory_info.h> | ||||||||||||||||
| #include <util/ui_message.h> | ||||||||||||||||
|
|
||||||||||||||||
| #include <goto-symex/shadow_memory.h> | ||||||||||||||||
|
|
@@ -19,6 +21,9 @@ Author: Daniel Kroening, Peter Schrammel | |||||||||||||||
|
|
||||||||||||||||
| #include "bmc_util.h" | ||||||||||||||||
|
|
||||||||||||||||
| #include <algorithm> | ||||||||||||||||
| #include <fstream> | ||||||||||||||||
|
|
||||||||||||||||
| multi_path_symex_only_checkert::multi_path_symex_only_checkert( | ||||||||||||||||
| const optionst &options, | ||||||||||||||||
| ui_message_handlert &ui_message_handler, | ||||||||||||||||
|
|
@@ -41,8 +46,8 @@ multi_path_symex_only_checkert::multi_path_symex_only_checkert( | |||||||||||||||
| options.get_list_option("unwindset"), goto_model, ui_message_handler); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| incremental_goto_checkert::resultt multi_path_symex_only_checkert:: | ||||||||||||||||
| operator()(propertiest &properties) | ||||||||||||||||
| incremental_goto_checkert::resultt | ||||||||||||||||
| multi_path_symex_only_checkert::operator()(propertiest &properties) | ||||||||||||||||
| { | ||||||||||||||||
| generate_equation(); | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -52,6 +57,21 @@ operator()(propertiest &properties) | |||||||||||||||
| symex, | ||||||||||||||||
| ui_message_handler); | ||||||||||||||||
|
|
||||||||||||||||
| // Write callgrind-format symex profile if requested | ||||||||||||||||
| { | ||||||||||||||||
| const std::string callgrind_file = options.get_option("symex-callgrind"); | ||||||||||||||||
| if(!callgrind_file.empty()) | ||||||||||||||||
| { | ||||||||||||||||
| std::ofstream out(callgrind_file); | ||||||||||||||||
| if(out) | ||||||||||||||||
| { | ||||||||||||||||
| symex.write_callgrind(out); | ||||||||||||||||
| log.status() << "Symex callgrind data written to " << callgrind_file | ||||||||||||||||
| << messaget::eom; | ||||||||||||||||
| } | ||||||||||||||||
|
||||||||||||||||
| } | |
| } | |
| else | |
| { | |
| log.warning() << "Failed to open symex callgrind output file '" | |
| << callgrind_file << "'" << messaget::eom; | |
| } |
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.
The expected per-function line assumes the function identifier prints as
factorial, but CBMC function identifiers are typically qualified (e.g.c::factorial). This regex is likely too strict and may make the test fail; consider loosening it to accept the qualified identifier.