This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[dwarflint] asserts with check_debug_info


Hi Petr,

check_debug_info can trigger an assert, which isn't a really nice way to
report an unexpected form for an attribute in the abbrev. The issue is
that read_die_chain () calls dwarf_version::form_class () a couple of
times without first validating the form via form_allowed (). Which is
understandable because this is a low level check and form_allowed () for
higher level checks to use. But... form_class will assert () if the form
isn't allowed/expected. This produces hard the debug "error reports"
when an attribute is encountered in an unforeseen form.

I fixed it by letting form_class () return max_dw_class, like
ambiguous_class () does. max_dw_class is already used as sentinel in
read_die_chain () in case the attribute is unknown. This lets things
work out for the low level check_debug_info check and then makes the
higher-level checks complain about the unexpected form instead.

Does this (patch attached) look like a sane solution to you?

Thanks,

Mark
diff --git a/dwarflint/dwarf_version.cc b/dwarflint/dwarf_version.cc
index 8a34ef0..28404a2 100644
--- a/dwarflint/dwarf_version.cc
+++ b/dwarflint/dwarf_version.cc
@@ -87,7 +87,6 @@ dwarf_version::form_class (form const *form, attribute const *attribute) const
   assert (attribute != NULL);
   dw_class_set result = form->classes ();
   result &= attribute->classes ();
-  assert (result.any ());
   if (result.count () > 1)
     {
       dw_class ret = this->ambiguous_class (form, attribute, result);
@@ -95,8 +94,10 @@ dwarf_version::form_class (form const *form, attribute const *attribute) const
       assert (result[ret]);
       return ret;
     }
-  else
+  else if (result.count () == 1)
     return static_cast<dw_class> (ffsl (result.to_ulong ()) - 1);
+  else
+    return max_dw_class;
 }
 
 form_width_t

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]