Skip to content

Commit 61c718b

Browse files
authored
Merge pull request diffblue#232 from diffblue/feature/option_dump-html-program
SEC-41 : Introducing the option --dump-html-program to security-analyser.
2 parents 2afb1a4 + 1650b2c commit 61c718b

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/driver/sec_driver_parse_options.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <goto-programs/link_to_library.h>
3232
#include <goto-programs/class_hierarchy.h>
3333
#include <goto-programs/remove_exceptions.h>
34+
#include <analyses/call_graph.h>
3435

3536
#include <analyses/goto_check.h>
3637
#include <analyses/local_may_alias.h>
@@ -253,6 +254,45 @@ int sec_driver_parse_optionst::doit()
253254
return 0;
254255
}
255256

257+
if(cmdline.isset("dump-html-program"))
258+
{
259+
status()
260+
<< "Dumping GOTO program in HTML format under directory: '"
261+
<< cmdline.get_value("dump-html-program")
262+
<< "'..."
263+
<< eom;
264+
if(fileutl_file_exists(cmdline.get_value("dump-html-program")))
265+
{
266+
error()
267+
<< "ERROR: The output path '"
268+
<< cmdline.get_value("dump-html-program")
269+
<< "' for the HTML dump exists."
270+
<< eom;
271+
return -1;
272+
}
273+
class_hierarchyt class_hierarchy;
274+
class_hierarchy(goto_model.symbol_table);
275+
call_grapht call_graph(goto_model.goto_functions);
276+
std::vector<irep_idt> inverted_topological_order;
277+
{
278+
std::unordered_set<irep_idt, dstring_hash> processed;
279+
for(const auto &elem : goto_model.goto_functions.function_map)
280+
inverted_partial_topological_order(
281+
call_graph,
282+
elem.first,
283+
processed,
284+
inverted_topological_order);
285+
}
286+
dump_goto_program_in_html(
287+
goto_model,
288+
call_graph,
289+
class_hierarchy,
290+
goto_model.symbol_table,
291+
inverted_topological_order,
292+
cmdline.get_value("dump-html-program"));
293+
return 0;
294+
}
295+
256296
error() << "no analysis option given -- consider reading --help"
257297
<< eom;
258298
return 6;
@@ -416,6 +456,10 @@ void sec_driver_parse_optionst::help()
416456
" --show-symbol-table show symbol table\n"
417457
" --show-goto-functions show goto program\n"
418458
" --show-properties show the properties, but don't run analysis\n"
459+
" --dump-html-program dump goto program in HTML format into\n"
460+
" a directory. Pass a non existing directory\n"
461+
" path-name with this option. The directory\n"
462+
" will be created with the dumped program.\n"
419463
"\n"
420464
"Other options:\n"
421465
" --version show version and exit\n"

src/driver/sec_driver_parse_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class optionst;
2525
"(little-endian)(big-endian)" \
2626
"(show-goto-functions)(show-loops)" \
2727
"(show-symbol-table)(show-parse-tree)" \
28+
"(dump-html-program):" \
2829
"(show-properties)(show-reachable-properties)(property):" \
2930
"(verbosity):(version)" \
3031
"(gcc)(arch):" \

0 commit comments

Comments
 (0)