/// Tests if a suppression specification can match ABI artifacts
/// coming from the binary being analyzed.
///
- /// This tests if the suppression matches the soname of and binary
- /// name of the ELF binary being analyzed.
+ /// This tests if the suppression can match the soname of and binary
+ /// name of the ELF binary being analyzed. More precisely, if there
+ /// are any soname or file name property in the suppression and if
+ /// those do *NOT* match the current binary, then the function
+ /// returns false.
///
/// @param s the suppression specification to consider.
+ ///
+ /// @return true iff either there are no soname/filename related
+ /// property on the suppression, or if none of the soname/filename
+ /// properties of the suppression match the current binary.
bool
suppression_can_match(const suppr::suppression_base& s) const
{
- if (s.priv_->matches_soname(dt_soname())
- && s.priv_->matches_binary_name(elf_path()))
- return true;
- return false;
+ if (!s.priv_->matches_soname(dt_soname()))
+ if (s.has_soname_related_property())
+ // The suppression has some SONAME related properties, but
+ // none of them match the SONAME of the current binary. So
+ // the suppression cannot match the current binary.
+ return false;
+
+ if (!s.priv_->matches_binary_name(elf_path()))
+ if (s.has_file_name_related_property())
+ // The suppression has some file_name related properties, but
+ // none of them match the file name of the current binary. So
+ // the suppression cannot match the current binary.
+ return false;
+
+ return true;
}
/// Test whether if a given function suppression matches a function
return soname_not_regex_;
}
+ /// Test if the current suppression matches a given SONAME.
+ ///
+ /// @param soname the SONAME to consider.
+ ///
+ /// @return true iff the suppression matches the SONAME denoted by
+ /// @p soname.
+ ///
+ /// Note that if the suppression contains no property that is
+ /// related to SONAMEs, the function returns false.
bool
matches_soname(const string& soname) const
{
+ bool has_regexp = false;
if (sptr_utils::regex_t_sptr regexp = get_soname_regex())
- if (regexec(regexp.get(), soname.c_str(), 0, NULL, 0) != 0)
- return false;
+ {
+ has_regexp = true;
+ if (regexec(regexp.get(), soname.c_str(), 0, NULL, 0) != 0)
+ return false;
+ }
if (sptr_utils::regex_t_sptr regexp = get_soname_not_regex())
- if (regexec(regexp.get(), soname.c_str(), 0, NULL, 0) == 0)
+ {
+ has_regexp = true;
+ if (regexec(regexp.get(), soname.c_str(), 0, NULL, 0) == 0)
+ return false;
+ }
+
+ if (!has_regexp)
return false;
return true;
}
+ /// Test if the current suppression matches the full file path to a
+ /// given binary.
+ ///
+ /// @param binary_name the full path to the binary.
+ ///
+ /// @return true iff the suppression matches the path denoted by @p
+ /// binary_name.
+ ///
+ /// Note that if the suppression contains no property that is
+ /// related to file name, the function returns false.
bool
matches_binary_name(const string& binary_name) const
{
+ bool has_regexp = false;
+
if (sptr_utils::regex_t_sptr regexp = get_file_name_regex())
- if (regexec(regexp.get(), binary_name.c_str(),
- 0, NULL, 0) != 0)
- return false;
+ {
+ has_regexp = true;
+ if (regexec(regexp.get(), binary_name.c_str(),
+ 0, NULL, 0) != 0)
+ return false;
+ }
if (sptr_utils::regex_t_sptr regexp = get_file_name_not_regex())
- if (regexec(regexp.get(), binary_name.c_str(),
- 0, NULL, 0) == 0)
- return false;
+ {
+ has_regexp = true;
+ if (regexec(regexp.get(), binary_name.c_str(),
+ 0, NULL, 0) == 0)
+ return false;
+ }
+
+ if (!has_regexp)
+ return false;
return true;
}
suppression_base::get_file_name_not_regex_str() const
{return priv_->file_name_not_regex_str_;}
+/// Test if the current suppression has a property related to file
+/// name.
+///
+/// @return true iff the current suppression has either a
+/// file_name_regex or a file_name_not_regex property.
+bool
+suppression_base::has_file_name_related_property() const
+{
+ return (!(get_file_name_regex_str().empty()
+ && get_file_name_not_regex_str().empty()));
+}
+
/// Setter of the "soname_regex_str property of the current instance
/// of @ref suppression_base.
///
suppression_base::get_soname_not_regex_str() const
{return priv_->soname_not_regex_str_;}
+/// Test if the current suppression has a property related to SONAMEs.
+///
+/// @return true iff the current suppression has either a soname_regex
+/// or a soname_not_regex property.
+bool
+suppression_base::has_soname_related_property() const
+{
+ return (!(get_soname_regex_str().empty()
+ && get_soname_not_regex_str().empty()));
+}
+
/// Check if the SONAMEs of the two binaries being compared match the
/// content of the properties "soname_regexp" and "soname_not_regexp"
/// of the current suppression specification.
string first_soname = ctxt.get_corpus_diff()->first_corpus()->get_soname(),
second_soname = ctxt.get_corpus_diff()->second_corpus()->get_soname();
+ if (!suppr.has_soname_related_property())
+ return false;
+
if (!suppr.priv_->matches_soname(first_soname)
&& !suppr.priv_->matches_soname(second_soname))
return false;
string first_binary_path = ctxt.get_corpus_diff()->first_corpus()->get_path(),
second_binary_path = ctxt.get_corpus_diff()->second_corpus()->get_path();
+ if (!suppr.has_file_name_related_property())
+ return false;
+
if (!suppr.priv_->matches_binary_name(first_binary_path)
&& !suppr.priv_->matches_binary_name(second_binary_path))
return false;
{
if (ctxt)
{
- // Check if the names of the binaries match
+ // Check if the names of the binaries match the suppression
if (!names_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_file_name_related_property())
+ return false;
- // Check if the sonames of the binaries match
+ // Check if the sonames of the binaries match the suppression
if (!sonames_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_soname_related_property())
+ return false;
}
return suppresses_type(type);
-
}
/// Test if an instance of @ref type_suppression matches a given type.
if (!(get_change_kind() & k))
return false;
- // Check if the name and soname of the binaries match
+ // Check if the name and soname of the binaries match the current
+ // suppr spec
if (ctxt)
{
- // Check if the name of the binaries match
+ // Check if the name of the binaries match the current suppr spec
if (!names_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_file_name_related_property())
+ return false;
- // Check if the soname of the binaries match
+ // Check if the soname of the binaries match the current suppr spec
if (!sonames_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_soname_related_property())
+ return false;
}
string fname = fn->get_qualified_name();
ABG_ASSERT(k & function_suppression::ADDED_FUNCTION_CHANGE_KIND
|| k & function_suppression::DELETED_FUNCTION_CHANGE_KIND);
- // Check if the name and soname of the binaries match
+ // Check if the name and soname of the binaries match the current
+ // suppr spect
if (ctxt)
{
- // Check if the name of the binaries match
+ // Check if the name of the binaries match the current
+ // suppr spect
if (!names_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_file_name_related_property())
+ return false;
- // Check if the soname of the binaries match
+ // Check if the soname of the binaries match the current
+ // suppr spect
if (!sonames_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_soname_related_property())
+ return false;
}
string sym_name = sym->get_name(), sym_version = sym->get_version().str();
// Check if the name and soname of the binaries match
if (ctxt)
{
- // Check if the name of the binaries match
+ // Check if the name of the binaries match the current
+ // suppr spec
if (!names_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_file_name_related_property())
+ return false;
- // Check if the soname of the binaries match
+ // Check if the soname of the binaries match the current suppr
+ // spec
if (!sonames_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_soname_related_property())
+ return false;
}
string var_name = var->get_qualified_name();
ABG_ASSERT(k & ADDED_VARIABLE_CHANGE_KIND
|| k & DELETED_VARIABLE_CHANGE_KIND);
- // Check if the name and soname of the binaries match
+ // Check if the name and soname of the binaries match the current
+ // suppr spec.
if (ctxt)
{
- // Check if the name of the binaries match
+ // Check if the name of the binaries match the current suppr
+ // spec
if (!names_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_file_name_related_property())
+ return false;
- // Check if the soname of the binaries match
+ // Check if the soname of the binaries match the current suppr spec
if (!sonames_of_binaries_match(*this, *ctxt))
- return false;
+ if (has_soname_related_property())
+ return false;
}
string sym_name = sym->get_name(), sym_version = sym->get_version().str();
string fname;
tools_utils::base_name(file_path, fname);
+ bool has_regexp = false;
+
if (sptr_utils::regex_t_sptr regexp =
suppression_base::priv_->get_file_name_regex())
- if (regexec(regexp.get(), fname.c_str(), 0, NULL, 0) != 0)
- return false;
+ {
+ has_regexp = true;
+ if (regexec(regexp.get(), fname.c_str(), 0, NULL, 0) != 0)
+ return false;
+ }
if (sptr_utils::regex_t_sptr regexp =
suppression_base::priv_->get_file_name_not_regex())
- if (regexec(regexp.get(), fname.c_str(), 0, NULL, 0) == 0)
- return false;
+ {
+ has_regexp = true;
+ if (regexec(regexp.get(), fname.c_str(), 0, NULL, 0) == 0)
+ return false;
+ }
+
+ if (!has_regexp)
+ return false;
return true;
}