[03/16] dwarf-reader,ir: Make logging a property of the middle end
Commit Message
Hello,
Add a "do-log" property to the abigail::ir::environment::priv. That
way, we can log finer grain time stamps during type canonicalization.
This is useful for debugging.
* src/abg-dwarf-reader.cc (reader::read_debug_info_into_corpus):
Set the do_log property on the environment from the do_log
property of the reader.
* src/abg-ir-priv.h (environment::priv::do_log_): New data member.
(environment::priv::priv): Initialize it.
(environment::priv::do_log): Define new accessor method.
(canonicalize_types): Add logging.
* src/abg-ir.cc (canonicalize): Add logging to time the
canonicalization of each type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
src/abg-dwarf-reader.cc | 2 ++
src/abg-ir-priv.h | 21 ++++++++++++++++++---
src/abg-ir.cc | 16 ++++++++++++++++
3 files changed, 36 insertions(+), 3 deletions(-)
@@ -2154,6 +2154,8 @@ public:
env().set_self_comparison_debug_input(corpus());
#endif
+ env().priv_->do_log(do_log());
+
// Walk all the DIEs of the debug info to build a DIE -> parent map
// useful for get_die_parent() to work.
{
@@ -494,6 +494,7 @@ struct environment::priv
bool decl_only_class_equals_definition_;
bool use_enum_binary_only_equality_;
bool allow_type_comparison_results_caching_;
+ bool do_log_;
optional<bool> analyze_exported_interfaces_only_;
#ifdef WITH_DEBUG_SELF_COMPARISON
bool self_comparison_debug_on_;
@@ -520,7 +521,8 @@ struct environment::priv
do_on_the_fly_canonicalization_(true),
decl_only_class_equals_definition_(false),
use_enum_binary_only_equality_(true),
- allow_type_comparison_results_caching_(false)
+ allow_type_comparison_results_caching_(false),
+ do_log_(false)
#ifdef WITH_DEBUG_SELF_COMPARISON
,
self_comparison_debug_on_(false)
@@ -553,6 +555,14 @@ struct environment::priv
allow_type_comparison_results_caching() const
{return allow_type_comparison_results_caching_;}
+ void
+ do_log(bool f)
+ {do_log_ = f;}
+
+ bool
+ do_log() const
+ {return do_log_;}
+
/// Cache the result of comparing two sub-types.
///
/// @param first the first sub-type that has been compared. Its
@@ -1321,8 +1331,13 @@ canonicalize_types(const input_iterator& begin,
return;
// First, let's compute the canonical type of this type.
- for (auto t = begin; t != end; ++t)
- canonicalize(deref(t));
+ for (auto t = begin, i = 0; t != end; ++t, ++i)
+ {
+ if (deref(t)->get_environment().priv_->do_log())
+ std::cerr << "#" << std::dec << i << " ";
+
+ canonicalize(deref(t));
+ }
#ifdef WITH_DEBUG_CT_PROPAGATION
// Then now, make sure that all types -- which propagated canonical
@@ -15039,7 +15039,23 @@ canonicalize(type_base_sptr t)
if (t->get_canonical_type())
return t->get_canonical_type();
+ if (t->get_environment().priv_->do_log())
+ std::cerr << "Canonicalization of type '"
+ << t->get_pretty_representation(true, true)
+ << "/@#" << std::hex << t.get() << ": ";
+
+ tools_utils::timer tmr;
+
+ if (t->get_environment().priv_->do_log())
+ tmr.start();
type_base_sptr canonical = type_base::get_canonical_type_for(t);
+
+ if (t->get_environment().priv_->do_log())
+ tmr.stop();
+
+ if (t->get_environment().priv_->do_log())
+ std::cerr << tmr << "\n";
+
maybe_adjust_canonical_type(canonical, t);
t->priv_->canonical_type = canonical;