Skip to content

Commit d44063a

Browse files
author
martin
committed
Add support for generating the dependency graph to goto-analyze, including dot format.
1 parent 8cddfbb commit d44063a

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
227227
options.set_option("text", false);
228228
options.set_option("json", false);
229229
options.set_option("xml", false);
230+
options.set_option("dot", false);
230231
options.set_option("outfile", "-");
231232

232233
if (cmdline.isset("text"))
@@ -244,6 +245,11 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
244245
options.set_option("xml", true);
245246
options.set_option("outfile", cmdline.get_value("xml"));
246247
}
248+
else if (cmdline.isset("dot"))
249+
{
250+
options.set_option("dot", true);
251+
options.set_option("outfile", cmdline.get_value("dot"));
252+
}
247253
else
248254
{
249255
options.set_option("text", true);
@@ -298,6 +304,7 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
298304
options.set_option("constants", false);
299305
options.set_option("intervals", false);
300306
options.set_option("non-null", false);
307+
options.set_option("dependence-graph", false);
301308

302309
if (cmdline.isset("intervals") ||
303310
cmdline.isset("show-intervals"))
@@ -307,10 +314,13 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
307314
options.set_option("non-null", true);
308315
else if (cmdline.isset("constants"))
309316
options.set_option("constants", true);
317+
else if (cmdline.isset("dependence-graph"))
318+
options.set_option("dependence-graph", true);
310319

311320
if (!(options.get_bool_option("constants") ||
312321
options.get_bool_option("intervals") ||
313-
options.get_bool_option("non-null")))
322+
options.get_bool_option("non-null") ||
323+
options.get_bool_option("dependence-graph")))
314324
{
315325
status() << "Domain defaults to --constants" << eom;
316326
options.set_option("constants", true);
@@ -661,11 +671,13 @@ void goto_analyzer_parse_optionst::help()
661671
" --constants constant abstraction\n"
662672
" --intervals interval abstraction\n"
663673
" --non-null non-null abstraction\n"
674+
" --dependence-graph dependency relation between instructions\n"
664675
"\n"
665676
"Output options:\n"
666677
" --text file_name output results in plain text to given file\n"
667678
" --json file_name output results in JSON format to given file\n"
668679
" --xml file_name output results in XML format to given file\n"
680+
" --dot file_name output results in DOT format to given file\n"
669681
"\n"
670682
"Other analyses:\n"
671683
" --taint file_name perform taint analysis using rules in given file\n"

src/goto-analyzer/goto_analyzer_parse_options.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ class optionst;
3333
"(gcc)(arch):" \
3434
"(taint):(show-taint)" \
3535
"(show-local-may-alias)" \
36-
"(json):(xml):(text):" \
36+
"(json):(xml):(text):(dot):" \
3737
"(unreachable-instructions)" \
3838
"(intervals)(show-intervals)" \
3939
"(non-null)(show-non-null)" \
4040
"(constants)" \
41-
"(show)(verify)(simplify):" \
41+
"(dependence-graph)" \
42+
"(show)(verify)(simplify):" \
4243
"(flow-sensitive)(concurrent)"
4344

4445
class goto_analyzer_parse_optionst:

src/goto-analyzer/static_show_domain.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Martin Brain, [email protected]
1414

1515
#include <analyses/interval_domain.h>
1616
#include <analyses/constant_propagator.h>
17+
#include <analyses/dependence_graph.h>
1718

1819
#include "static_show_domain.h"
1920

@@ -37,6 +38,7 @@ bool static_show_domain(
3738
std::ostream &out)
3839
{
3940
ai_baset *domain = NULL;
41+
namespacet ns(goto_model.symbol_table);
4042

4143
if (options.get_bool_option("flow-sensitive"))
4244
{
@@ -48,7 +50,10 @@ bool static_show_domain(
4850

4951
//else if (options.get_bool_option("non-null"))
5052
// domain = new ait<non_null_domaint>();
51-
53+
54+
else if (options.get_bool_option("dependence-graph"))
55+
domain = new dependence_grapht(ns);
56+
5257
}
5358
else if (options.get_bool_option("concurrent"))
5459
{
@@ -75,10 +80,18 @@ bool static_show_domain(
7580
//status() << "performing analysis" << eom;
7681
(*domain)(goto_model);
7782

83+
7884
if(options.get_bool_option("json"))
7985
out << domain->output_json(goto_model);
8086
else if(options.get_bool_option("xml"))
8187
out << domain->output_xml(goto_model);
88+
else if(options.get_bool_option("dot") && options.get_bool_option("dependence-graph"))
89+
{
90+
dependence_grapht *d = dynamic_cast<dependence_grapht*>(domain);
91+
assert(d != NULL);
92+
93+
d->output_dot(out);
94+
}
8295
else
8396
domain->output(goto_model, out);
8497

0 commit comments

Comments
 (0)