-
Notifications
You must be signed in to change notification settings - Fork 277
New goto-instrument option: --print-global-state-size #2190
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
Changes from all commits
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,9 @@ | ||
#include <stdint.h> | ||
|
||
uint32_t some_global_var; | ||
int8_t other_global_var; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--print-global-state-size | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^Total size of global objects: 40 bits$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,6 @@ Author: Daniel Kroening, [email protected] | |
#include "wmm/weak_memory.h" | ||
#include "call_sequences.h" | ||
#include "accelerate/accelerate.h" | ||
#include "count_eloc.h" | ||
#include "horn_encoding.h" | ||
#include "thread_instrumentation.h" | ||
#include "skip_loops.h" | ||
|
@@ -484,6 +483,12 @@ int goto_instrument_parse_optionst::doit() | |
return CPROVER_EXIT_SUCCESS; | ||
} | ||
|
||
if(cmdline.isset("print-global-state-size")) | ||
{ | ||
print_global_state_size(goto_model); | ||
return CPROVER_EXIT_SUCCESS; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a stupid question but what is the use-case for this? Is bits necessarily the most useful piece of information? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A question that has come up is "what is the size of the state space?" (let's not discuss whether that is even a meaningful question). The output here does provide guidance: if the non-constant part of global variables is in the order of millions of bits you'll likely run into trouble (even when just a few instructions are to be executed). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... this is true ... I wonder if we could give any more meaningful stats for the same effort / with the same code. |
||
} | ||
|
||
if(cmdline.isset("list-symbols")) | ||
{ | ||
show_symbol_table_brief(goto_model, get_ui()); | ||
|
@@ -1454,15 +1459,14 @@ void goto_instrument_parse_optionst::help() | |
" --dump-cpp generate C++ source\n" | ||
" --dot generate CFG graph in DOT format\n" | ||
" --interpreter do concrete execution\n" | ||
" --count-eloc count effective lines of code\n" | ||
" --list-eloc list full path names of lines containing code\n" // NOLINT(*) | ||
"\n" | ||
"Diagnosis:\n" | ||
" --show-loops show the loops in the program\n" | ||
HELP_SHOW_PROPERTIES | ||
" --show-symbol-table show loaded symbol table\n" | ||
" --list-symbols list symbols with type information\n" | ||
HELP_SHOW_GOTO_FUNCTIONS | ||
HELP_GOTO_PROGRAM_STATS | ||
" --drop-unused-functions drop functions trivially unreachable from main function\n" // NOLINT(*) | ||
" --print-internal-representation\n" // NOLINTNEXTLINE(*) | ||
" show verbose internal representation of the program\n" | ||
|
@@ -1471,8 +1475,6 @@ void goto_instrument_parse_optionst::help() | |
" --show-natural-loops show natural loop heads\n" | ||
// NOLINTNEXTLINE(whitespace/line_length) | ||
" --list-calls-args list all function calls with their arguments\n" | ||
// NOLINTNEXTLINE(whitespace/line_length) | ||
" --print-path-lengths print statistics about control-flow graph paths\n" | ||
" --call-graph show graph of function calls\n" | ||
// NOLINTNEXTLINE(whitespace/line_length) | ||
" --reachable-call-graph show graph of function calls potentially reachable from main function\n" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <goto-programs/generate_function_bodies.h> | ||
|
||
#include "count_eloc.h" | ||
|
||
// clang-format off | ||
#define GOTO_INSTRUMENT_OPTIONS \ | ||
"(all)" \ | ||
|
@@ -81,17 +83,18 @@ Author: Daniel Kroening, [email protected] | |
"(accelerate)(constant-propagator)" \ | ||
"(k-induction):(step-case)(base-case)" \ | ||
"(show-call-sequences)(check-call-sequence)" \ | ||
"(interpreter)(show-reaching-definitions)(count-eloc)(list-eloc)" \ | ||
"(interpreter)(show-reaching-definitions)" \ | ||
"(list-symbols)(list-undefined-functions)" \ | ||
"(z3)(add-library)(show-dependence-graph)" \ | ||
"(horn)(skip-loops):(apply-code-contracts)(model-argc-argv):" \ | ||
"(show-threaded)(list-calls-args)(print-path-lengths)" \ | ||
"(show-threaded)(list-calls-args)" \ | ||
"(undefined-function-is-assume-false)" \ | ||
"(remove-function-body):"\ | ||
OPT_FLUSH \ | ||
"(splice-call):" \ | ||
OPT_REMOVE_CALLS_NO_BODY \ | ||
OPT_REPLACE_FUNCTION_BODY | ||
OPT_REPLACE_FUNCTION_BODY \ | ||
OPT_GOTO_PROGRAM_STATS | ||
|
||
// clang-format on | ||
|
||
|
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.
It seems to me that if the total is too large, the next thing someone will ask is "what's taking up all of the space", so could we have, possibly at verbose or debug, something that prints out the size and the name?
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.
I did consider doing so, but now that's done in #2184 during symbolic execution.
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.
OK.