tools/prune-trace: various improvements
- Variants/benchmarks can now be selected with wildcards
(--variant/--benchmark), and can be excluded from pruning
(--variant-exclude/--benchmark-exclude).
- The database clearing step can be skipped with --no-delete to
avoid deadlocks with concurrent DB accesses.
- Internals:
* injection_instr / injection_instr_absolute moves from
fspgroup to fsppilot. fsppilot now contains all information we
need for running FI experiments.
TODO: generic campaign needs to be modified, too.
* Force MySQL to use an efficient join order (STRAIGHT_JOIN).
Change-Id: I6241ea2de9da1a1e709fae6374df4fc06ef262a0
This commit is contained in:
@ -7,50 +7,60 @@ static fail::Logger LOG ("BasicPruner");
|
||||
bool BasicPruner::prune_all() {
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "INSERT INTO fsppilot (known_outcome, variant_id, instr1, instr2, data_address, fspmethod_id) "
|
||||
"SELECT 0, variant_id, instr1, instr2, data_address, " << m_method_id << " "
|
||||
/* When we are in basic-left mode we use the left boundary of the
|
||||
equivalence interval. Since the current database scheme has no
|
||||
instr1_absolute, we set this to NULL in the basic-left mode. */
|
||||
// FIXME "basic-left mode" doesn't make any sense; injections at instr1 and
|
||||
// at instr2 are completely equivalent.
|
||||
std::string injection_instr = this->use_instr1 ? "instr1" : "instr2";
|
||||
std::string injection_instr_absolute = this->use_instr1 ? "NULL" : "instr2_absolute";
|
||||
|
||||
ss << "INSERT INTO fsppilot (known_outcome, variant_id, instr2, injection_instr, injection_instr_absolute, data_address, fspmethod_id) "
|
||||
"SELECT 0, variant_id, instr2, " << injection_instr << ", " << injection_instr_absolute << ", "
|
||||
" data_address, " << m_method_id << " "
|
||||
"FROM trace "
|
||||
"WHERE variant_id = " << m_variant_id << " AND accesstype = 'R'";
|
||||
"WHERE variant_id IN (" << m_variant_id_query << ") AND accesstype = 'R'";
|
||||
if (!db->query(ss.str().c_str())) return false;
|
||||
ss.str("");
|
||||
|
||||
int rows = db->affected_rows();
|
||||
// single entry for known outcome (write access)
|
||||
ss << "INSERT INTO fsppilot (known_outcome, variant_id, instr1, instr2, data_address, fspmethod_id) "
|
||||
"SELECT 1, variant_id, instr1, instr2, data_address, " << m_method_id << " "
|
||||
"FROM trace "
|
||||
"WHERE variant_id = " << m_variant_id << " AND accesstype = 'W' "
|
||||
"LIMIT 1";
|
||||
if (!db->query(ss.str().c_str())) return false;
|
||||
ss.str("");
|
||||
rows += db->affected_rows();
|
||||
|
||||
// for each variant:
|
||||
MYSQL_RES *res = db->query(m_variant_id_query.c_str(), true);
|
||||
MYSQL_ROW row;
|
||||
while ((row = mysql_fetch_row(res))) {
|
||||
// single entry for known outcome (write access)
|
||||
ss << "INSERT INTO fsppilot (known_outcome, variant_id, instr2, injection_instr, injection_instr_absolute, data_address, fspmethod_id) "
|
||||
"SELECT 1, variant_id, instr2, " << injection_instr << ", " << injection_instr_absolute << ", "
|
||||
" data_address, " << m_method_id << " "
|
||||
"FROM trace "
|
||||
"WHERE variant_id = " << row[0] << " AND accesstype = 'W' "
|
||||
"LIMIT 1";
|
||||
if (!db->query(ss.str().c_str())) return false;
|
||||
ss.str("");
|
||||
rows += db->affected_rows();
|
||||
}
|
||||
|
||||
LOG << "created " << rows << " fsppilot entries" << std::endl;
|
||||
|
||||
/* When we are in basic-left mode we use the left boundary of the
|
||||
equivalence interval. Sine the current database scheme has no
|
||||
instr2_absolute, we set this to NULL in the basic-left mode. */
|
||||
std::string injection_instr = this->use_instr1 ? "t.instr1" : "t.instr2";
|
||||
std::string injection_instr_absolute = this->use_instr1 ? "NULL" : "t.instr2_absolute";
|
||||
|
||||
ss << "INSERT INTO fspgroup (variant_id, injection_instr, injection_instr_absolute, "
|
||||
<< " data_address, fspmethod_id, pilot_id) "
|
||||
<< "SELECT p.variant_id, " << injection_instr << ", " << injection_instr_absolute << ", p.data_address, p.fspmethod_id, p.id "
|
||||
ss << "INSERT INTO fspgroup (variant_id, instr2, data_address, fspmethod_id, pilot_id) "
|
||||
<< "SELECT STRAIGHT_JOIN p.variant_id, p.instr2, p.data_address, p.fspmethod_id, p.id "
|
||||
<< "FROM fsppilot p "
|
||||
<< " JOIN trace t ON t.variant_id = p.variant_id AND t.instr2 = p.instr2"
|
||||
<< "JOIN trace t ON t.variant_id = p.variant_id AND t.instr2 = p.instr2"
|
||||
<< " AND t.data_address = p.data_address "
|
||||
<< "WHERE known_outcome = 0 AND p.fspmethod_id = " << m_method_id << " AND p.variant_id = " << m_variant_id;
|
||||
<< "WHERE known_outcome = 0 AND p.fspmethod_id = " << m_method_id << " "
|
||||
<< "AND p.variant_id IN (" << m_variant_id_query << ")";
|
||||
|
||||
if (!db->query(ss.str().c_str())) return false;
|
||||
ss.str("");
|
||||
|
||||
rows = db->affected_rows();
|
||||
ss << "INSERT INTO fspgroup (variant_id, injection_instr, injection_instr_absolute, data_address, fspmethod_id, pilot_id) "
|
||||
"SELECT t.variant_id, "<< injection_instr << ", " << injection_instr_absolute <<", t.data_address, p.fspmethod_id, p.id "
|
||||
"FROM trace t "
|
||||
"JOIN fsppilot p "
|
||||
ss << "INSERT INTO fspgroup (variant_id, instr2, data_address, fspmethod_id, pilot_id) "
|
||||
"SELECT STRAIGHT_JOIN t.variant_id, t.instr2, t.data_address, p.fspmethod_id, p.id "
|
||||
"FROM fsppilot p "
|
||||
"JOIN trace t "
|
||||
"ON t.variant_id = p.variant_id AND p.fspmethod_id = " << m_method_id << " AND p.known_outcome = 1 "
|
||||
"WHERE t.variant_id = " << m_variant_id << " AND t.accesstype = 'W'";
|
||||
"WHERE t.variant_id IN (" << m_variant_id_query << ") AND t.accesstype = 'W'";
|
||||
if (!db->query(ss.str().c_str())) return false;
|
||||
ss.str("");
|
||||
rows += db->affected_rows();
|
||||
|
||||
Reference in New Issue
Block a user