Go to the documentation of this file.
25 const std::vector<std::string> &args)
27 symbol_table(symbol_table),
54 auto point_int = address2size_t(point);
56 return (point_int - begin_int) / member_size;
59 std::vector<gdb_value_extractort::memory_scopet>::iterator
65 [&name](
const memory_scopet &scope) { return scope.id() == name; });
68 std::vector<gdb_value_extractort::memory_scopet>::iterator
75 return memory_scope.contains(point);
85 return scope_it->size();
96 const auto pointer_distance = scope_it->distance(point, member_size);
98 (pointer_distance > 0 ?
"+" +
integer2string(pointer_distance) :
"");
105 return *maybe_size / 8;
133 symbol_value.
address, symbol_size,
id);
156 const exprt target_expr =
198 symbolt snapshot_symbol(symbol);
199 snapshot_symbol.
value = pair.second;
201 snapshot.
insert(snapshot_symbol);
207 const symbolt &symbol = pair.second;
233 auto it =
values.find(memory_location);
253 values.insert(std::make_pair(memory_location, new_symbol));
272 const auto &memory_location = pointer_value.
address;
273 std::string memory_location_string = memory_location.
string();
277 std::string struct_name;
281 std::string member_offset_string;
283 pointer_value.
pointee,
'+', struct_name, member_offset_string,
true);
288 struct_name = pointer_value.
pointee;
301 const auto &struct_symbol_expr = struct_symbol->
symbol_expr();
302 if(struct_symbol->
type.
id() == ID_array)
309 if(struct_symbol->
type.
id() == ID_pointer)
320 maybe_member_expr.has_value(),
"structure doesn't have member");
324 return *maybe_member_expr;
336 const auto &function_name = pointer_value.
pointee;
339 if(function_symbol ==
nullptr)
342 "input source code does not contain function: " + function_name};
345 return function_symbol->symbol_expr();
355 const auto &memory_location = value.
address;
358 auto it =
values.find(memory_location);
367 const auto pointee_symbol_expr = pointee_symbol->symbol_expr();
368 return pointee_symbol_expr;
388 const auto number_of_elements = allocated_size /
get_type_size(target_type);
389 if(allocated_size != 1 && number_of_elements > 1)
393 for(
size_t i = 0; i < number_of_elements; i++)
399 elements.push_back(sub_expr_value);
404 const typet target_array_type =
411 const auto array_symbol =
417 values[memory_location] = array_symbol;
428 const exprt target_expr =
433 values[memory_location] = new_symbol;
439 const auto &known_value = it->second;
443 if(known_value.is_not_nil() && known_value.type() != expected_type)
454 const typet &expected_type)
459 if(pointer_value.
pointee.empty())
463 if(maybe_pointee.has_value())
464 pointer_value.
pointee = *maybe_pointee;
465 if(pointer_value.
pointee.find(
"+") != std::string::npos)
470 if(pointee_symbol ==
nullptr)
472 const auto &pointee_type = pointee_symbol->
type;
473 return pointee_type.
id() == ID_struct_tag ||
474 pointee_type.id() == ID_union_tag || pointee_type.id() == ID_array ||
475 pointee_type.id() == ID_struct || pointee_type.id() == ID_union;
480 const exprt &zero_expr,
489 const auto known_pointer =
memory_map.find(c_expr);
492 known_pointer->second.pointee == c_expr)
494 : known_pointer->second;
498 const auto memory_location = value.
address;
500 if(!memory_location.is_null())
505 const auto target_expr =
510 return std::move(result_expr);
516 const auto target_expr =
521 return std::move(result_expr);
525 const auto target_expr =
531 if(target_expr.is_nil())
541 if(target_expr.type().id() == ID_array)
546 if(result_indexed_expr->type() == zero_expr.
type())
547 return *result_indexed_expr;
550 return std::move(result_expr);
554 if(target_expr.type() == zero_expr.
type())
559 if(result_expr.type() != zero_expr.
type())
561 return std::move(result_expr);
577 exprt new_array(array);
579 for(
size_t i = 0; i < new_array.
operands().size(); ++i)
593 const exprt &zero_expr,
607 if(!maybe_value.has_value())
609 const std::string value = *maybe_value;
622 if(!maybe_value.has_value() || maybe_value->empty())
624 const std::string value = *maybe_value;
629 else if(type.
id() == ID_c_bool)
635 if(!maybe_value.has_value())
637 const std::string value = *maybe_value;
641 else if(type.
id() == ID_c_enum)
647 if(!maybe_value.has_value())
649 const std::string value = *maybe_value;
653 else if(type.
id() == ID_struct_tag)
657 else if(type.
id() == ID_array)
661 else if(type.
id() == ID_pointer)
667 else if(type.
id() == ID_union_tag)
676 const exprt &zero_expr,
684 exprt new_expr(zero_expr);
689 for(
size_t i = 0; i < new_expr.
operands().size(); ++i)
709 const exprt &zero_expr,
717 exprt new_expr(zero_expr);
724 auto &operand = new_expr.
operands()[0];
#define UNREACHABLE
This should be used to mark dead code.
const componentst & components() const
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
A codet representing sequential composition of program statements.
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
const typet & subtype() const
size_t query_malloc_size(const std::string &pointer_expr)
Get the exact allocated size for a pointer pointer_expr.
Data associated with the value of a pointer, i.e.
#define CHECK_RETURN(CONDITION)
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a typet to a c_enum_typet.
The type of an expression, extends irept.
typet type
Type of symbol.
Operator to dereference a pointer.
constant_exprt convert_member_name_to_enum_value(const irep_idt &member_name, const c_enum_typet &c_enum)
This function creates a constant representing the bitvector encoded integer value of a string in the ...
optionalt< std::string > get_value(const std::string &expr)
Get the memory address pointed to by the given pointer expression.
constant_exprt from_c_boolean_value(bool bool_value, const typet &type)
This function creates a constant representing either 0 or 1 as value of type type.
const mp_integer string2integer(const std::string &n, unsigned base)
The plus expression Associativity is not specified.
Base class for all expressions.
A struct tag type, i.e., struct_typet with an identifier.
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
Thrown when we can't handle something in an input source file.
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
bool id2boolean(const std::string &bool_value)
Convert id to a Boolean value.
Memory address imbued with the explicit boolean data indicating if the address is null or not.
Expression to hold a symbol (variable)
bitvector_typet index_type()
std::size_t safe_string2size_t(const std::string &str, int base)
optionalt< exprt > zero_initializer(const typet &type, const source_locationt &source_location, const namespacet &ns)
Create the equivalent of zero for type type.
virtual iteratort begin() override
A union tag type, i.e., union_typet with an identifier.
std::string address_string
std::string what() const override
A human readable description of what went wrong.
typet & type()
Return the type of the expression.
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
void split_string(const std::string &s, char delim, std::vector< std::string > &result, bool strip, bool remove_empty)
virtual std::string convert(const typet &src)
Expression Initialization.
bool is_c_char_type(const typet &type)
This function checks, whether this has been a char type in the c program.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
const std::string & id2string(const irep_idt &d)
#define PRECONDITION(CONDITION)
const irep_idt & get_identifier() const
optionalt< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
virtual std::pair< symbolt &, bool > insert(symbolt symbol) override
Author: Diffblue Ltd.
bool is_c_integral_type(const typet &type)
This function checks, whether the type has been some kind of integer type in the c program.
pointer_typet pointer_type(const typet &subtype)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
optionalt< std::string > string
const irep_idt & id() const
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
std::vector< exprt > operandst
void add(const codet &code)
High-level interface to gdb.
nonstd::optional< T > optionalt
void declare_created_symbols(code_blockt &init_code)
Adds declarations for all non-static symbols created.
pointer_valuet get_memory(const std::string &expr)
Get the value of a pointer associated with expr.
This file contains functions, that should support test for underlying c types, in cases where this is...
Extract member of struct or union.
exprt value
Initial value of symbol.
Structure type, corresponds to C style structs.
source_locationt location
Source code location of definition of symbol.
optionalt< exprt > get_subexpression_at_offset(const exprt &expr, const mp_integer &offset_bytes, const typet &target_type_raw, const namespacet &ns)
const symbolst & symbols
Read-only field, used to look up symbols given their names.
bool is_constant() const
Return whether the expression is a constant.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
std::string string() const
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
Operator to return the address of an object.
Used for configuring the behaviour of expr2c and type2c.
exprt allocate_automatic_local_object(code_blockt &assignments, const exprt &target_expr, const typet &allocate_type, const irep_idt &basename_prefix="tmp")
Creates a local variable with automatic lifetime.
Semantic type conversion.
unsignedbv_typet size_type()
A codet representing an assignment in the program.
optionalt< mp_integer > member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)
Array constructor from list of elements.
Thrown when an unexpected error occurs during the analysis (e.g., when the SAT solver returns an erro...
const std::string integer2string(const mp_integer &n, unsigned base)
bool has_known_offset() const