Merge commit 'dcd2c021a5ac91d38187d397914e5f51e2fc8819'

Conflicts:
	tools/import-trace/RegisterImporter.cc

Change-Id: I4f49c976bd60badba73c15746aa03c420cb9f77b
This commit is contained in:
Horst Schirmeier
2013-09-11 14:38:55 +02:00
33 changed files with 690 additions and 174 deletions

View File

@ -0,0 +1,15 @@
// Architecture.hpp: wraps architecture definition headers
#ifndef __ARCHITECTURE_HPP__
#define __ARCHITECTURE_HPP__
#include "config/FailConfig.hpp"
#ifdef BUILD_X86
#include "x86/X86Architecture.hpp"
#endif
#ifdef BUILD_ARM
#include "arm/ARMArchitecture.hpp"
#endif
#endif

View File

@ -22,6 +22,7 @@ void CPUArchitecture::m_addRegister(Register* reg, RegisterType type)
Register* CPUArchitecture::getRegister(size_t i) const
{
assert(i < m_Registers.size() && "FATAL ERROR: Invalid index provided!");
assert(m_Registers[i]->getId() == i && "FATAL ERROR: Register index mismatch");
return m_Registers[i];
}

View File

@ -13,7 +13,7 @@ namespace fail {
/**
* \class CPUArchitecture
* This is the base class for CPU architectures that can be used to merge information and
* functionallity that every backend with the same target architecture will share. The classes
* functionality that every backend with the same target architecture will share. The classes
* directly derived from this are especially meant to be usable in campaigns, so they shouldn't
* contain any backend specific code.
*/

View File

@ -102,7 +102,7 @@ public:
*/
iterator begin() { return m_Regs.begin(); }
/**
* Returns an iterator to the end of the interal data structure.
* Returns an iterator to the end of the internal data structure.
* \code
* [1|2| ... |n]X
* ^

View File

@ -17,6 +17,10 @@ public:
~ArmArchitecture();
};
#ifdef BUILD_ARM
typedef ArmArchitecture Architecture;
#endif
/**
* \enum GPRegIndex
* Defines the general purpose (GP) register identifier for the ARM

View File

@ -18,6 +18,10 @@ public:
~X86Architecture();
};
#ifdef BUILD_X86
typedef X86Architecture Architecture;
#endif
/**
* \enum GPRegisterId
* Symbolic identifier to access the x86 general purpose register

View File

@ -8,7 +8,15 @@ static fail::Logger LOG("Database", true);
using namespace fail;
#ifndef __puma
boost::mutex Database::m_global_lock;
#endif
Database::Database(const std::string &username, const std::string &host, const std::string &database) {
#ifndef __puma
boost::lock_guard<boost::mutex> guard(m_global_lock);
#endif
handle = mysql_init(0);
last_result = 0;
mysql_options(handle, MYSQL_READ_DEFAULT_FILE, "~/.my.cnf");
@ -26,6 +34,9 @@ Database::~Database()
// flush cached INSERTs if available
insert_multiple();
#ifndef __puma
boost::lock_guard<boost::mutex> guard(m_global_lock);
#endif
mysql_close(handle);
}
@ -217,7 +228,7 @@ void Database::cmdline_setup() {
HOSTNAME = cmd.addOption("H", "hostname", Arg::Required,
"-h/--hostname \tMYSQL Hostname (default: taken from ~/.my.cnf)");
USERNAME = cmd.addOption("u", "username", Arg::Required,
"-u/--username \tMYSQL Username (default: taken from ~/.my.cnf, or your current user)");
"-u/--username \tMYSQL Username (default: taken from ~/.my.cnf, or your current user)\n");
}
Database * Database::cmdline_connect() {

View File

@ -23,6 +23,7 @@ namespace fail {
MYSQL_RES *last_result; // !< Used for mysql_result_free
#ifndef __puma
boost::mutex m_handle_lock;
static boost::mutex m_global_lock;
#endif
std::string m_insertquery;
std::vector<std::string> m_insertquery_values;

View File

@ -105,6 +105,7 @@ void LLVMDisassembler::disassemble()
instr_info.opcode = Inst.getOpcode();
instr_info.length = Size;
instr_info.address = SectionAddr + Index;
instr_info.conditional_branch = desc.isConditionalBranch();
unsigned int pos = 0;
for (MCInst::iterator it = Inst.begin(); it != Inst.end(); ++it) {

View File

@ -42,6 +42,7 @@ public:
unsigned int opcode;
unsigned int address;
unsigned char length;
bool conditional_branch;
std::vector<register_t> reg_uses;
std::vector<register_t> reg_defs;
};

View File

@ -62,6 +62,10 @@ int main(int argc, char* argv[]) {
it != instr.reg_defs.end(); ++it) {
std::cout << reg_info.getName(*it) << "(" << *it << ") ";
}
if (instr.conditional_branch) {
std::cout << "(conditional branch)";
}
std::cout << std::endl;
}
}

View File

@ -41,7 +41,7 @@ void GenericTracing::parseOptions() {
CommandLine::option_handle FULL_TRACE = cmd.addOption("", "full-trace", Arg::None, "--full-trace \tDo a full trace (more data, default: off)");
CommandLine::option_handle MEM_SYMBOL = cmd.addOption("m", "memory-symbol", Arg::Required,
"-m,--memory-symbol \tELF symbol(s) to trace accesses (without specifiying all mem read/writes are traced)");
"-m,--memory-symbol \tELF symbol(s) to trace accesses (default: all mem read/writes are traced)");
CommandLine::option_handle MEM_REGION = cmd.addOption("M", "memory-region", Arg::Required,
"-M,--memory-region \trestrict memory region which is traced"
" Possible formats: 0x<address>, 0x<address>:0x<address>, 0x<address>:<length>");

View File

@ -5,10 +5,6 @@
// includes generated headers (e.g., protobuf message definitions) that are not
// guaranteed to exist when the aspect is woven.
// FIXME: cmake does not remove these .ah files when the user configures
// another experiment (or even makes "clean"). Currently, this needs to be
// worked around by manually removing $BUILDDIR/core/experiments/*/*.ah .
// You need to provide the implementation of this function in your experiment
// directory:
void instantiate@EXPERIMENT_TYPE@();

View File

@ -1,10 +1,6 @@
#ifndef __INSTANTIATE_@EXPERIMENT_TYPE@_AH__
#define __INSTANTIATE_@EXPERIMENT_TYPE@_AH__
// FIXME: cmake does not remove these .ah files when the user configures
// another experiment (or even makes "clean"). Currently, this needs to be
// worked around by manually removing $BUILDDIR/core/experiments/*/*.ah .
// Make sure your experiment declaration is in experiment.hpp:
#include "../experiments/@EXPERIMENT_NAME@/experiment.hpp"
#include "sal/SALInst.hpp"

View File

@ -52,14 +52,14 @@ bool NanoJPEGCampaign::run()
// list: latest accesses (instr offset | bit mask)
map<GPRegisterId, std::list<std::pair<unsigned, uint64_t> > > reg_cascade;
// open up an equivalence class for all bits in all GPRs
reg_cascade[RID_EAX].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_EBX].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_ECX].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_EDX].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_ESP].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_EBP].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_ESI].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_EDI].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_CAX].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_CBX].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_CCX].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_CDX].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_CSP].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_CBP].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_CSI].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
reg_cascade[RID_CDI].push_front(std::pair<unsigned, uint64_t>(0, 0xffffffffffffffffULL));
// load trace
ifstream tracef(NANOJPEG_TRACE);
@ -145,7 +145,7 @@ bool NanoJPEGCampaign::run()
acc->second &= ~common_mask;
// new EC with experiments: acc->first -- instr, common_mask
// if (reg != RID_EBP && reg != RID_ESI && reg != RID_EDI) {
// if (reg != RID_CBP && reg != RID_CSI && reg != RID_CDI) {
count_exp += add_experiment_ec(acc->first, instr, absolute_instr, reg, common_mask);
// }
@ -189,7 +189,7 @@ bool NanoJPEGCampaign::run()
// skip empty EC (because register was read within the same instruction)?
if (acc->first <= instr) {
// new EC with known result: acc->first -- instr, common_mask
// if (reg != RID_EBP && reg != RID_ESI && reg != RID_EDI) {
// if (reg != RID_CBP && reg != RID_CSI && reg != RID_CDI) {
count_known += add_known_ec(acc->first, instr, absolute_instr, reg, common_mask);
// }
}
@ -234,7 +234,7 @@ bool NanoJPEGCampaign::run()
// skip empty EC (because register was read within the same instruction)?
if (acc->first <= instr) {
// new EC with known result: acc->first -- instr, common_mask
// if (reg != RID_EBP && reg != RID_ESI && reg != RID_EDI) {
// if (reg != RID_CBP && reg != RID_CSI && reg != RID_CDI) {
count_exp += add_experiment_ec(acc->first, instr, absolute_instr, reg, common_mask);
// }
}