Skip to content

Add --print-internal-representation to goto-instrument #991

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
merged 1 commit into from
Jun 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
char stage2_start[100];

int main(){
int x = 3;
unsigned y = 4;
}
12 changes: 12 additions & 0 deletions regression/goto-instrument/print-internal-representation/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
main.c
--print-internal-representation
^EXIT=0$
^SIGNAL=0$
^ \* identifier: __CPROVER_initialize$
^ \* identifier: main::1::x$
^ \* identifier: main::1::y$
--
--
Ensures that the output from pretty() is printed when
--print-internal-representation is passed to goto-instrument.
19 changes: 18 additions & 1 deletion src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,19 @@ int goto_instrument_parse_optionst::doit()
return 0;
}

if(cmdline.isset("print-internal-representation"))
{
for(auto const &pair : goto_functions.function_map)
for(auto const &ins : pair.second.body.instructions)
{
if(ins.code.is_not_nil())
status() << ins.code.pretty() << eom;
if(ins.guard.is_not_nil())
status() << "[guard] " << ins.guard.pretty() << eom;
}
return 0;
}

if(cmdline.isset("show-goto-functions"))
{
namespacet ns(symbol_table);
Expand Down Expand Up @@ -770,6 +783,7 @@ int goto_instrument_parse_optionst::doit()
error() << "Out of memory" << eom;
return 11;
}
// NOLINTNEXTLINE(readability/fn_size)
}

void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal(
Expand Down Expand Up @@ -1454,6 +1468,8 @@ void goto_instrument_parse_optionst::help()
" --show-symbol-table show symbol table\n"
" --list-symbols list symbols with type information\n"
HELP_SHOW_GOTO_FUNCTIONS
" --print-internal-representation\n" // NOLINTNEXTLINE(*)
" show verbose internal representation of the program\n"
" --list-undefined-functions list functions without body\n"
" --show-struct-alignment show struct members that might be concurrently accessed\n" // NOLINT(*)
" --show-natural-loops show natural loop heads\n"
Expand Down Expand Up @@ -1481,7 +1497,8 @@ void goto_instrument_parse_optionst::help()
" --nondet-static add nondeterministic initialization of variables with static lifetime\n" // NOLINT(*)
" --check-invariant function instruments invariant checking function\n"
" --remove-pointers converts pointer arithmetic to base+offset expressions\n" // NOLINT(*)
" --undefined-function-is-assume-false\n"
// NOLINTNEXTLINE(whitespace/line_length)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please could you remove the line break introduced here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks Martin. Not sure what you mean, I didn't introduce a line break, but just added two linter directives since the linter was complaining...

" --undefined-function-is-assume-false\n" // NOLINTNEXTLINE(whitespace/line_length)
" convert each call to an undefined function to assume(false)\n"
"\n"
"Loop transformations:\n"
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 @@ -60,6 +60,7 @@ Author: Daniel Kroening, [email protected]
"(full-slice)(reachability-slice)(slice-global-inits)" \
"(inline)(partial-inline)(function-inline):(log):(no-caching)" \
OPT_REMOVE_CONST_FUNCTION_POINTERS \
"(print-internal-representation)" \
"(remove-function-pointers)" \
"(show-claims)(show-properties)(property):" \
"(show-symbol-table)(show-points-to)(show-rw-set)" \
Expand Down