static bool
get_parent_die(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
Dwarf_Die& parent_die,
size_t where_offset);
static bool
get_scope_die(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
size_t where_offset,
Dwarf_Die& scope_die);
static bool
-die_is_anonymous(Dwarf_Die* die);
+die_is_anonymous(const Dwarf_Die* die);
static bool
-die_is_type(Dwarf_Die* die);
+die_is_type(const Dwarf_Die* die);
static bool
-die_is_decl(Dwarf_Die* die);
+die_is_decl(const Dwarf_Die* die);
static bool
-die_is_namespace(Dwarf_Die* die);
+die_is_namespace(const Dwarf_Die* die);
static bool
die_is_unspecified(Dwarf_Die* die);
die_is_void_type(Dwarf_Die* die);
static bool
-die_is_pointer_type(Dwarf_Die* die);
+die_is_pointer_type(const Dwarf_Die* die);
static bool
-pointer_or_qual_die_of_anonymous_class_type(Dwarf_Die* die);
+pointer_or_qual_die_of_anonymous_class_type(const Dwarf_Die* die);
static bool
-die_is_reference_type(Dwarf_Die* die);
+die_is_reference_type(const Dwarf_Die* die);
static bool
-die_is_pointer_or_reference_type(Dwarf_Die* die);
+die_is_pointer_or_reference_type(const Dwarf_Die* die);
static bool
-die_is_pointer_reference_or_typedef_type(Dwarf_Die* die);
+die_is_pointer_reference_or_typedef_type(const Dwarf_Die* die);
static bool
die_is_class_type(Dwarf_Die* die);
static bool
-die_is_qualified_type(Dwarf_Die* die);
+die_is_qualified_type(const Dwarf_Die* die);
static bool
-die_has_object_pointer(Dwarf_Die* die,
+die_has_object_pointer(const Dwarf_Die* die,
Dwarf_Die& object_pointer);
static bool
static bool
die_is_at_class_scope(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
size_t where_offset,
Dwarf_Die& class_scope_die);
static bool
dwarf_language_to_tu_language(size_t l);
static bool
-die_unsigned_constant_attribute(Dwarf_Die* die,
- unsigned attr_name,
- uint64_t& cst);
+die_unsigned_constant_attribute(const Dwarf_Die* die,
+ unsigned attr_name,
+ uint64_t& cst);
static bool
-die_signed_constant_attribute(Dwarf_Die*die,
+die_signed_constant_attribute(const Dwarf_Die*die,
unsigned attr_name,
int64_t& cst);
static bool
-die_constant_attribute(Dwarf_Die *die,
+die_constant_attribute(const Dwarf_Die *die,
unsigned attr_name,
array_type_def::subrange_type::bound_value &value);
static bool
-die_attribute_has_form(Dwarf_Die* die,
- unsigned attr_name,
- unsigned int form);
+die_attribute_has_form(const Dwarf_Die* die,
+ unsigned attr_name,
+ unsigned int form);
static bool
-die_attribute_is_signed(Dwarf_Die* die, unsigned attr_name);
+die_attribute_is_signed(const Dwarf_Die* die, unsigned attr_name);
static bool
-die_attribute_is_unsigned(Dwarf_Die* die, unsigned attr_name);
+die_attribute_is_unsigned(const Dwarf_Die* die, unsigned attr_name);
static bool
-die_attribute_has_no_signedness(Dwarf_Die* die, unsigned attr_name);
+die_attribute_has_no_signedness(const Dwarf_Die* die, unsigned attr_name);
static bool
die_address_attribute(Dwarf_Die* die, unsigned attr_name, Dwarf_Addr& result);
static string
-die_name(Dwarf_Die* die);
+die_name(const Dwarf_Die* die);
static location
-die_location(const read_context& ctxt, Dwarf_Die* die);
+die_location(const read_context& ctxt, const Dwarf_Die* die);
static bool
die_location_address(Dwarf_Die* die,
bool& is_tls_address);
static bool
-die_die_attribute(Dwarf_Die* die,
+die_die_attribute(const Dwarf_Die* die,
unsigned attr_name,
Dwarf_Die& result,
bool look_thru_abstract_origin = true);
static string
-get_internal_anonynous_die_base_name(Dwarf_Die *die);
+get_internal_anonynous_die_base_name(const Dwarf_Die *die);
static string
build_internal_anonymous_die_name(const string &base_name,
size_t anonymous_type_index);
static string
-die_qualified_type_name(const read_context& ctxt, Dwarf_Die* die, size_t where);
+die_qualified_type_name(const read_context& ctxt,
+ const Dwarf_Die* die,
+ size_t where);
static string
-die_qualified_decl_name(const read_context& ctxt, Dwarf_Die* die, size_t where);
+die_qualified_decl_name(const read_context& ctxt,
+ const Dwarf_Die* die,
+ size_t where);
static string
-die_qualified_name(const read_context& ctxt, Dwarf_Die* die, size_t where);
+die_qualified_name(const read_context& ctxt,
+ const Dwarf_Die* die,
+ size_t where);
static bool
die_qualified_type_name_empty(const read_context& ctxt,
- Dwarf_Die* die, size_t where,
+ const Dwarf_Die* die, size_t where,
string &qualified_name);
static void
die_return_and_parm_names_from_fn_type_die(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
size_t where_offset,
bool pretty_print,
string &return_type_name,
static string
die_function_signature(const read_context& ctxt,
- Dwarf_Die *die,
+ const Dwarf_Die *die,
size_t where_offset);
static bool
static bool
die_function_type_is_method_type(const read_context& ctxt,
- Dwarf_Die *die,
+ const Dwarf_Die *die,
size_t where_offset,
Dwarf_Die& object_pointer_die,
Dwarf_Die& class_die,
bool& is_static);
static string
-die_pretty_print_type(read_context& ctxt, Dwarf_Die* die, size_t where_offset);
+die_pretty_print_type(read_context& ctxt,
+ const Dwarf_Die* die,
+ size_t where_offset);
static string
-die_pretty_print_decl(read_context& ctxt, Dwarf_Die* die, size_t where_offset);
+die_pretty_print_decl(read_context& ctxt,
+ const Dwarf_Die* die,
+ size_t where_offset);
static string
-die_pretty_print(read_context& ctxt, Dwarf_Die* die, size_t where_offset);
+die_pretty_print(read_context& ctxt,
+ const Dwarf_Die* die,
+ size_t where_offset);
static void
-maybe_canonicalize_type(Dwarf_Die* die, read_context& ctxt);
+maybe_canonicalize_type(Dwarf_Die* die,
+ read_context& ctxt);
static uint64_t
get_default_array_lower_bound(translation_unit::language l);
imported_unit_points_type::const_iterator&);
static array_type_def::subrange_sptr
-build_subrange_type(read_context& ctxt,
- Dwarf_Die* die,
+build_subrange_type(read_context& ctxt,
+ const Dwarf_Die* die,
size_t where_offset,
bool associate_type_to_die = true);
static void
-build_subranges_from_array_type_die(read_context& ctxt,
- Dwarf_Die* die,
- array_type_def::subranges_type& subranges,
- size_t where_offset,
- bool associate_type_to_die = true);
+build_subranges_from_array_type_die(read_context& ctxt,
+ const Dwarf_Die* die,
+ array_type_def::subranges_type& subranges,
+ size_t where_offset,
+ bool associate_type_to_die = true);
static bool
compare_dies(const read_context& ctxt,
- Dwarf_Die *l, Dwarf_Die *r,
+ const Dwarf_Die *l, const Dwarf_Die *r,
bool update_canonical_dies_on_the_fly);
/// Convert an elf symbol type (given by the ELF{32,64}_ST_TYPE
/// @return the container that associates DIEs coming from the
/// same source as @p die.
ContainerType&
- get_container(const read_context& ctxt, Dwarf_Die *die)
+ get_container(const read_context& ctxt, const Dwarf_Die *die)
{
die_source source = NO_DEBUG_INFO_DIE_SOURCE;
ABG_ASSERT(ctxt.get_die_source(die, source));
/// @return the container that associates DIEs coming from the
/// same source as @p die.
const ContainerType&
- get_container(const read_context& ctxt, Dwarf_Die *die) const
+ get_container(const read_context& ctxt, const Dwarf_Die *die) const
{
return const_cast<die_source_dependant_container_set*>(this)->
get_container(ctxt, die);
/// @param die_as_type if yes, it means @p die has to be considered
/// as a type.
void
- compute_canonical_die_offset(Dwarf_Die *die,
+ compute_canonical_die_offset(const Dwarf_Die *die,
Dwarf_Off &canonical_die_offset,
bool die_as_type) const
{
/// @param die_as_type if yes, it means @p die has to be considered
/// as a type.
void
- compute_canonical_die(Dwarf_Die *die,
+ compute_canonical_die(const Dwarf_Die *die,
offset_offset_map_type& canonical_dies,
Dwarf_Die &canonical_die,
bool die_as_type) const
die_source source;
ABG_ASSERT(get_die_source(die, source));
- Dwarf_Off die_offset = dwarf_dieoffset(die);
+ Dwarf_Off die_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(die));
compute_canonical_die(die_offset, source,
canonical_dies,
/// itself. @p canonical_die is thus set to the canonical die in
/// either cases.
bool
- get_or_compute_canonical_die(Dwarf_Die* die,
+ get_or_compute_canonical_die(const Dwarf_Die* die,
Dwarf_Die& canonical_die,
size_t where,
bool die_as_type) const
: const_cast<read_context*>(this)->canonical_decl_die_offsets_.
get_container(source);
- Dwarf_Off initial_die_offset = dwarf_dieoffset(die);
+ Dwarf_Off initial_die_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(die));
if (Dwarf_Off canonical_die_offset =
get_canonical_die_offset(canonical_dies,
/// @return true iff the source of the DIE could be determined and
/// returned.
bool
- get_die_source(Dwarf_Die *die, die_source &source) const
+ get_die_source(const Dwarf_Die *die, die_source &source) const
{
ABG_ASSERT(die);
return get_die_source(*die, source);
/// @return true iff the source of the DIE could be determined and
/// returned.
bool
- get_die_source(Dwarf_Die &die, die_source &source) const
+ get_die_source(const Dwarf_Die &die, die_source &source) const
{
Dwarf_Die cu_die;
Dwarf_Die cu_kind;
uint8_t address_size = 0, offset_size = 0;
- if (!dwarf_diecu(&die, &cu_die, &address_size, &offset_size))
+ if (!dwarf_diecu(const_cast<Dwarf_Die*>(&die),
+ &cu_die, &address_size,
+ &offset_size))
return false;
Dwarf_Half version = 0;
/// @return the interned string representing the qualified name of
/// @p die.
interned_string
- get_die_qualified_type_name(Dwarf_Die *die, size_t where_offset) const
+ get_die_qualified_type_name(const Dwarf_Die *die, size_t where_offset) const
{
ABG_ASSERT(die);
die_qualified_name_maps_.get_container(*const_cast<read_context*>(this),
die);
- size_t die_offset = dwarf_dieoffset(die);
+ size_t die_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(die));
die_istring_map_type::const_iterator i =
map.find(die_offset);
{
read_context& ctxt = *const_cast<read_context*>(this);
string qualified_name;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
if ((tag == DW_TAG_structure_type
|| tag == DW_TAG_class_type
|| tag == DW_TAG_union_type)
/// @return the interned_string that represents the pretty
/// representation.
interned_string
- get_die_pretty_type_representation(Dwarf_Die *die, size_t where_offset) const
+ get_die_pretty_type_representation(const Dwarf_Die *die,
+ size_t where_offset) const
{
ABG_ASSERT(die);
die_istring_map_type& map =
die_pretty_type_repr_maps_.get_container(*const_cast<read_context*>(this),
die);
- size_t die_offset = dwarf_dieoffset(die);
+ size_t die_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(die));
die_istring_map_type::const_iterator i = map.find(die_offset);
if (i == map.end())
/// @return the interned_string that represents the pretty
/// representation.
interned_string
- get_die_pretty_representation(Dwarf_Die *die, size_t where_offset) const
+ get_die_pretty_representation(const Dwarf_Die *die, size_t where_offset) const
{
ABG_ASSERT(die);
die_pretty_repr_maps_.get_container(*const_cast<read_context*>(this),
die);
- size_t die_offset = dwarf_dieoffset(die);
+ size_t die_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(die));
die_istring_map_type::const_iterator i = map.find(die_offset);
if (i == map.end())
///
/// @return true iff the language of the DIE was found.
bool
- get_die_language(Dwarf_Die *die, translation_unit::language &lang) const
+ get_die_language(const Dwarf_Die *die, translation_unit::language &lang) const
{
Dwarf_Die cu_die;
- ABG_ASSERT(dwarf_diecu(die, &cu_die, 0, 0));
+ ABG_ASSERT(dwarf_diecu(const_cast<Dwarf_Die*>(die), &cu_die, 0, 0));
uint64_t l = 0;
if (!die_unsigned_constant_attribute(&cu_die, DW_AT_language, l))
///
/// @return true if the ODR is relevant for @p die.
bool
- odr_is_relevant(Dwarf_Die *die) const
+ odr_is_relevant(const Dwarf_Die *die) const
{
translation_unit::language lang;
if (!get_die_language(die, lang))
/// @param die_as_type if true, it means that @p die has to be
/// considered as a type.
void
- set_canonical_die_offset(Dwarf_Die *die,
+ set_canonical_die_offset(const Dwarf_Die *die,
Dwarf_Off canonical_die_offset,
bool die_as_type) const
{
die_source source;
ABG_ASSERT(get_die_source(die, source));
- Dwarf_Off die_offset = dwarf_dieoffset(die);
+ Dwarf_Off die_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(die));
set_canonical_die_offset(die_offset, source,
canonical_die_offset,
///
/// @param where_offset where in the DIE stream we logically are.
void
- associate_die_to_type(Dwarf_Die *die,
+ associate_die_to_type(const Dwarf_Die *die,
type_base_sptr type,
size_t where)
{
///
/// @return true iff @p die is anonymous.
static bool
-die_is_anonymous(Dwarf_Die* die)
+die_is_anonymous(const Dwarf_Die* die)
{
Dwarf_Attribute attr;
- if (!dwarf_attr_integrate(die, DW_AT_name, &attr))
+ if (!dwarf_attr_integrate(const_cast<Dwarf_Die*>(die), DW_AT_name, &attr))
return true;
return false;
}
/// @return the string representing the value of the attribute, or an
/// empty string if no string attribute could be found.
static string
-die_string_attribute(Dwarf_Die* die, unsigned attr_name)
+die_string_attribute(const Dwarf_Die* die, unsigned attr_name)
{
if (!die)
return "";
Dwarf_Attribute attr;
- if (!dwarf_attr_integrate(die, attr_name, &attr))
+ if (!dwarf_attr_integrate(const_cast<Dwarf_Die*>(die), attr_name, &attr))
return "";
const char* str = dwarf_formstring(&attr);
/// @return true if there was an attribute of the name @p attr_name
/// and with a value that is a constant, false otherwise.
static bool
-die_unsigned_constant_attribute(Dwarf_Die* die,
+die_unsigned_constant_attribute(const Dwarf_Die* die,
unsigned attr_name,
uint64_t& cst)
{
Dwarf_Attribute attr;
Dwarf_Word result = 0;
- if (!dwarf_attr_integrate(die, attr_name, &attr)
+ if (!dwarf_attr_integrate(const_cast<Dwarf_Die*>(die), attr_name, &attr)
|| dwarf_formudata(&attr, &result))
return false;
/// @return true iff a signed constant attribute of the name @p
/// attr_name was found on the DIE @p die.
static bool
-die_signed_constant_attribute(Dwarf_Die *die,
+die_signed_constant_attribute(const Dwarf_Die *die,
unsigned attr_name,
int64_t& cst)
{
Dwarf_Attribute attr;
Dwarf_Sword result = 0;
- if (!dwarf_attr_integrate(die, attr_name, &attr)
+ if (!dwarf_attr_integrate(const_cast<Dwarf_Die*>(die), attr_name, &attr)
|| dwarf_formsdata(&attr, &result))
return false;
/// @return true iff DIE @p die has an attribute named @p attr_name
/// with a constant value.
static bool
-die_constant_attribute(Dwarf_Die *die,
+die_constant_attribute(const Dwarf_Die *die,
unsigned attr_name,
array_type_def::subrange_type::bound_value &value)
{
/// @return true iff the attribute named @p attr_name on DIE @p die
/// has the form @p attr_form.
static bool
-die_attribute_has_form(Dwarf_Die *die,
+die_attribute_has_form(const Dwarf_Die *die,
unsigned attr_name,
unsigned int attr_form)
{
Dwarf_Attribute attr;
- if (!dwarf_attr_integrate(die, attr_name, &attr))
+ if (!dwarf_attr_integrate(const_cast<Dwarf_Die*>(die), attr_name, &attr))
return false;
return dwarf_hasform(&attr, attr_form);
/// @return true iff the attribute named @p attr_name on DIE @p die is
/// signed.
static bool
-die_attribute_is_signed(Dwarf_Die* die, unsigned attr_name)
+die_attribute_is_signed(const Dwarf_Die* die, unsigned attr_name)
{
if (die_attribute_has_form(die, attr_name, DW_FORM_sdata))
return true;
/// @return true iff the attribute named @p attr_name on DIE @p die is
/// unsigned.
static bool
-die_attribute_is_unsigned(Dwarf_Die* die, unsigned attr_name)
+die_attribute_is_unsigned(const Dwarf_Die* die, unsigned attr_name)
{
if (die_attribute_has_form(die, attr_name, DW_FORM_udata))
return true;
/// @return true iff the attribute named @p attr_name of DIE @p die is
/// neither specifically signed nor unsigned.
static bool
-die_attribute_has_no_signedness(Dwarf_Die *die, unsigned attr_name)
+die_attribute_has_no_signedness(const Dwarf_Die *die, unsigned attr_name)
{
return (!die_attribute_is_unsigned(die, attr_name)
&& !die_attribute_is_signed(die, attr_name));
/// @return the mangled name if it's present in the DIE, or just an
/// empty string if it's not.
static string
-die_linkage_name(Dwarf_Die* die)
+die_linkage_name(const Dwarf_Die* die)
{
if (!die)
return "";
/// doesn't have a DW_AT_decl_file attribute, then the return value is
/// just an empty string.
static string
-die_decl_file_attribute(Dwarf_Die* die)
+die_decl_file_attribute(const Dwarf_Die* die)
{
if (!die)
return "";
- const char* str = dwarf_decl_file(die);
+ const char* str = dwarf_decl_file(const_cast<Dwarf_Die*>(die));
return str ? str : "";
}
/// @return true if the DIE @p die contains an attribute named @p
/// attr_name that is a DIE reference, false otherwise.
static bool
-die_die_attribute(Dwarf_Die* die,
+die_die_attribute(const Dwarf_Die* die,
unsigned attr_name,
Dwarf_Die& result,
bool look_thru_abstract_origin)
Dwarf_Attribute attr;
if (look_thru_abstract_origin)
{
- if (!dwarf_attr_integrate(die, attr_name, &attr))
+ if (!dwarf_attr_integrate(const_cast<Dwarf_Die*>(die), attr_name, &attr))
return false;
}
else
{
- if (!dwarf_attr(die, attr_name, &attr))
+ if (!dwarf_attr(const_cast<Dwarf_Die*>(die), attr_name, &attr))
return false;
}
bool r = dwarf_formref_die(&attr, &result);
///
/// @return the location associated with @p die.
static location
-die_location(const read_context& ctxt, Dwarf_Die* die)
+die_location(const read_context& ctxt, const Dwarf_Die* die)
{
if (!die)
return location();
///
/// @return a copy of the name of the DIE.
static string
-die_name(Dwarf_Die* die)
+die_name(const Dwarf_Die* die)
{
string name = die_string_attribute(die, DW_AT_name);
return name;
///
/// @return true if the size attribute was found.
static bool
-die_size_in_bits(Dwarf_Die* die, uint64_t& size)
+die_size_in_bits(const Dwarf_Die* die, uint64_t& size)
{
if (!die)
return false;
///
/// @return true if @p die represents a type, false otherwise.
static bool
-die_is_type(Dwarf_Die* die)
+die_is_type(const Dwarf_Die* die)
{
if (!die)
return false;
- return is_type_tag(dwarf_tag(die));
+ return is_type_tag(dwarf_tag(const_cast<Dwarf_Die*>(die)));
}
/// Test if a DIE represents a declaration.
///
/// @return true if @p die represents a decl, false otherwise.
static bool
-die_is_decl(Dwarf_Die* die)
+die_is_decl(const Dwarf_Die* die)
{
if (!die)
return false;
- return is_decl_tag(dwarf_tag(die));
+ return is_decl_tag(dwarf_tag(const_cast<Dwarf_Die*>(die)));
}
/// Test if a DIE represents a namespace.
///
/// @return true if @p die represents a namespace, false otherwise.
static bool
-die_is_namespace(Dwarf_Die* die)
+die_is_namespace(const Dwarf_Die* die)
{
if (!die)
return false;
- return (dwarf_tag(die) == DW_TAG_namespace);
+ return (dwarf_tag(const_cast<Dwarf_Die*>(die)) == DW_TAG_namespace);
}
/// Test if a DIE has tag DW_TAG_unspecified_type.
///
/// @return true iff @p die represents a pointer type.
static bool
-die_is_pointer_type(Dwarf_Die* die)
+die_is_pointer_type(const Dwarf_Die* die)
{
if (!die)
return false;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
if (tag == DW_TAG_pointer_type)
return true;
/// @return true iff @p is for a pointer, reference or qualified type
/// to anonymous class or struct.
static bool
-pointer_or_qual_die_of_anonymous_class_type(Dwarf_Die* die)
+pointer_or_qual_die_of_anonymous_class_type(const Dwarf_Die* die)
{
if (!die_is_pointer_or_reference_type(die)
&& !die_is_qualified_type(die))
///
/// @return true iff @p die represents a reference type.
static bool
-die_is_reference_type(Dwarf_Die* die)
+die_is_reference_type(const Dwarf_Die* die)
{
if (!die)
return false;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
if (tag == DW_TAG_reference_type || tag == DW_TAG_rvalue_reference_type)
return true;
///
/// @return true iff @p die represents an array type.
static bool
-die_is_array_type(Dwarf_Die* die)
+die_is_array_type(const Dwarf_Die* die)
{
if (!die)
return false;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
if (tag == DW_TAG_array_type)
return true;
///
/// @return true iff @p die represents a pointer or reference type.
static bool
-die_is_pointer_or_reference_type(Dwarf_Die* die)
+die_is_pointer_or_reference_type(const Dwarf_Die* die)
{return (die_is_pointer_type(die)
|| die_is_reference_type(die)
|| die_is_array_type(die));}
/// @return true iff @p die represents a pointer, a reference or a
/// typedef type.
static bool
-die_is_pointer_reference_or_typedef_type(Dwarf_Die* die)
+die_is_pointer_reference_or_typedef_type(const Dwarf_Die* die)
{return (die_is_pointer_or_reference_type(die)
- || dwarf_tag(die) == DW_TAG_typedef);}
+ || dwarf_tag(const_cast<Dwarf_Die*>(die)) == DW_TAG_typedef);}
/// Test if a DIE represents a class type.
///
///
/// @return true iff @p die is for a qualified type.
static bool
-die_is_qualified_type(Dwarf_Die* die)
+die_is_qualified_type(const Dwarf_Die* die)
{
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
if (tag == DW_TAG_const_type
|| tag == DW_TAG_volatile_type
|| tag == DW_TAG_restrict_type)
/// case, the parameter @p object_pointer is set to the DIE of that
/// object pointer.
static bool
-die_has_object_pointer(Dwarf_Die* die, Dwarf_Die& object_pointer)
+die_has_object_pointer(const Dwarf_Die* die, Dwarf_Die& object_pointer)
{
if (!die)
return false;
/// die.
static bool
die_is_at_class_scope(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
size_t where_offset,
Dwarf_Die& class_scope_die)
{
///
/// @return true iff the function could peel @p die.
static bool
-die_peel_pointer_and_typedef(Dwarf_Die *die, Dwarf_Die& peeled_die)
+die_peel_pointer_and_typedef(const Dwarf_Die *die, Dwarf_Die& peeled_die)
{
if (!die)
return false;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
if (tag == DW_TAG_pointer_type
|| tag == DW_TAG_reference_type
/// @return true iff @p die is a DIE for a method type.
static bool
die_function_type_is_method_type(const read_context& ctxt,
- Dwarf_Die *die,
+ const Dwarf_Die *die,
size_t where_offset,
Dwarf_Die& object_pointer_die,
Dwarf_Die& class_die,
if (!die)
return false;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
ABG_ASSERT(tag == DW_TAG_subroutine_type || tag == DW_TAG_subprogram);
bool has_object_pointer = false;
///
/// @return true if the virtual-ness could be determined.
static bool
-die_virtuality(Dwarf_Die* die, virtuality& virt)
+die_virtuality(const Dwarf_Die* die, virtuality& virt)
{
if (!die)
return false;
/// @return bool if the DIE represents a virtual base or function,
/// false othersise.
static bool
-die_is_virtual(Dwarf_Die* die)
+die_is_virtual(const Dwarf_Die* die)
{
virtuality v;
if (!die_virtuality(die, v))
/// any case, if this function returns true, then the parameter @p
/// result is set to the result of the comparison.
static bool
-compare_dies_string_attribute_value(Dwarf_Die *l, Dwarf_Die *r,
+compare_dies_string_attribute_value(const Dwarf_Die *l, const Dwarf_Die *r,
unsigned attr_name,
bool &result)
{
Dwarf_Attribute l_attr, r_attr;
- if (!dwarf_attr_integrate(l, attr_name, &l_attr)
- || !dwarf_attr_integrate(r, attr_name, &r_attr))
+ if (!dwarf_attr_integrate(const_cast<Dwarf_Die*>(l), attr_name, &l_attr)
+ || !dwarf_attr_integrate(const_cast<Dwarf_Die*>(r), attr_name, &r_attr))
return false;
ABG_ASSERT(l_attr.form == DW_FORM_strp
/// @return true iff the file paths of the DIEs of the two types are
/// equal.
static bool
-compare_dies_cu_decl_file(Dwarf_Die* l, Dwarf_Die *r, bool &result)
+compare_dies_cu_decl_file(const Dwarf_Die* l, const Dwarf_Die *r, bool &result)
{
Dwarf_Die l_cu, r_cu;
- if (!dwarf_diecu(l, &l_cu, 0, 0)
- ||!dwarf_diecu(r, &r_cu, 0, 0))
+ if (!dwarf_diecu(const_cast<Dwarf_Die*>(l), &l_cu, 0, 0)
+ ||!dwarf_diecu(const_cast<Dwarf_Die*>(r), &r_cu, 0, 0))
return false;
bool compared =
/// value. In that case the expr and expr_len arguments are set to
/// the resulting dwarf exprssion.
static bool
-die_location_expr(Dwarf_Die* die,
+die_location_expr(const Dwarf_Die* die,
unsigned attr_name,
Dwarf_Op** expr,
uint64_t* expr_len)
return false;
Dwarf_Attribute attr;
- if (!dwarf_attr_integrate(die, attr_name, &attr))
+ if (!dwarf_attr_integrate(const_cast<Dwarf_Die*>(die), attr_name, &attr))
return false;
size_t len = 0;
///@param offset the resulting constant offset, in bits. This
///argument is set iff the function returns true.
static bool
-die_member_offset(const read_context& ctxt, Dwarf_Die* die, int64_t& offset)
+die_member_offset(const read_context& ctxt,
+ const Dwarf_Die* die,
+ int64_t& offset)
{
Dwarf_Op* expr = NULL;
uint64_t expr_len = 0;
/// @return a string representing the base of the internal anonymous
/// name.
static string
-get_internal_anonynous_die_base_name(Dwarf_Die *die)
+get_internal_anonynous_die_base_name(const Dwarf_Die *die)
{
ABG_ASSERT(die_is_type(die));
ABG_ASSERT(die_string_attribute(die, DW_AT_name) == "");
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
string type_name;
if (tag == DW_TAG_class_type || tag == DW_TAG_structure_type)
type_name = "__anonymous_struct__";
/// @return a copy of the qualified name of the type.
static string
die_qualified_type_name(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
size_t where_offset)
{
if (!die)
return "";
- int tag = dwarf_tag (die);
+ int tag = dwarf_tag (const_cast<Dwarf_Die*>(die));
if (tag == DW_TAG_compile_unit
|| tag == DW_TAG_partial_unit
|| tag == DW_TAG_type_unit)
/// @return a copy of the computed name.
static string
die_qualified_decl_name(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
size_t where_offset)
{
if (!die || !die_is_decl(die))
string repr;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
switch (tag)
{
case DW_TAG_namespace:
///
/// @return a copy of the computed name.
static string
-die_qualified_name(const read_context& ctxt, Dwarf_Die* die, size_t where)
+die_qualified_name(const read_context& ctxt, const Dwarf_Die* die, size_t where)
{
if (die_is_type(die))
return die_qualified_type_name(ctxt, die, where);
///
/// @return true if the qualified name of the DIE is empty.
static bool
-die_qualified_type_name_empty(const read_context& ctxt, Dwarf_Die* die,
+die_qualified_type_name_empty(const read_context& ctxt,
+ const Dwarf_Die* die,
size_t where, string &qualified_name)
{
if (!die)
return true;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
string qname;
if (tag == DW_TAG_typedef
/// member function, then this is set to true.
static void
die_return_and_parm_names_from_fn_type_die(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
size_t where_offset,
bool pretty_print,
string &return_type_name,
return_type_name.clear();
}
- if (dwarf_child(die, &child) == 0)
+ if (dwarf_child(const_cast<Dwarf_Die*>(die), &child) == 0)
do
{
int child_tag = dwarf_tag(&child);
/// @return a copy of the computed function signature string.
static string
die_function_signature(const read_context& ctxt,
- Dwarf_Die *fn_die,
+ const Dwarf_Die *fn_die,
size_t where_offset)
{
///
/// @return the resulting pretty representation.
static string
-die_pretty_print_type(read_context& ctxt, Dwarf_Die* die, size_t where_offset)
+die_pretty_print_type(read_context& ctxt,
+ const Dwarf_Die* die,
+ size_t where_offset)
{
- if (!die || (!die_is_type(die) && dwarf_tag(die) != DW_TAG_subprogram))
+ if (!die
+ || (!die_is_type(die)
+ && dwarf_tag(const_cast<Dwarf_Die*>(die)) != DW_TAG_subprogram))
return "";
string repr;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
switch (tag)
{
case DW_TAG_string_type:
///
/// @return the resulting pretty representation.
static string
-die_pretty_print_decl(read_context& ctxt, Dwarf_Die* die, size_t where_offset)
+die_pretty_print_decl(read_context& ctxt,
+ const Dwarf_Die* die,
+ size_t where_offset)
{
if (!die || !die_is_decl(die))
return "";
string repr;
- int tag = dwarf_tag(die);
+ int tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
switch (tag)
{
case DW_TAG_namespace:
///
/// @return a copy of the pretty printed artifact.
static string
-die_pretty_print(read_context& ctxt, Dwarf_Die* die, size_t where_offset)
+die_pretty_print(read_context& ctxt, const Dwarf_Die* die, size_t where_offset)
{
if (die_is_type(die))
return die_pretty_print_type(ctxt, die, where_offset);
///
/// @return true iff @p l equals @p r.
static bool
-compare_as_decl_dies(Dwarf_Die *l, Dwarf_Die *r)
+compare_as_decl_dies(const Dwarf_Die *l, const Dwarf_Die *r)
{
ABG_ASSERT(l && r);
- if (dwarf_tag(l) != dwarf_tag(r))
+ if (dwarf_tag(const_cast<Dwarf_Die*>(l))
+ != dwarf_tag(const_cast<Dwarf_Die*>(r)))
return false;
bool result = false;
///
/// @return true iff @p l equals @p r.
static bool
-compare_as_type_dies(Dwarf_Die *l, Dwarf_Die *r)
+compare_as_type_dies(const Dwarf_Die *l, const Dwarf_Die *r)
{
ABG_ASSERT(l && r);
ABG_ASSERT(die_is_type(l));
ABG_ASSERT(die_is_type(r));
- if (dwarf_tag(l) == DW_TAG_string_type
- && dwarf_tag(r) == DW_TAG_string_type
- && dwarf_dieoffset(l) != dwarf_dieoffset(r))
+ if (dwarf_tag(const_cast<Dwarf_Die*>(l)) == DW_TAG_string_type
+ && dwarf_tag(const_cast<Dwarf_Die*>(r)) == DW_TAG_string_type
+ && (dwarf_dieoffset(const_cast<Dwarf_Die*>(l))
+ != dwarf_dieoffset(const_cast<Dwarf_Die*>(r))))
// For now, we cannot compare DW_TAG_string_type because of its
// string_length attribute that is a location descriptor that is
// not necessarily a constant. So it's super hard to evaluate it
///
/// @return true iff @p l equals @p r.
static bool
-compare_dies(const read_context& ctxt, Dwarf_Die *l, Dwarf_Die *r,
+compare_dies(const read_context& ctxt,
+ const Dwarf_Die *l, const Dwarf_Die *r,
istring_set_type& aggregates_being_compared,
bool update_canonical_dies_on_the_fly)
{
ABG_ASSERT(l);
ABG_ASSERT(r);
- int l_tag = dwarf_tag(l), r_tag = dwarf_tag(r);
+ int l_tag = dwarf_tag(const_cast<Dwarf_Die*>(l)),
+ r_tag = dwarf_tag(const_cast<Dwarf_Die*>(r));
if (l_tag != r_tag)
return false;
- Dwarf_Off l_offset = dwarf_dieoffset(l), r_offset = dwarf_dieoffset(r);
+ Dwarf_Off l_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(l)),
+ r_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(r));
Dwarf_Off l_canonical_die_offset = 0, r_canonical_die_offset = 0;
die_source l_die_source, r_die_source;
ABG_ASSERT(ctxt.get_die_source(l, l_die_source));
Dwarf_Die l_enumtor, r_enumtor;
bool found_l_enumtor, found_r_enumtor;
- for (found_l_enumtor = dwarf_child(l, &l_enumtor) == 0,
- found_r_enumtor = dwarf_child(r, &r_enumtor) == 0;
+ for (found_l_enumtor = dwarf_child(const_cast<Dwarf_Die*>(l),
+ &l_enumtor) == 0,
+ found_r_enumtor = dwarf_child(const_cast<Dwarf_Die*>(r),
+ &r_enumtor) == 0;
found_l_enumtor && found_r_enumtor;
found_l_enumtor = dwarf_siblingof(&l_enumtor, &l_enumtor) == 0,
found_r_enumtor = dwarf_siblingof(&r_enumtor, &r_enumtor) == 0)
Dwarf_Die l_member, r_member;
bool found_l_member, found_r_member;
- for (found_l_member = dwarf_child(l, &l_member) == 0,
- found_r_member = dwarf_child(r, &r_member) == 0;
+ for (found_l_member = dwarf_child(const_cast<Dwarf_Die*>(l),
+ &l_member) == 0,
+ found_r_member = dwarf_child(const_cast<Dwarf_Die*>(r),
+ &r_member) == 0;
found_l_member && found_r_member;
found_l_member = dwarf_siblingof(&l_member, &l_member) == 0,
found_r_member = dwarf_siblingof(&r_member, &r_member) == 0)
{
Dwarf_Die l_child, r_child;
bool found_l_child, found_r_child;
- for (found_l_child = dwarf_child(l, &l_child) == 0,
- found_r_child = dwarf_child(r, &r_child) == 0;
+ for (found_l_child = dwarf_child(const_cast<Dwarf_Die*>(l),
+ &l_child) == 0,
+ found_r_child = dwarf_child(const_cast<Dwarf_Die*>(r),
+ &r_child) == 0;
found_l_child && found_r_child;
found_l_child = dwarf_siblingof(&l_child, &l_child) == 0,
found_r_child = dwarf_siblingof(&r_child, &r_child) == 0)
{
Dwarf_Die l_child, r_child;
bool found_l_child, found_r_child;
- for (found_l_child = dwarf_child(l, &l_child) == 0,
- found_r_child = dwarf_child(r, &r_child) == 0;
+ for (found_l_child = dwarf_child(const_cast<Dwarf_Die*>(l),
+ &l_child) == 0,
+ found_r_child = dwarf_child(const_cast<Dwarf_Die*>(r),
+ &r_child) == 0;
found_l_child && found_r_child;
found_l_child = dwarf_siblingof(&l_child,
&l_child) == 0,
/// @return true iff @p l equals @p r.
static bool
compare_dies(const read_context& ctxt,
- Dwarf_Die *l, Dwarf_Die *r,
+ const Dwarf_Die *l,
+ const Dwarf_Die *r,
bool update_canonical_dies_on_the_fly)
{
istring_set_type aggregates_being_compared;
/// otherwise.
static bool
get_parent_die(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
Dwarf_Die& parent_die,
size_t where_offset)
{
ABG_ASSERT(ctxt.get_die_source(die, source));
const offset_offset_map_type& m = ctxt.die_parent_map(source);
- offset_offset_map_type::const_iterator i = m.find(dwarf_dieoffset(die));
+ offset_offset_map_type::const_iterator i =
+ m.find(dwarf_dieoffset(const_cast<Dwarf_Die*>(die)));
if (i == m.end())
return false;
/// scope DIE iff the function returns true.
static bool
get_scope_die(const read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
size_t where_offset,
Dwarf_Die& scope_die)
{
if (is_c_language(ctxt.cur_transl_unit()->get_language()))
{
- ABG_ASSERT(dwarf_tag(die) != DW_TAG_member);
- return dwarf_diecu(die, &scope_die, 0, 0);
+ ABG_ASSERT(dwarf_tag(const_cast<Dwarf_Die*>(die)) != DW_TAG_member);
+ return dwarf_diecu(const_cast<Dwarf_Die*>(die), &scope_die, 0, 0);
}
Dwarf_Die logical_parent_die;
/// array_type_def::subrange_type, or nil if no type could be built.
static array_type_def::subrange_sptr
build_subrange_type(read_context& ctxt,
- Dwarf_Die* die,
+ const Dwarf_Die* die,
size_t where_offset,
bool associate_type_to_die)
{
die_source source;
ABG_ASSERT(ctxt.get_die_source(die, source));
- unsigned tag = dwarf_tag(die);
+ unsigned tag = dwarf_tag(const_cast<Dwarf_Die*>(die));
if (tag != DW_TAG_subrange_type)
return result;
/// e.g, DW_TAG_partial_unit that can be included in several places in
/// the DIE tree.
static void
-build_subranges_from_array_type_die(read_context& ctxt,
- Dwarf_Die* die,
+build_subranges_from_array_type_die(read_context& ctxt,
+ const Dwarf_Die* die,
array_type_def::subranges_type& subranges,
- size_t where_offset,
- bool associate_type_to_die)
+ size_t where_offset,
+ bool associate_type_to_die)
{
Dwarf_Die child;
- if (dwarf_child(die, &child) == 0)
+ if (dwarf_child(const_cast<Dwarf_Die*>(die), &child) == 0)
{
do
{