Merge branch 'master' of ssh://vamos.informatik.uni-erlangen.de:29418/fail
This commit is contained in:
@ -11,4 +11,6 @@ message DatabaseCampaignMessage {
|
||||
required int32 injection_instr = 4 [(sql_ignore) = true];
|
||||
optional int32 injection_instr_absolute = 5 [(sql_ignore) = true];
|
||||
required int32 data_address = 6 [(sql_ignore) = true];
|
||||
required string variant = 7 [(sql_ignore) = true];
|
||||
required string benchmark = 8 [(sql_ignore) = true];
|
||||
}
|
||||
@ -63,8 +63,7 @@ bool DatabaseCampaign::run() {
|
||||
pruner = "basic";
|
||||
|
||||
db = Database::cmdline_connect();
|
||||
variant_id = db->get_variant_id(variant, benchmark);
|
||||
log_send << "Variant to use " << variant << "/" << benchmark << " (ID: " << variant_id << ")" << std::endl;
|
||||
log_send << "Variant to use " << variant << "/" << benchmark << std::endl;
|
||||
fspmethod_id = db->get_fspmethod_id(pruner);
|
||||
log_send << "Pruner to use " << pruner << " (ID: " << fspmethod_id << ")" << std::endl;
|
||||
|
||||
@ -80,56 +79,17 @@ bool DatabaseCampaign::run() {
|
||||
boost::thread collect_thread(&DatabaseCampaign::collect_result_thread, this);
|
||||
#endif
|
||||
|
||||
/* Gather all unfinished jobs */
|
||||
int experiment_count;
|
||||
std::string sql_select = "SELECT pilot_id, g.fspmethod_id, g.variant_id, p.injection_instr, p.injection_instr_absolute, g.data_address";
|
||||
std::stringstream ss;
|
||||
ss << " FROM fspgroup g"
|
||||
<< " INNER JOIN fsppilot p ON p.id = g.pilot_id "
|
||||
<< " WHERE p.known_outcome = 0 "
|
||||
<< " AND g.fspmethod_id = " << fspmethod_id
|
||||
<< " AND g.variant_id = " << variant_id
|
||||
<< " AND (SELECT COUNT(*) FROM " + db_connect.result_table() + " as r WHERE r.pilot_id = g.pilot_id) < 8"
|
||||
<< " ORDER BY p.injection_instr";
|
||||
std::string sql_body = ss.str();
|
||||
|
||||
/* Get the number of unfinished experiments */
|
||||
MYSQL_RES *count = db->query(("SELECT COUNT(*) " + sql_body).c_str(), true);
|
||||
MYSQL_ROW row = mysql_fetch_row(count);
|
||||
experiment_count = atoi(row[0]);
|
||||
|
||||
|
||||
MYSQL_RES *pilots = db->query_stream ((sql_select + sql_body).c_str());
|
||||
|
||||
log_send << "Found " << experiment_count << " unfinished experiments in database." << std::endl;
|
||||
|
||||
sent_pilots = 0;
|
||||
while ((row = mysql_fetch_row(pilots)) != 0) {
|
||||
unsigned pilot_id = atoi(row[0]);
|
||||
unsigned injection_instr = atoi(row[3]);
|
||||
unsigned data_address = atoi(row[5]);
|
||||
|
||||
DatabaseCampaignMessage pilot;
|
||||
pilot.set_pilot_id(pilot_id);
|
||||
pilot.set_fspmethod_id(fspmethod_id);
|
||||
pilot.set_variant_id(variant_id);
|
||||
pilot.set_injection_instr(injection_instr);
|
||||
if (row[4]) {
|
||||
unsigned injection_instr_absolute = atoi(row[4]);
|
||||
pilot.set_injection_instr_absolute(injection_instr_absolute);
|
||||
}
|
||||
pilot.set_data_address(data_address);
|
||||
|
||||
this->cb_send_pilot(pilot);
|
||||
|
||||
if ((++sent_pilots) % 1000 == 0) {
|
||||
log_send << "pushed " << sent_pilots << " pilots into the queue" << std::endl;
|
||||
std::vector<Database::Variant> variants = db->get_variants(variant, benchmark);
|
||||
for (std::vector<Database::Variant>::const_iterator it = variants.begin();
|
||||
it != variants.end(); ++it) {
|
||||
if(!run_variant(*it)) {
|
||||
log_send << "run_variant failed for " << it->variant << "/" << it->benchmark <<std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
log_send << "pushed " << sent_pilots << " pilots into the queue" << std::endl;
|
||||
log_send << "wait for the clients to complete" << std::endl;
|
||||
|
||||
campaignmanager.noMoreParameters();
|
||||
|
||||
#ifndef __puma
|
||||
@ -149,3 +109,58 @@ void DatabaseCampaign::collect_result_thread() {
|
||||
}
|
||||
}
|
||||
|
||||
bool DatabaseCampaign::run_variant(Database::Variant variant) {
|
||||
/* Gather all unfinished jobs */
|
||||
int experiment_count;
|
||||
std::string sql_select = "SELECT pilot_id, g.fspmethod_id, g.variant_id, p.injection_instr, p.injection_instr_absolute, g.data_address ";
|
||||
std::stringstream ss;
|
||||
ss << " FROM fspgroup g"
|
||||
<< " INNER JOIN fsppilot p ON p.id = g.pilot_id "
|
||||
<< " WHERE p.known_outcome = 0 "
|
||||
<< " AND g.fspmethod_id = " << fspmethod_id
|
||||
<< " AND g.variant_id = " << variant.id
|
||||
<< " AND (SELECT COUNT(*) FROM " + db_connect.result_table() + " as r WHERE r.pilot_id = g.pilot_id)"
|
||||
<< " < " << expected_number_of_results(variant.variant, variant.benchmark)
|
||||
<< " ORDER BY p.injection_instr";
|
||||
std::string sql_body = ss.str();
|
||||
|
||||
/* Get the number of unfinished experiments */
|
||||
MYSQL_RES *count = db->query(("SELECT COUNT(*) " + sql_body).c_str(), true);
|
||||
MYSQL_ROW row = mysql_fetch_row(count);
|
||||
experiment_count = atoi(row[0]);
|
||||
|
||||
|
||||
MYSQL_RES *pilots = db->query_stream ((sql_select + sql_body).c_str());
|
||||
|
||||
log_send << "Found " << experiment_count << " unfinished experiments in database. ("
|
||||
<< variant.variant << "/" << variant.benchmark << ")" << std::endl;
|
||||
|
||||
sent_pilots = 0;
|
||||
while ((row = mysql_fetch_row(pilots)) != 0) {
|
||||
unsigned pilot_id = atoi(row[0]);
|
||||
unsigned injection_instr = atoi(row[3]);
|
||||
unsigned data_address = atoi(row[5]);
|
||||
|
||||
|
||||
DatabaseCampaignMessage pilot;
|
||||
pilot.set_pilot_id(pilot_id);
|
||||
pilot.set_fspmethod_id(fspmethod_id);
|
||||
pilot.set_variant_id(variant.id);
|
||||
pilot.set_injection_instr(injection_instr);
|
||||
pilot.set_variant(variant.variant);
|
||||
pilot.set_benchmark(variant.benchmark);
|
||||
if (row[4]) {
|
||||
unsigned injection_instr_absolute = atoi(row[4]);
|
||||
pilot.set_injection_instr_absolute(injection_instr_absolute);
|
||||
}
|
||||
pilot.set_data_address(data_address);
|
||||
|
||||
this->cb_send_pilot(pilot);
|
||||
|
||||
if ((++sent_pilots) % 1000 == 0) {
|
||||
log_send << "pushed " << sent_pilots << " pilots into the queue" << std::endl;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@ class DatabaseCampaign : public Campaign {
|
||||
Database *db; // !< The database connection object
|
||||
DatabaseProtobufAdapter db_connect;
|
||||
|
||||
int variant_id; // !< Which variant do we work on (from CMDLINE)
|
||||
int fspmethod_id; // !< Which fspmethod should be put out to the clients
|
||||
|
||||
void collect_result_thread();
|
||||
@ -41,6 +40,20 @@ public:
|
||||
*/
|
||||
virtual bool run();
|
||||
|
||||
/**
|
||||
* Is called by run() for every variant, returned by the variant
|
||||
* filter (SQL LIKE).
|
||||
* @return \c true if the campaign was successful, \c false otherwise
|
||||
*/
|
||||
virtual bool run_variant(fail::Database::Variant);
|
||||
|
||||
/**
|
||||
* How many results have to are expected from each fsppilot. If
|
||||
* there are less result rows, the pilot will be again sent to the clients
|
||||
* @return \c exptected number of results
|
||||
*/
|
||||
virtual int expected_number_of_results(std::string variant, std::string benchmark) { return 8;}
|
||||
|
||||
/**
|
||||
* Callback function that can be used to add command line options
|
||||
* to the campaign
|
||||
|
||||
@ -74,36 +74,56 @@ my_ulonglong Database::affected_rows()
|
||||
}
|
||||
|
||||
|
||||
int Database::get_variant_id(const std::string &variant, const std::string &benchmark)
|
||||
{
|
||||
std::vector<Database::Variant> Database::get_variants(const std::string &variant, const std::string &benchmark) {
|
||||
std::vector<Variant> result;
|
||||
|
||||
if (!query("CREATE TABLE IF NOT EXISTS variant ("
|
||||
" id int(11) NOT NULL AUTO_INCREMENT,"
|
||||
" variant varchar(255) NOT NULL,"
|
||||
" benchmark varchar(255) NOT NULL,"
|
||||
" PRIMARY KEY (id),"
|
||||
"UNIQUE KEY variant (variant,benchmark))")) {
|
||||
return 0;
|
||||
"UNIQUE KEY variant (variant,benchmark)) ENGINE=MyISAM")) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int variant_id;
|
||||
std::stringstream ss;
|
||||
// FIXME SQL injection possible
|
||||
ss << "SELECT id FROM variant WHERE variant LIKE '" << variant << "' AND benchmark LIKE '" << benchmark << "'";
|
||||
ss << "SELECT id, variant, benchmark FROM variant WHERE variant LIKE '" << variant << "' AND benchmark LIKE '" << benchmark << "'";
|
||||
MYSQL_RES *variant_id_res = query(ss.str().c_str(), true);
|
||||
|
||||
if (!variant_id_res) {
|
||||
return 0;
|
||||
return result;
|
||||
} else if (mysql_num_rows(variant_id_res)) {
|
||||
MYSQL_ROW row = mysql_fetch_row(variant_id_res);
|
||||
variant_id = atoi(row[0]);
|
||||
} else {
|
||||
ss.str("");
|
||||
for (unsigned int i = 0; i < mysql_num_rows(variant_id_res); ++i) {
|
||||
MYSQL_ROW row = mysql_fetch_row(variant_id_res);
|
||||
Variant var;
|
||||
var.id = atoi(row[0]);
|
||||
var.variant = std::string(row[1]);
|
||||
var.benchmark = std::string(row[2]);
|
||||
result.push_back(var);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int Database::get_variant_id(const std::string &variant, const std::string &benchmark)
|
||||
{
|
||||
std::vector<Variant> variants = get_variants(variant, benchmark);
|
||||
if (variants.size() == 0) {
|
||||
// Insert a new variant
|
||||
std::stringstream ss;
|
||||
ss << "INSERT INTO variant (variant, benchmark) VALUES ('" << variant << "', '" << benchmark << "')";
|
||||
if (!query(ss.str().c_str())) {
|
||||
return 0;
|
||||
}
|
||||
variant_id = mysql_insert_id(handle);
|
||||
return mysql_insert_id(handle);
|
||||
} else if (variants.size() == 1) {
|
||||
return variants[0].id;
|
||||
} else {
|
||||
LOG << "Variant identifier " << variant << "/" << benchmark << " is ambigious!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
return variant_id;
|
||||
}
|
||||
|
||||
int Database::get_fspmethod_id(const std::string &method)
|
||||
@ -111,7 +131,7 @@ int Database::get_fspmethod_id(const std::string &method)
|
||||
if (!query("CREATE TABLE IF NOT EXISTS fspmethod ("
|
||||
" id int(11) NOT NULL AUTO_INCREMENT,"
|
||||
" method varchar(255) NOT NULL,"
|
||||
" PRIMARY KEY (id), UNIQUE KEY method (method))")) {
|
||||
" PRIMARY KEY (id), UNIQUE KEY method (method)) ENGINE=MyISAM")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include <boost/thread.hpp>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <mysql/mysql.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -31,6 +32,12 @@ namespace fail {
|
||||
Database(const std::string &username, const std::string &host, const std::string &database);
|
||||
~Database() { mysql_close(handle); }
|
||||
|
||||
struct Variant {
|
||||
int id;
|
||||
std::string variant;
|
||||
std::string benchmark;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the variant id for a specific variant/benchmark pair,
|
||||
* if it isn't defined in the database (variant table), it is
|
||||
@ -38,6 +45,13 @@ namespace fail {
|
||||
*/
|
||||
int get_variant_id(const std::string &variant, const std::string &benchmark);
|
||||
|
||||
/**
|
||||
* Get all variants that fit the given patterns (will be
|
||||
* queried with SQL LIKE).
|
||||
*/
|
||||
std::vector<Variant> get_variants(const std::string &variant, const std::string &benchmark);
|
||||
|
||||
|
||||
/**
|
||||
* Get the fault space pruning method id for a specific
|
||||
* pruning method, if it isn't defined in the database
|
||||
|
||||
@ -48,6 +48,8 @@ void ElfReader::setup(const char* path) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_filename = std::string(path);
|
||||
|
||||
// Evaluate headers
|
||||
Elf32_Ehdr ehdr;
|
||||
Elf32_Shdr sec_hdr;
|
||||
|
||||
@ -75,7 +75,6 @@ namespace fail {
|
||||
*/
|
||||
|
||||
class ElfReader {
|
||||
|
||||
public:
|
||||
typedef ElfSymbol entry_t;
|
||||
typedef std::vector<entry_t> container_t;
|
||||
@ -153,9 +152,11 @@ namespace fail {
|
||||
container_t::const_iterator sec_begin() { return m_sectiontable.begin(); }
|
||||
container_t::const_iterator sec_end() { return m_sectiontable.end(); }
|
||||
|
||||
const std::string & getFilename() { return m_filename; }
|
||||
|
||||
private:
|
||||
Logger m_log;
|
||||
std::string m_filename;
|
||||
|
||||
void setup(const char*);
|
||||
int process_symboltable(int sect_num, FILE* fp);
|
||||
|
||||
@ -95,7 +95,7 @@ void LLVMDisassembler::disassemble()
|
||||
// This symbol has the same address as the next symbol. Skip it.
|
||||
continue;
|
||||
|
||||
for (Index = Start; Index < End; Index += Size) {
|
||||
for (Index = Start; Index <= End; Index += Size) {
|
||||
MCInst Inst;
|
||||
|
||||
if (disas->getInstruction(Inst, Size, memoryObject, Index,
|
||||
|
||||
@ -265,7 +265,7 @@ bool EcosKernelTestCampaign::run()
|
||||
<< " AND p.fspmethod_id = " << fspmethod_id << " "
|
||||
<< " AND (" << sql_variants << ") ";
|
||||
#elif 1
|
||||
if (!db->query("CREATE TEMPORARY TABLE done_pilots (id INT UNSIGNED NOT NULL PRIMARY KEY)")) return false;
|
||||
if (!db->query("CREATE TEMPORARY TABLE done_pilots (id INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=MyISAM")) return false;
|
||||
ss << "INSERT INTO done_pilots SELECT pilot_id FROM " << m_result_table << " GROUP BY pilot_id HAVING SUM(bit_width) = 8";
|
||||
if (!db->query(ss.str().c_str())) return false;
|
||||
unsigned finished_jobs = db->affected_rows();
|
||||
|
||||
Reference in New Issue
Block a user