Skip to content

Commit 7c94bfe

Browse files
committed
Include taint slicer/instrumenter to time profiler.
1 parent 3540122 commit 7c94bfe

File tree

7 files changed

+69
-0
lines changed

7 files changed

+69
-0
lines changed

src/taint-slicer/instrumentation_props.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <java_bytecode/expr2java.h>
1919
#include <util/prefix.h>
2020
#include <util/msgstream.h>
21+
#include <util/tmprof.h>
2122
#include <deque>
2223

2324
bool is_primitive_type(const typet &type)
@@ -74,6 +75,8 @@ static void perform_BFS(
7475
const std::set<taint_function_idt> &functions,
7576
std::set<taint_propagation_chainst::node_idt> &reachable)
7677
{
78+
TMPROF_BLOCK();
79+
7780
std::deque<taint_propagation_chainst::node_idt> work;
7881
for(const auto nid :
7982
do_fwd_search ? chains.get_sources() :
@@ -112,6 +115,8 @@ taint_instrumentation_propst::taint_instrumentation_propst(
112115
, use_data_flow_insensitive_version(
113116
use_data_flow_insensitive_instrumentation)
114117
{
118+
TMPROF_BLOCK();
119+
115120
// First we compute "valid" nodes of the propagation chaint w.r.t. the root
116121
// function. We find these nodes by 2 BFSs: one from sources and one from
117122
// sinks. During both searches we have to stay inside the set of passed
@@ -155,6 +160,8 @@ void taint_instrumentation_propst::build_map_from_typenames_to_tokennames(
155160
const taint_propagation_chainst &chains,
156161
const taint_programt &program)
157162
{
163+
TMPROF_BLOCK();
164+
158165
for(const auto &loc : get_location_props())
159166
{
160167
const goto_programt::instructiont &I=*loc.get_instruction_id();
@@ -223,6 +230,8 @@ void taint_build_instrumentation_props(
223230
std::vector<taint_instrumentation_propst> &output,
224231
const bool use_data_flow_insensitive_instrumentation)
225232
{
233+
TMPROF_BLOCK();
234+
226235
// First we collect all functions mentioned in the graph of chains.
227236
std::set<irep_idt> functions;
228237
{
@@ -336,6 +345,8 @@ void taint_build_instrumentation_props(
336345

337346
void dump_as_json(const taint_instrumentation_propst &props, json_objectt &out)
338347
{
348+
TMPROF_BLOCK();
349+
339350
out["data_flow_insensitive_instrumentation_applied"]=jsont::json_boolean(
340351
props.data_flow_insensitive_version_applied());
341352
{

src/taint-slicer/instrumenter.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <util/arith_tools.h>
1717
#include <util/pointer_offset_size.h>
1818
#include <util/msgstream.h>
19+
#include <util/tmprof.h>
1920
#include <util/std_expr.h>
2021

2122
const c_bool_typet &get_shadow_variable_type()
@@ -133,6 +134,8 @@ exprt make_or_update_initialiser(
133134
const std::set<taint_instrumentert::automaton_variable_idt> &
134135
names_of_shadow_variables)
135136
{
137+
TMPROF_BLOCK();
138+
136139
if(new_type.id() != ID_struct)
137140
{
138141
// Rewrite type regardless, for example to turn (array*)null into
@@ -205,6 +208,8 @@ static void get_access_paths_to_shadow_vars(
205208
const symbol_tablet &instrumented_symbols_table,
206209
const std::set<taint_instrumented_variable_idt> &names_of_shadow_variables)
207210
{
211+
TMPROF_BLOCK();
212+
208213
// The only expected type of the dereferenced lhs of MALLOC
209214
// statement is ID_struct. Arrays are not supported yet.
210215
PRECONDITION(expr.type().id()==ID_struct);
@@ -245,6 +250,8 @@ static exprt get_super_if_subclassed(
245250
&inverse_substitutions,
246251
const symbol_tablet &symbol_table)
247252
{
253+
TMPROF_BLOCK();
254+
248255
namespacet ns(symbol_table);
249256
const typet &expr_type=ns.follow(expr.type());
250257

@@ -327,6 +334,8 @@ static bool is_unary_expression(const exprt &expr)
327334
exprt taint_instrumentert::drive_access_path_through_super_classes(
328335
const exprt &access_path) const
329336
{
337+
TMPROF_BLOCK();
338+
330339
const irept fixed_type_irep=
331340
instrument(access_path.type(), std::bind(
332341
&substitute_subclassed_types,
@@ -499,6 +508,8 @@ void taint_instrumentert::instrument_instructions_with_shadow_variables(
499508
goto_programt &program_to_be_instrumented,
500509
const taint_instrumentation_propst &props) const
501510
{
511+
TMPROF_BLOCK();
512+
502513
goto_programt::instructionst &instructions_to_be_instrumented=
503514
program_to_be_instrumented.instructions;
504515
const namespacet ns(get_instrumented_symbol_table());
@@ -773,6 +784,8 @@ taint_instrumentert::taint_instrumentert(
773784
/// individual elements of props.get_location_props().
774785
void taint_instrumentert::run()
775786
{
787+
TMPROF_BLOCK();
788+
776789
PRECONDITION(program!=nullptr);
777790
PRECONDITION(statistics!=nullptr);
778791

@@ -924,6 +937,8 @@ void taint_instrumentert::run()
924937
void taint_instrumentert::instrument_data_types(
925938
const taint_instrumentation_propst &props)
926939
{
940+
TMPROF_BLOCK();
941+
927942
std::set<irep_idt> new_type_names;
928943
for(const auto &id_info : props.get_datatypes())
929944
{
@@ -1066,6 +1081,8 @@ static exprt make_accessor_expression_to_shadow_variable(
10661081
const std::string &shadow_variable_name,
10671082
const symbol_tablet &symbol_table)
10681083
{
1084+
TMPROF_BLOCK();
1085+
10691086
namespacet ns(symbol_table);
10701087
const typet &arg_type = ns.follow(argument.type());
10711088
if(arg_type.id() == ID_pointer)
@@ -1108,6 +1125,8 @@ void taint_instrumentert::instrument_location(
11081125
const taint_mutable_instruction_idt rule_instruction_ptr,
11091126
const taint_instrumentation_propst &props)
11101127
{
1128+
TMPROF_BLOCK();
1129+
11111130
const taint_instrumentation_propst::location_propst &loc=
11121131
props.get_location_props().at(lid);
11131132

@@ -1178,6 +1197,8 @@ void taint_instrumentert::instrument_location(
11781197
const irep_idt function_id,
11791198
goto_programt &instrumentation_code)
11801199
{
1200+
TMPROF_BLOCK();
1201+
11811202
for(const auto &arg_token : args_and_tokens)
11821203
{
11831204
const exprt acc_path=
@@ -1231,6 +1252,8 @@ void taint_instrumentert::instrument_location_data_flow_insensitive(
12311252
const taint_mutable_instruction_idt instrumention_tail_instruction,
12321253
const taint_instrumentation_propst &props)
12331254
{
1255+
TMPROF_BLOCK();
1256+
12341257
const taint_instrumentation_propst::location_propst &loc=
12351258
props.get_location_props().at(lid);
12361259
goto_functionst::goto_functiont &instrumented_function=

src/taint-slicer/irept_instrument.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Date: May 2017
1212
\*******************************************************************/
1313

1414
#include <taint-slicer/irept_instrument.h>
15+
#include <util/tmprof.h>
1516

1617
#include <cassert>
1718

@@ -22,6 +23,8 @@ Date: May 2017
2223

2324
irept instrument(const irept irep, const instrumenter_fnt &instrumenter)
2425
{
26+
TMPROF_BLOCK();
27+
2528
bool modified=false;
2629

2730
irept::subt new_sub;
@@ -76,6 +79,8 @@ irept instrument_using_guide(
7679
const irept irep,
7780
const guide_instrumenter_fnt &instrumenter)
7881
{
82+
TMPROF_BLOCK();
83+
7984
bool modified=false;
8085

8186
irept::subt new_sub;

src/taint-slicer/propagation_chains.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <taint-slicer/propagation_chains.h>
1515
#include <util/file_util.h>
1616
#include <util/msgstream.h>
17+
#include <util/tmprof.h>
1718
#include <unordered_set>
1819
#include <deque>
1920
#include <algorithm>
@@ -31,6 +32,8 @@ static void compute_automaton_state_update_data(
3132
std::vector<argidx_and_tokennamet> &turn_on,
3233
std::vector<argidx_and_tokennamet> &turn_off)
3334
{
35+
TMPROF_BLOCK();
36+
3437
const bool is_sanitiser=
3538
tokens_propagation_graph.get_sanitiser_rules().count(rid)!=0UL;
3639

@@ -109,6 +112,8 @@ taint_propagation_chainst::taint_propagation_chainst(
109112
const taint_map_from_rules_to_their_application_sitest &rule_applications,
110113
taint_statisticst * const statistics)
111114
{
115+
TMPROF_BLOCK();
116+
112117
// First we collect sources and sinks
113118
for(const auto &rid :
114119
tokens_propagation_graph.get_forward_rules_from_token(
@@ -201,6 +206,8 @@ taint_propagation_chainst::extend_chain_by_transition(
201206
const call_grapht &inverted_call_graph,
202207
const taint_tokens_propagation_grapht &tokens_propagation_graph)
203208
{
209+
TMPROF_BLOCK();
210+
204211
// First we check call-graph reachability from instrumentation location of
205212
// "nid" to the target instrumentation location (identified by "fid" and
206213
// "iid"). If no path exists, then we terminate with failure (no transition
@@ -269,6 +276,8 @@ taint_propagation_chainst::extend_chain_by_transition(
269276
taint_propagation_chainst::node_idt
270277
taint_propagation_chainst::erase_node(const node_idt nid)
271278
{
279+
TMPROF_BLOCK();
280+
272281
nodes.at(nid)=nodes.back();
273282
nodes.pop_back();
274283

@@ -349,6 +358,8 @@ taint_propagation_chainst::erase_node(const node_idt nid)
349358

350359
void taint_propagation_chainst::erase_dead_branches()
351360
{
361+
TMPROF_BLOCK();
362+
352363
std::set<node_idt> dead_nodes;
353364
{
354365
// Use BFS to find all nodes forward-reachable from sources.
@@ -439,6 +450,8 @@ std::ostream &to_dot(
439450
const taint_propagation_chainst &chains,
440451
std::ostream &ostr)
441452
{
453+
TMPROF_BLOCK();
454+
442455
ostr << "digraph propagation_chains {\n"
443456
<< " rankdir=TB;\n"
444457
<< " node [fontsize=12 shape=box];\n"

src/taint-slicer/search_for_rule_applications.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
#include <taint-slicer/search_for_rule_applications.h>
88
#include <taint-analysis/taint_summary.h>
99
#include <boost/range/algorithm_ext/push_back.hpp>
10+
#include <util/tmprof.h>
1011
#include <string>
1112
#include <vector>
1213

1314
void taint_search_for_rule_applications(
1415
const taint_summaryt::dbt * const summaries,
1516
taint_map_from_rules_to_their_application_sitest &result)
1617
{
18+
TMPROF_BLOCK();
19+
1720
for(taint_summaryt::dbt::const_reference summary : *summaries)
1821
{
1922
for(const auto &iit_props : summary.second->get_transition_props())
@@ -43,6 +46,8 @@ void to_json(
4346
map_from_functions_to_rule_application_sites,
4447
json_objectt &result)
4548
{
49+
TMPROF_BLOCK();
50+
4651
for(const auto &rid_map : map_from_functions_to_rule_application_sites)
4752
{
4853
json_objectt rid;

src/taint-slicer/slicer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <taint-slicer/slicing_tasks_builder.h>
1313
#include <util/msgstream.h>
1414
#include <util/file_util.h>
15+
#include <util/tmprof.h>
1516
#include <summaries/summary_dump.h>
1617
#include <algorithm>
1718
#include <fstream>
@@ -49,6 +50,8 @@ taint_slicert::taint_slicert(
4950
void taint_slicert::compute_slice(
5051
const bool use_data_flow_insensitive_instrumentation)
5152
{
53+
TMPROF_BLOCK();
54+
5255
statistics->begin_search_for_rule_applications();
5356

5457
taint_map_from_rules_to_their_application_sitest

src/taint-slicer/slicing_tasks_builder.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <util/file_util.h>
2222
#include <util/fresh_symbol.h>
2323
#include <util/msgstream.h>
24+
#include <util/tmprof.h>
2425
#include <summaries/summary_dump.h>
2526
#include <exception>
2627
#include <iostream>
@@ -33,6 +34,8 @@ static void remove_calls_to_functions_without_bodies(
3334
goto_functionst &goto_functions,
3435
symbol_tablet &symbol_table)
3536
{
37+
TMPROF_BLOCK();
38+
3639
std::set<irep_idt> fns_without_bodies;
3740
for(auto &fname_prog : goto_functions.function_map)
3841
{
@@ -100,6 +103,8 @@ static void add_nondet_retval_assignments_after_calls(
100103
const std::string &callee_name,
101104
const typet &callee_ret_type)
102105
{
106+
TMPROF_BLOCK();
107+
103108
for(auto it=goto_program.instructions.begin();
104109
it!=goto_program.instructions.end();
105110
++it)
@@ -143,6 +148,8 @@ std::pair<taint_slicing_taskt,std::string> build_slicing_task(
143148
const bool perform_html_dump,
144149
const bool string_refinement_enabled)
145150
{
151+
TMPROF_BLOCK();
152+
146153
// The pathname of the output GOTO program binary file of the slicing task.
147154
const auto pathname=
148155
(output_dir /
@@ -392,6 +399,8 @@ std::pair<taint_slicing_taskt,std::string> build_slicing_task(
392399

393400
void dump_as_json(const taint_slicing_taskt &task, json_objectt &out)
394401
{
402+
TMPROF_BLOCK();
403+
395404
out["root_function"]=json_stringt(task.get_root_function());
396405
out["goto_binary_file"]=json_stringt(task.get_goto_binary_file());
397406
json_arrayt jsinks;

0 commit comments

Comments
 (0)