Skip to content

Commit 1b58ff9

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#991 from karkhaz/pretty-print
Add --print-internal-representation to goto-instrument
2 parents 17e5963 + 6822afa commit 1b58ff9

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
char stage2_start[100];
2+
3+
int main(){
4+
int x = 3;
5+
unsigned y = 4;
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
main.c
3+
--print-internal-representation
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^ \* identifier: __CPROVER_initialize$
7+
^ \* identifier: main::1::x$
8+
^ \* identifier: main::1::y$
9+
--
10+
--
11+
Ensures that the output from pretty() is printed when
12+
--print-internal-representation is passed to goto-instrument.

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,19 @@ int goto_instrument_parse_optionst::doit()
578578
return 0;
579579
}
580580

581+
if(cmdline.isset("print-internal-representation"))
582+
{
583+
for(auto const &pair : goto_functions.function_map)
584+
for(auto const &ins : pair.second.body.instructions)
585+
{
586+
if(ins.code.is_not_nil())
587+
status() << ins.code.pretty() << eom;
588+
if(ins.guard.is_not_nil())
589+
status() << "[guard] " << ins.guard.pretty() << eom;
590+
}
591+
return 0;
592+
}
593+
581594
if(cmdline.isset("show-goto-functions"))
582595
{
583596
namespacet ns(symbol_table);
@@ -770,6 +783,7 @@ int goto_instrument_parse_optionst::doit()
770783
error() << "Out of memory" << eom;
771784
return 11;
772785
}
786+
// NOLINTNEXTLINE(readability/fn_size)
773787
}
774788

775789
void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal(
@@ -1451,6 +1465,8 @@ void goto_instrument_parse_optionst::help()
14511465
" --show-symbol-table show symbol table\n"
14521466
" --list-symbols list symbols with type information\n"
14531467
HELP_SHOW_GOTO_FUNCTIONS
1468+
" --print-internal-representation\n" // NOLINTNEXTLINE(*)
1469+
" show verbose internal representation of the program\n"
14541470
" --list-undefined-functions list functions without body\n"
14551471
" --show-struct-alignment show struct members that might be concurrently accessed\n" // NOLINT(*)
14561472
" --show-natural-loops show natural loop heads\n"
@@ -1478,7 +1494,8 @@ void goto_instrument_parse_optionst::help()
14781494
" --nondet-static add nondeterministic initialization of variables with static lifetime\n" // NOLINT(*)
14791495
" --check-invariant function instruments invariant checking function\n"
14801496
" --remove-pointers converts pointer arithmetic to base+offset expressions\n" // NOLINT(*)
1481-
" --undefined-function-is-assume-false\n"
1497+
// NOLINTNEXTLINE(whitespace/line_length)
1498+
" --undefined-function-is-assume-false\n" // NOLINTNEXTLINE(whitespace/line_length)
14821499
" convert each call to an undefined function to assume(false)\n"
14831500
"\n"
14841501
"Loop transformations:\n"

src/goto-instrument/goto_instrument_parse_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Author: Daniel Kroening, [email protected]
6060
"(full-slice)(reachability-slice)(slice-global-inits)" \
6161
"(inline)(partial-inline)(function-inline):(log):(no-caching)" \
6262
OPT_REMOVE_CONST_FUNCTION_POINTERS \
63+
"(print-internal-representation)" \
6364
"(remove-function-pointers)" \
6465
"(show-claims)(show-properties)(property):" \
6566
"(show-symbol-table)(show-points-to)(show-rw-set)" \

0 commit comments

Comments
 (0)