36 const std::string &taint_file_name,
40 const std::string &json_file_name);
62 for(goto_programt::instructionst::iterator
63 it=goto_function.body.instructions.begin();
64 it!=goto_function.body.instructions.end();
71 switch(instruction.
type)
79 if(
function.
id()==ID_symbol)
84 std::set<irep_idt> identifiers;
86 identifiers.insert(identifier);
88 irep_idt class_id=
function.get(ID_C_class);
100 for(
const auto &p : parents)
107 for(
const auto &i : identifiers)
108 if(i==rule.function_identifier ||
111 "java::"+
id2string(rule.function_identifier)+
":"))
119 debug() <<
"MATCH " << rule.id <<
" on " << identifier <<
eom;
127 code_type.
parameters().front().get_bool(ID_C_this);
133 const symbolt &return_value_symbol=
142 have_this?rule.parameter_number:rule.parameter_number-1;
151 assert(!function_call.
arguments().empty());
161 codet code_set_may(
"set_may");
163 code_set_may.
op0()=where;
167 t->make_other(code_set_may);
182 t->source_location.set_comment(rule.message);
188 codet code_clear_may(
"clear_may");
189 code_clear_may.
operands().resize(2);
190 code_clear_may.
op0()=where;
191 code_clear_may.
op1()=
194 t->make_other(code_clear_may);
210 if(!insert_before.
empty())
212 goto_function.body.insert_before_swap(it, insert_before);
214 while(!it->is_function_call()) ++it;
217 if(!insert_after.
empty())
219 goto_function.body.destructive_insert(
220 std::next(it), insert_after);
226 const std::string &taint_file_name,
230 const std::string &json_file_name)
235 bool use_json=!json_file_name.empty();
237 status() <<
"Reading taint file `" << taint_file_name
242 error() <<
"Failed to read taint definition file" <<
eom;
247 <<
" taint definitions" <<
eom;
252 status() <<
"Instrumenting taint" <<
eom;
260 bool have_entry_point=
267 status() <<
"Working from entry point" <<
eom;
271 status() <<
"No entry point found; " 272 <<
"we will consider the heads of all functions as reachable" 280 if(f_it->second.body_available() &&
286 t->make_function_call(call);
307 custom_bitvector_analysis(goto_functions, ns);
311 custom_bitvector_analysis.
output(ns, goto_functions, std::cout);
317 if(!f_it->second.body.has_assertion())
322 if(f_it->first==
"__actual_thread_spawn")
329 if(!i_it->is_assert())
334 if(custom_bitvector_analysis[i_it].has_values.is_false())
348 <<
"******** Function " << symbol.
display_name() <<
'\n';
355 json_stringt(i_it->source_location.get_property_class());
363 std::cout << i_it->source_location;
364 if(!i_it->source_location.get_comment().empty())
365 std::cout <<
": " << i_it->source_location.get_comment();
367 if(!i_it->source_location.get_property_class().empty())
369 << i_it->source_location.get_property_class() <<
")";
378 std::ofstream json_out(json_file_name);
382 error() <<
"Failed to open json output `" 383 << json_file_name <<
"'" <<
eom;
387 status() <<
"Analysis result is written to `" 388 << json_file_name <<
"'" <<
eom;
390 json_out << json_result <<
'\n';
395 catch(
const char *error_msg)
400 catch(
const std::string &error_msg)
407 error() <<
"Caught unexpected error in taint_analysist::operator()" <<
eom;
414 const std::string &taint_file_name,
417 const std::string &json_file_name)
Field-insensitive, location-sensitive bitvector analysis.
const std::string & id2string(const irep_idt &d)
void set_property_class(const irep_idt &property_class)
exprt simplify_expr(const exprt &src, const namespacet &ns)
goto_program_instruction_typet type
What kind of instruction?
void output(std::ostream &) const
const code_typet & to_code_type(const typet &type)
Cast a generic typet to a code_typet.
const irep_idt & get_identifier() const
void destructive_append(goto_programt &p)
Appends the given program, which is destroyed.
function_mapt function_map
symbol_tablet symbol_table
Symbol table.
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
static mstreamt & eom(mstreamt &m)
This class represents an instruction in the GOTO intermediate representation.
virtual void output(const namespacet &ns, const goto_functionst &goto_functions, std::ostream &out) const
bool taint_analysis(goto_modelt &goto_model, const std::string &taint_file_name, message_handlert &message_handler, bool show_full, const std::string &json_file_name)
class_hierarchyt class_hierarchy
class symbol_exprt symbol_expr() const
produces a symbol_exprt for a symbol
void instrument(const namespacet &, goto_functionst &)
instructionst::iterator targett
instructionst instructions
The list of instructions in the goto program.
static bool has_get_must_or_may(const exprt &)
::goto_functiont goto_functiont
A side effect that returns a non-deterministically chosen value.
bool has_prefix(const std::string &s, const std::string &prefix)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
Operator to return the address of an object.
std::vector< irep_idt > idst
A generic container class for the GOTO intermediate representation of one function.
const irep_idt & display_name() const
bool taint_parser(const std::string &file_name, taint_parse_treet &dest, message_handlert &message_handler)
message_handlert & get_message_handler()
static irep_idt entry_point()
mstreamt & result() const
mstreamt & status() const
source_locationt source_location
The location of the instruction in the source file.
targett add_instruction()
Adds an instruction at the end.
Base class for all expressions.
const parameterst & parameters() const
bool empty() const
Is the program empty?
bool operator()(const std::string &taint_file_name, const symbol_tablet &, goto_functionst &, bool show_full, const std::string &json_file_name)
exprt eval(const exprt &src, locationt loc)
goto_programt coverage_criteriont message_handlert & message_handler
A statement in a programming language.
A generic base class for expressions that are predicates, i.e., boolean-typed, and that take exactly ...
#define forall_goto_functions(it, functions)
#define forall_goto_program_instructions(it, program)
idst get_parents_trans(const irep_idt &id) const
goto_functionst goto_functions
GOTO functions.
json_objectt json(const source_locationt &location)
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See namespace_baset::lookup().
const code_function_callt & to_code_function_call(const codet &code)