Code coverage updates (#50)

* code coverage updates

- python support
- refactored source

* remove code_coverage::operator+ and operator+=

* impl/coverage.hpp
This commit is contained in:
Jonathan R. Madsen
2022-05-08 01:40:56 -05:00
committed by GitHub
parent 1f66e23fdd
commit 134b33320d
9 changed files with 611 additions and 183 deletions
+2 -2
View File
@@ -90,7 +90,7 @@ function_signature::get(bool _all, bool _save) const
else if(!m_info_end && !_rc1.empty())
ss << " [" << _rc1 << "]";
else
errprintf(1, "loop line info is empty!");
errprintf(3, "line info for %s is empty!\n", m_name.c_str());
}
if((_all || use_file_info) && m_file.length() > 0) ss << " [" << m_file;
if((_all || use_line_info) && m_row.first > 0) ss << ":" << m_row.first;
@@ -130,7 +130,7 @@ function_signature::get_coverage(bool _basic_block) const
else if(!m_info_end && !_rc1.empty())
ss << " [" << _rc1 << "]";
else
errprintf(1, "loop line info is empty!");
errprintf(3, "line info for %s is empty!\n", m_name.c_str());
}
else
{
+31 -3
View File
@@ -121,7 +121,36 @@ module_function::should_instrument() const
bool
module_function::should_coverage_instrument() const
{
return should_instrument(true);
// hard constraints
if(!is_instrumentable()) return false;
if(!can_instrument_entry()) return false;
if(is_module_constrained()) return false;
if(is_routine_constrained()) return false;
// should be before user selection
constexpr int absolute_min_instructions = 2;
if(num_instructions < absolute_min_instructions)
{
messages.emplace_back(
2, "Skipping", "function",
TIMEMORY_JOIN("-", "less-than", absolute_min_instructions, "instructions"));
return false;
}
// user selection
if(is_user_excluded()) return false;
if(is_overlapping_constrained()) return false;
if(is_entry_trap_constrained()) return false;
// user selection
if(!file_restrict.empty() || !func_restrict.empty()) return !is_user_restricted();
if(is_user_included()) return true;
if(is_address_range_constrained()) return false;
if(is_num_instructions_constrained()) return false;
return true;
}
bool
@@ -150,7 +179,7 @@ module_function::should_instrument(bool coverage) const
// should be applied before dynamic-callsite check
if(is_overlapping_constrained()) return false;
if(is_entry_trap_constrained()) return false;
if(is_exit_trap_constrained()) return false;
if(!coverage && is_exit_trap_constrained()) return false;
// needs to be applied before address range and number of instruction constraints
if(is_dynamic_callsite_forced()) return true;
@@ -737,7 +766,6 @@ module_function::register_coverage(address_space_t* _addr_space,
"no-constraint");
}
}
verbprintf(0, "Basic-block code coverage is not available yet\n");
break;
}
case CODECOV_NONE: break;