Skip to content

Commit

Permalink
goto-analyzer: --show-local-bitvector
Browse files Browse the repository at this point in the history
This adds --show-local-bitvector as a task to goto-analyzer.
  • Loading branch information
kroening committed Dec 27, 2024
1 parent f9a7807 commit 1e50663
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/man/goto-analyzer.1
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ perform taint analysis using rules in given file
\fB\-\-show\-taint\fR
print taint analysis results on stdout
.TP
\fB\-\-show\-local\-bitvector\fR
perform procedure\-local bitvector analysis
.TP
\fB\-\-show\-local\-may\-alias\fR
perform procedure\-local may alias analysis
.SS "C/C++ frontend options:"
Expand Down
8 changes: 8 additions & 0 deletions regression/goto-analyzer/bitvector-analysis/basic1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
int some_int;
int *pointer_global;

void foobar(int *pointer_parameter)
{
int *pointer_local;
pointer_local = &some_int;
}
8 changes: 8 additions & 0 deletions regression/goto-analyzer/bitvector-analysis/basic1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
basic1.c
--show-local-bitvector
^ foobar::pointer_parameter: \+unknown$
^ foobar::1::pointer_local: \+static_lifetime$
^EXIT=0$
^SIGNAL=0$
--
24 changes: 24 additions & 0 deletions src/goto-analyzer/goto_analyzer_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Author: Daniel Kroening, [email protected]
#include <goto-programs/show_symbol_table.h>

#include <analyses/ai.h>
#include <analyses/local_bitvector_analysis.h>
#include <analyses/local_may_alias.h>
#include <ansi-c/cprover_library.h>
#include <ansi-c/gcc_version.h>
Expand Down Expand Up @@ -139,6 +140,11 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
options.set_option("show-local-may-alias", true);
options.set_option("specific-analysis", true);
}
if(cmdline.isset("show-local-bitvector"))
{

Check warning on line 144 in src/goto-analyzer/goto_analyzer_parse_options.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-analyzer/goto_analyzer_parse_options.cpp#L144

Added line #L144 was not covered by tests
options.set_option("show-local-bitvector", true);
options.set_option("specific-analysis", true);
}

// Output format choice
if(cmdline.isset("text"))
Expand Down Expand Up @@ -572,6 +578,23 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
return CPROVER_EXIT_SUCCESS;
}

if(options.get_bool_option("show-local-bitvector"))
{
namespacet ns(goto_model.symbol_table);

Check warning on line 584 in src/goto-analyzer/goto_analyzer_parse_options.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-analyzer/goto_analyzer_parse_options.cpp#L584

Added line #L584 was not covered by tests
for(const auto &gf_entry : goto_model.goto_functions.function_map)
{

Check warning on line 586 in src/goto-analyzer/goto_analyzer_parse_options.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-analyzer/goto_analyzer_parse_options.cpp#L586

Added line #L586 was not covered by tests
std::cout << ">>>>\n";
std::cout << ">>>> " << gf_entry.first << '\n';
std::cout << ">>>>\n";
local_bitvector_analysist local_bitvector_analysis(gf_entry.second, ns);
local_bitvector_analysis.output(std::cout, gf_entry.second, ns);
std::cout << '\n';
}

return CPROVER_EXIT_SUCCESS;
}

label_properties(goto_model);

if(cmdline.isset("show-properties"))
Expand Down Expand Up @@ -802,6 +825,7 @@ void goto_analyzer_parse_optionst::help()
" {y--taint} {ufile_name} \t perform taint analysis using rules in given"
" file\n"
" {y--show-taint} \t print taint analysis results on stdout\n"
" {y--show-local-bitvector} \t perform procedure-local bitvector analysis\n"
" {y--show-local-may-alias} \t perform procedure-local may alias analysis\n"
"\n"
"C/C++ frontend options:\n"
Expand Down
3 changes: 2 additions & 1 deletion src/goto-analyzer/goto_analyzer_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class optionst;

#define GOTO_ANALYSER_OPTIONS_SPECIFIC_ANALYSES \
"(taint):(show-taint)" \
"(show-local-may-alias)"
"(show-local-may-alias)" \
"(show-local-bitvector)"

#define GOTO_ANALYSER_OPTIONS \
OPT_FUNCTIONS \
Expand Down

0 comments on commit 1e50663

Please sign in to comment.