type_base* get_canonical_type(const char* name, unsigned index);
#ifdef WITH_DEBUG_SELF_COMPARISON
- unordered_map<string, uintptr_t>&
+ const unordered_map<string, uintptr_t>&
get_type_id_canonical_type_map() const;
+ unordered_map<string, uintptr_t>&
+ get_type_id_canonical_type_map();
+
+ const unordered_map<uintptr_t, string>&
+ get_pointer_type_id_map() const;
+
unordered_map<uintptr_t, string>&
get_pointer_type_id_map();
string
- get_type_id_from_pointer(uintptr_t ptr);
+ get_type_id_from_pointer(uintptr_t ptr) const;
string
- get_type_id_from_type(const type_base *ptr);
+ get_type_id_from_type(const type_base *ptr) const;
uintptr_t
- get_canonical_type_from_type_id(const char*);
+ get_canonical_type_from_type_id(const char*) const;
#endif
friend class class_or_union;
{
to_remove.insert(i);
t->priv_->set_propagated_canonical_type_confirmed(true);
+#ifdef WITH_DEBUG_SELF_COMPARISON
+ check_abixml_canonical_type_propagation_during_self_comp(t);
+#endif
}
}
env.priv_->remove_from_types_with_non_confirmed_propagated_ct(t);
env.priv_->set_is_not_recursive(t);
t->priv_->set_propagated_canonical_type_confirmed(true);
+#ifdef WITH_DEBUG_SELF_COMPARISON
+ check_abixml_canonical_type_propagation_during_self_comp(t);
+#endif
}
/// Mark all the types that have been the target of canonical type
|| t->priv_->depends_on_recursive_type());
t->priv_->set_does_not_depend_on_recursive_type();
t->priv_->set_propagated_canonical_type_confirmed(true);
+#ifdef WITH_DEBUG_SELF_COMPARISON
+ check_abixml_canonical_type_propagation_during_self_comp(t);
+#endif
}
types_with_non_confirmed_propagated_ct_.clear();
}
}
#ifdef WITH_DEBUG_SELF_COMPARISON
+
+ const unordered_map<string, uintptr_t>&
+ get_type_id_canonical_type_map() const
+ {return type_id_canonical_type_map_;}
+
+ unordered_map<string, uintptr_t>&
+ get_type_id_canonical_type_map()
+ {return type_id_canonical_type_map_;}
+
+ const unordered_map<uintptr_t, string>&
+ get_pointer_type_id_map() const
+ {return pointer_type_id_map_;}
+
+ unordered_map<uintptr_t, string>&
+ get_pointer_type_id_map()
+ {return pointer_type_id_map_;}
+
+ string
+ get_type_id_from_pointer(uintptr_t ptr) const
+ {
+ auto it = get_pointer_type_id_map().find(ptr);
+ if (it != get_pointer_type_id_map().end())
+ return it->second;
+ return "";
+ }
+
+ string
+ get_type_id_from_type(const type_base *t) const
+ {return get_type_id_from_pointer(reinterpret_cast<uintptr_t>(t));}
+
+ uintptr_t
+ get_canonical_type_from_type_id(const char* type_id) const
+ {
+ if (!type_id)
+ return 0;
+ auto it = get_type_id_canonical_type_map().find(type_id);
+ if (it != get_type_id_canonical_type_map().end())
+ return it->second;
+ return 0;
+ }
+
/// When debugging self comparison, verify that a type T
/// de-serialized from abixml has the same canonical type as the
/// initial type built from DWARF that was serialized into T in the
///
/// @param t deserialized type (from abixml) to consider.
///
- /// @param c the canonical type @p t should have.
+ /// @param c the canonical type that @p t has, as computed freshly
+ /// from the abixml file.
///
- /// @return true iff @p c is the canonical type that @p t should
- /// have.
+ /// @return true iff @p c has the same value as the canonical type
+ /// that @p t had before being serialized into abixml.
bool
check_canonical_type_from_abixml_during_self_comp(const type_base* t,
const type_base* c)
return false;
}
+ /// When debugging self comparison, verify that a type T
+ /// de-serialized from abixml has the same canonical type as the
+ /// initial type built from DWARF that was serialized into T in the
+ /// first place.
+ ///
+ /// @param t deserialized type (from abixml) to consider.
+ ///
+ /// @return true iff @p c is the canonical type that @p t should
+ /// have.
+ bool
+ check_abixml_canonical_type_propagation_during_self_comp(const type_base* t)
+ {
+ if (t->get_corpus()
+ && t->get_corpus()->get_origin() == ir::corpus::NATIVE_XML_ORIGIN)
+ {
+ type_base* c = t->get_naked_canonical_type();
+ if (c && !check_canonical_type_from_abixml_during_self_comp(t, c))
+ {
+ string repr = t->get_pretty_representation(true, true);
+ string type_id = get_type_id_from_type(t);
+ std::cerr << "error: canonical type propagation error for '"
+ << repr
+ << "' of type-id: '"
+ << type_id
+ << "' / type: @"
+ << std::hex
+ << t
+ << "/ canon: @"
+ << c
+ << ", should have had canonical type: "
+ << std::hex
+ << get_canonical_type_from_type_id(type_id.c_str())
+ << "\n";
+ return false;
+ }
+ }
+ return true;
+ }
+
/// When debugging self comparison, verify that a type T
/// de-serialized from abixml has the same canonical type as the
/// initial type built from DWARF that was serialized into T in the
// shall now confirm the propagation for all those types.
env.priv_->confirm_ct_propagation();
+#ifdef WITH_DEBUG_SELF_COMPARISON
+ if (value == false && env.priv_->right_type_comp_operands_.empty())
+ {
+ for (const auto i : env.priv_->types_with_non_confirmed_propagated_ct_)
+ {
+ type_base *t = reinterpret_cast<type_base*>(i);
+ env.priv_->check_abixml_canonical_type_propagation_during_self_comp(t);
+ }
+ }
+#endif
+
ABG_RETURN(value);
}
///
/// @return the set of abixml type-id and the pointer value of the
/// (canonical) type it's associated to.
-unordered_map<string, uintptr_t>&
+const unordered_map<string, uintptr_t>&
environment::get_type_id_canonical_type_map() const
-{return priv_->type_id_canonical_type_map_;}
+{return priv_->get_type_id_canonical_type_map();}
+
+/// Get the set of abixml type-id and the pointer value of the
+/// (canonical) type it's associated to.
+///
+/// This is useful for debugging purposes, especially in the context
+/// of the use of the command:
+/// 'abidw --debug-abidiff <binary>'.
+///
+/// @return the set of abixml type-id and the pointer value of the
+/// (canonical) type it's associated to.
+unordered_map<string, uintptr_t>&
+environment::get_type_id_canonical_type_map()
+{return priv_->get_type_id_canonical_type_map();}
+
+/// Getter of the map that associates the values of type pointers to
+/// their type-id strings.
+///
+/// Note that this map is populated at abixml reading time, (by
+/// build_type()) when a given XML element representing a type is
+/// read into a corresponding abigail::ir::type_base.
+///
+/// This is used only for the purpose of debugging the
+/// self-comparison process. That is, when invoking "abidw
+/// --debug-abidiff".
+///
+/// @return the map that associates the values of type pointers to
+/// their type-id strings.
+const unordered_map<uintptr_t, string>&
+environment::get_pointer_type_id_map() const
+{return priv_->get_pointer_type_id_map();}
/// Getter of the map that associates the values of type pointers to
/// their type-id strings.
/// their type-id strings.
unordered_map<uintptr_t, string>&
environment::get_pointer_type_id_map()
-{return priv_->pointer_type_id_map_;}
+{return priv_->get_pointer_type_id_map();}
/// Getter of the type-id that corresponds to the value of a pointer
/// to abigail::ir::type_base that was created from the abixml reader.
///
/// @return the type-id strings that corresponds
string
-environment::get_type_id_from_pointer(uintptr_t ptr)
-{
- auto it = get_pointer_type_id_map().find(ptr);
- if (it != get_pointer_type_id_map().end())
- return it->second;
- return "";
-}
+environment::get_type_id_from_pointer(uintptr_t ptr) const
+{return priv_->get_type_id_from_pointer(ptr);}
/// Getter of the type-id that corresponds to the value of an
/// abigail::ir::type_base that was created from the abixml reader.
///
/// @return the type-id strings that corresponds
string
-environment::get_type_id_from_type(const type_base *t)
-{return get_type_id_from_pointer(reinterpret_cast<uintptr_t>(t));}
+environment::get_type_id_from_type(const type_base *t) const
+{return priv_->get_type_id_from_type(t);}
/// Getter of the canonical type of the artifact designated by a
/// type-id.
/// @return the set of abixml type-id and the pointer value of the
/// (canonical) type it's associated to.
uintptr_t
-environment::get_canonical_type_from_type_id(const char* type_id)
-{
- if (!type_id)
- return 0;
- auto it = get_type_id_canonical_type_map().find(type_id);
- if (it != get_type_id_canonical_type_map().end())
- return it->second;
- return 0;
-}
+environment::get_canonical_type_from_type_id(const char* type_id) const
+{return priv_->get_canonical_type_from_type_id(type_id);}
#endif
+
// </environment stuff>
// <type_or_decl_base stuff>
if (!env.priv_->
check_canonical_type_from_abixml_during_self_comp(t,
result))
- // The canonical type of the type re-read from abixml
- // type doesn't match the canonical type that was
- // initially serialized down.
- std::cerr << "error: wrong canonical type for '"
- << repr
- << "' / type: @"
- << std::hex
- << t.get()
- << "/ canon: @"
- << result.get()
- << std::endl;
+ {
+ // The canonical type of the type re-read from abixml
+ // type doesn't match the canonical type that was
+ // initially serialized down.
+ uintptr_t should_have_canonical_type = 0;
+ string type_id = env.get_type_id_from_type(t.get());
+ if (type_id.empty())
+ type_id = "type-id-<not-found>";
+ else
+ should_have_canonical_type =
+ env.get_canonical_type_from_type_id(type_id.c_str());
+ std::cerr << "error: wrong canonical type for '"
+ << repr
+ << "' / type: @"
+ << std::hex
+ << t.get()
+ << "/ canon: @"
+ << result.get()
+ << ", type-id: '"
+ << type_id
+ << "'. Should have had canonical type: "
+ << std::hex
+ << should_have_canonical_type
+ << std::endl;
+ }
}
else //!result
{
<< repr
<< "' from second corpus"
<< ", ptr: " << std::hex << t.get()
- << "type-id: " << type_id
+ << " type-id: " << type_id
<< std::endl;
}
}
}
-#endif
+#endif //WITH_DEBUG_SELF_COMPARISON
if (!result)
{
}
else if (j->second
!= reinterpret_cast<uintptr_t>(t->get_canonical_type().get()))
- // So thecanonical type of 't' (at abixml de-serialization
+ // So the canonical type of 't' (at abixml de-serialization
// time) is different from the canonical type that led to
// the serialization of 't' at abixml serialization time.
// Report this because it needs further debugging.
std::cerr << "error: canonical type for type '"
- << t->get_pretty_representation(/*internal=*/false,
- /*qualified=*/false)
+ << t->get_pretty_representation(/*internal=*/true,
+ /*qualified=*/true)
<< "' of type-id '" << type_id
<< "' changed from '" << std::hex
<< j->second << "' to '" << std::hex
// <c>0x25f9ba8</c>
// </type>
- string id = ctxt.get_id_for_type (const_cast<type_base*>(type));
- o << " <type>\n"
- << " <id>" << id << "</id>\n"
- << " <c>"
- << std::hex
- << (type->get_canonical_type()
- ? reinterpret_cast<uintptr_t>(type->get_canonical_type().get())
- : 0xdeadbabe)
- << "</c>\n"
- << " </type>\n";
+ type_base* canonical = type->get_naked_canonical_type();
+ string id ;
+ if (canonical)
+ {
+ id = ctxt.get_id_for_type (const_cast<type_base*>(type));
+
+ o << " <type>\n"
+ << " <id>" << id << "</id>\n"
+ << " <c>"
+ << std::hex
+ << reinterpret_cast<uintptr_t>(canonical)
+ << "</c>\n"
+ << " </type>\n";
+ }
}
/// Serialize the map that is stored at
-Functions changes summary: 0 Removed, 3 Changed (7 filtered out), 13 Added functions
+Functions changes summary: 0 Removed, 3 Changed (12 filtered out), 13 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
Function symbols changes summary: 0 Removed, 0 Added function symbol not referenced by debug info
Variable symbols changes summary: 0 Removed, 6 Added variable symbols not referenced by debug info