formatting, typos, comments, details
Change-Id: Iae5f1acb653a694622e9ac2bad93efcfca588f3a
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
#ifndef __EXPERIMENT_DATA_HPP__
|
||||
#define __EXPERIMENT_DATA_HPP__
|
||||
#define __EXPERIMENT_DATA_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <google/protobuf/message.h>
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __SOCKET_COMM_HPP__
|
||||
#define __SOCKET_COMM_HPP__
|
||||
#define __SOCKET_COMM_HPP__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@ -56,7 +56,7 @@ public:
|
||||
static int timedAccept(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int timeout);
|
||||
|
||||
private:
|
||||
static char * getBuf(int sockfd, int *size);
|
||||
static char *getBuf(int sockfd, int *size);
|
||||
static ssize_t safe_write(int fd, const void *buf, size_t count);
|
||||
static ssize_t safe_read(int fd, void *buf, size_t count);
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __FAIL_CONFIG_HPP__
|
||||
#define __FAIL_CONFIG_HPP__
|
||||
#define __FAIL_CONFIG_HPP__
|
||||
|
||||
// #define / #undef the following configuration macros to enable/disable the
|
||||
// various event sources, fault injection sinks, and miscellaneous other
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __CAMPAIGN_HPP__
|
||||
#define __CAMPAIGN_HPP__
|
||||
#define __CAMPAIGN_HPP__
|
||||
|
||||
namespace fail {
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __CAMPAIGN_MANAGER_HPP__
|
||||
#define __CAMPAIGN_MANAGER_HPP__
|
||||
#define __CAMPAIGN_MANAGER_HPP__
|
||||
|
||||
#include "sal/SALInst.hpp"
|
||||
#include "comm/ExperimentData.hpp"
|
||||
|
||||
@ -29,13 +29,13 @@ bool DatabaseCampaign::run() {
|
||||
if (!cb_commandline_init()) return false;
|
||||
|
||||
CommandLine::option_handle VARIANT = cmd.addOption("v", "variant", Arg::Required,
|
||||
"-v/--variant \tVariant label (default: \"none\")");
|
||||
"-v/--variant \tVariant label (default: \"none\"; use % and _ as wildcard characters)");
|
||||
CommandLine::option_handle BENCHMARK = cmd.addOption("b", "benchmark", Arg::Required,
|
||||
"-b/--benchmark \tBenchmark label (default: \"none\")\n");
|
||||
"-b/--benchmark \tBenchmark label (default: \"none\"; use % and _ as wildcard characters)\n");
|
||||
CommandLine::option_handle PRUNER = cmd.addOption("p", "prune-method", Arg::Required,
|
||||
"-p/--prune-method \tWhich import method to use (default: basic)");
|
||||
|
||||
if(!cmd.parse()) {
|
||||
if (!cmd.parse()) {
|
||||
log_send << "Error parsing arguments." << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
@ -82,7 +82,7 @@ bool DatabaseCampaign::run() {
|
||||
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)) {
|
||||
if (!run_variant(*it)) {
|
||||
log_send << "run_variant failed for " << it->variant << "/" << it->benchmark <<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public:
|
||||
virtual bool cb_commandline_init() { return true; }
|
||||
|
||||
/**
|
||||
* Callback to the campagin to get the result message descriptor
|
||||
* Callback to the campaign to get the result message descriptor
|
||||
*/
|
||||
virtual const google::protobuf::Descriptor * cb_result_message() = 0;
|
||||
|
||||
|
||||
@ -159,7 +159,7 @@ void JobServer::run()
|
||||
// TODO: Log-level?
|
||||
#ifndef __puma
|
||||
boost::thread* th;
|
||||
while (!m_finish){
|
||||
while (!m_finish) {
|
||||
// Accept connection
|
||||
int cs = SocketComm::timedAccept(s, (struct sockaddr*)&clientaddr, &clen, 100);
|
||||
if (cs < 0) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __JOB_SERVER_H__
|
||||
#define __JOB_SERVER_H__
|
||||
#define __JOB_SERVER_H__
|
||||
|
||||
#include "Minion.hpp"
|
||||
#include "util/SynchronizedQueue.hpp"
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __MINION_HPP__
|
||||
#define __MINION_HPP__
|
||||
#define __MINION_HPP__
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __COROUTINE_MANAGER_HPP__
|
||||
#define __COROUTINE_MANAGER_HPP__
|
||||
#define __COROUTINE_MANAGER_HPP__
|
||||
|
||||
#include <map>
|
||||
#include <stack>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __EXPERIMENT_FLOW_HPP__
|
||||
#define __EXPERIMENT_FLOW_HPP__
|
||||
#define __EXPERIMENT_FLOW_HPP__
|
||||
|
||||
#include "sal/SALInst.hpp"
|
||||
|
||||
|
||||
@ -15,8 +15,10 @@ JobClient::JobClient(const std::string& server, int port)
|
||||
{
|
||||
SocketComm::init();
|
||||
m_server_ent = gethostbyname(m_server.c_str());
|
||||
|
||||
cout << "JobServer: " << m_server.c_str() << endl;
|
||||
if(m_server_ent == NULL) {
|
||||
|
||||
if (m_server_ent == NULL) {
|
||||
perror("[Client@gethostbyname()]");
|
||||
// TODO: Log-level?
|
||||
exit(1);
|
||||
@ -109,7 +111,6 @@ bool JobClient::getParam(ExperimentData& exp)
|
||||
|
||||
FailControlMessage_Command JobClient::tryToGetExperimentData(ExperimentData& exp)
|
||||
{
|
||||
|
||||
FailControlMessage ctrlmsg;
|
||||
|
||||
//Are there other jobs for the experiment
|
||||
@ -144,7 +145,7 @@ FailControlMessage_Command JobClient::tryToGetExperimentData(ExperimentData& exp
|
||||
switch (ctrlmsg.command()) {
|
||||
case FailControlMessage::WORK_FOLLOWS:
|
||||
uint32_t i;
|
||||
for (i = 0 ; i < ctrlmsg.job_size() ; i++) {
|
||||
for (i = 0; i < ctrlmsg.job_size(); i++) {
|
||||
ExperimentData* temp_exp = new ExperimentData(exp.getMessage().New());
|
||||
|
||||
if (!SocketComm::rcvMsg(m_sockfd, temp_exp->getMessage())) {
|
||||
@ -187,8 +188,6 @@ FailControlMessage_Command JobClient::tryToGetExperimentData(ExperimentData& exp
|
||||
} else {
|
||||
return ctrlmsg.command();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool JobClient::sendResult(ExperimentData& result)
|
||||
@ -198,7 +197,7 @@ bool JobClient::sendResult(ExperimentData& result)
|
||||
temp_exp->getMessage().CopyFrom(result.getMessage());
|
||||
temp_exp->setWorkloadID(result.getWorkloadID());
|
||||
|
||||
m_results.push_back( temp_exp );
|
||||
m_results.push_back(temp_exp);
|
||||
|
||||
if (m_parameters.size() != 0) {
|
||||
//If job request time is over send back all existing results
|
||||
@ -259,7 +258,7 @@ bool JobClient::sendResultsToServer()
|
||||
cout << "[Client] Sending back result [";
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < m_results.size() ; i++) {
|
||||
for (i = 0; i < m_results.size(); i++) {
|
||||
ctrlmsg.add_workloadid(m_results[i]->getWorkloadID());
|
||||
cout << std::dec << m_results[i]->getWorkloadID();
|
||||
cout << " ";
|
||||
@ -272,7 +271,7 @@ bool JobClient::sendResultsToServer()
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < ctrlmsg.job_size() ; i++) {
|
||||
for (i = 0; i < ctrlmsg.job_size(); i++) {
|
||||
if (!SocketComm::sendMsg(m_sockfd, m_results.front()->getMessage())) {
|
||||
close(m_sockfd);
|
||||
return false;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __JOB_CLIENT_H__
|
||||
#define __JOB_CLIENT_H__
|
||||
#define __JOB_CLIENT_H__
|
||||
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Architecture.hpp: wraps architecture definition headers
|
||||
#ifndef __ARCHITECTURE_HPP__
|
||||
#define __ARCHITECTURE_HPP__
|
||||
#define __ARCHITECTURE_HPP__
|
||||
|
||||
#include "config/FailConfig.hpp"
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __CPU_HPP__
|
||||
#define __CPU_HPP__
|
||||
#define __CPU_HPP__
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __CPU_STATE_HPP__
|
||||
#define __CPU_STATE_HPP__
|
||||
#define __CPU_STATE_HPP__
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __CONCRETE_CPU_HPP__
|
||||
#define __CONCRETE_CPU_HPP__
|
||||
#define __CONCRETE_CPU_HPP__
|
||||
|
||||
#if defined BUILD_BOCHS
|
||||
#include "bochs/BochsCPU.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __EVENT_HPP__
|
||||
#define __EVENT_HPP__
|
||||
#define __EVENT_HPP__
|
||||
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __LISTENER_HPP__
|
||||
#define __LISTENER_HPP__
|
||||
#define __LISTENER_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
@ -37,7 +37,7 @@ void ListenerManager::remove(BaseListener* li)
|
||||
for (index_t i = 0; i < m_BufferList.size(); ) {
|
||||
if (m_BufferList[i]->getParent() == simulator.m_Flows.getCurrent()) {
|
||||
m_BufferList[i]->onDeletion();
|
||||
if(m_BufferList[i]->getPerformanceBuffer() != NULL)
|
||||
if (m_BufferList[i]->getPerformanceBuffer() != NULL)
|
||||
m_BufferList[i]->getPerformanceBuffer()->remove(i);
|
||||
m_remove(i);
|
||||
// Inspect the element at m_BufferList[i] a 2nd time
|
||||
@ -117,7 +117,7 @@ void ListenerManager::remove(ExperimentFlow* flow)
|
||||
std::set<PerfBufferBase*> perfBufLists;
|
||||
for (bufferlist_t::iterator it = m_BufferList.begin(); it != m_BufferList.end(); it++) {
|
||||
(*it)->onDeletion(); // invoke listener handler
|
||||
if((*it)->getPerformanceBuffer() != NULL)
|
||||
if ((*it)->getPerformanceBuffer() != NULL)
|
||||
perfBufLists.insert((*it)->getPerformanceBuffer());
|
||||
(*it)->setPerformanceBuffer(NULL);
|
||||
(*it)->setLocation(INVALID_INDEX);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __LISTENER_MANAGER_HPP__
|
||||
#define __LISTENER_MANAGER_HPP__
|
||||
#define __LISTENER_MANAGER_HPP__
|
||||
|
||||
#include <cassert>
|
||||
#include <list>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __MEMORY_HPP__
|
||||
#define __MEMORY_HPP__
|
||||
#define __MEMORY_HPP__
|
||||
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
@ -6,12 +6,12 @@
|
||||
|
||||
namespace fail {
|
||||
|
||||
class MemoryInstruction {
|
||||
class MemoryInstruction {
|
||||
regdata_t address;
|
||||
regdata_t value;
|
||||
uint8_t width;
|
||||
bool writeAccess;
|
||||
public:
|
||||
public:
|
||||
MemoryInstruction(regdata_t address = ADDR_INV, regdata_t value = 0, uint8_t width = 0, bool writeAccess = false) :
|
||||
address(address), value(value), width(width), writeAccess(writeAccess) { };
|
||||
|
||||
@ -26,14 +26,14 @@ namespace fail {
|
||||
void setValue(regdata_t val) { value = val; }
|
||||
void setWidth(uint8_t w) { width = w; }
|
||||
void setWriteAccess(bool iswrite) { writeAccess = iswrite; }
|
||||
};
|
||||
};
|
||||
|
||||
class MemoryInstructionAnalyzer {
|
||||
public:
|
||||
virtual bool eval(address_t opcode, MemoryInstruction & result) = 0;
|
||||
};
|
||||
class MemoryInstructionAnalyzer {
|
||||
public:
|
||||
virtual bool eval(address_t opcode, MemoryInstruction& result) = 0;
|
||||
};
|
||||
|
||||
extern MemoryInstructionAnalyzer & meminstruction;
|
||||
extern MemoryInstructionAnalyzer& meminstruction;
|
||||
} // end of namespace fail
|
||||
|
||||
#endif // __MEMORYINSTRUCTION_HPP__
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __REGISTER_HPP__
|
||||
#define __REGISTER_HPP__
|
||||
#define __REGISTER_HPP__
|
||||
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __SAL_CONFIG_HPP__
|
||||
#define __SAL_CONFIG_HPP__
|
||||
#define __SAL_CONFIG_HPP__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __SAL_INSTANCE_HPP__
|
||||
#define __SAL_INSTANCE_HPP__
|
||||
#define __SAL_INSTANCE_HPP__
|
||||
|
||||
#include "SALConfig.hpp"
|
||||
#include "config/VariantConfig.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __SIMULATOR_CONTROLLER_HPP__
|
||||
#define __SIMULATOR_CONTROLLER_HPP__
|
||||
#define __SIMULATOR_CONTROLLER_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __ARM_ARCHITECURE_HPP__
|
||||
#define __ARM_ARCHITECURE_HPP__
|
||||
#define __ARM_ARCHITECURE_HPP__
|
||||
|
||||
#include "../CPU.hpp"
|
||||
#include "../CPUState.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __ARM_CPU_STATE_HPP__
|
||||
#define __ARM_CPU_STATE_HPP__
|
||||
#define __ARM_CPU_STATE_HPP__
|
||||
|
||||
#include "../CPU.hpp"
|
||||
#include "../CPUState.hpp"
|
||||
|
||||
@ -1932,7 +1932,7 @@ void arm_load_store_instr::evaluate() {
|
||||
reg = fail::simulator.getCPU(0).getRegister(Rn);
|
||||
address = fail::simulator.getCPU(0).getRegisterContent(reg);
|
||||
|
||||
if(offset_mode == 0) { // immediate
|
||||
if (offset_mode == 0) { // immediate
|
||||
offs = offset.offset;
|
||||
} else { // (scaled) register
|
||||
reg = fail::simulator.getCPU(0).getRegister(offset.reg.Rm);
|
||||
@ -1941,7 +1941,7 @@ void arm_load_store_instr::evaluate() {
|
||||
// get shift value
|
||||
uint8_t shimm = offset.reg.shift_imm;
|
||||
|
||||
switch(offset.reg.shift) {
|
||||
switch (offset.reg.shift) {
|
||||
case 0: // LSL
|
||||
offs = rm << shimm;
|
||||
break;
|
||||
@ -1969,7 +1969,7 @@ void arm_load_store_instr::evaluate() {
|
||||
}
|
||||
|
||||
// Apply the offset to the address register
|
||||
if(index_mode == 1) { // pre indexed
|
||||
if (index_mode == 1) { // pre indexed
|
||||
// the calculated address was already written back into Rn
|
||||
} else if (index_mode == 2) { // post indexed
|
||||
// the address got the offset after the mem access
|
||||
|
||||
@ -4,31 +4,31 @@
|
||||
using namespace std;
|
||||
|
||||
namespace fail {
|
||||
static ArmMemoryInstructionAnalyzer anal;
|
||||
MemoryInstructionAnalyzer & meminstruction = anal;
|
||||
static ArmMemoryInstructionAnalyzer anal;
|
||||
MemoryInstructionAnalyzer& meminstruction = anal;
|
||||
|
||||
address_t ArmMemoryInstructionAnalyzer::findPrevious(address_t address){
|
||||
if(m_dis.hasInstructionAt(address)) {
|
||||
address_t ArmMemoryInstructionAnalyzer::findPrevious(address_t address){
|
||||
if (m_dis.hasInstructionAt(address)) {
|
||||
return address;
|
||||
} else if (m_dis.hasInstructionAt(address - 2)) {
|
||||
return address - 2;
|
||||
} else {
|
||||
return ADDR_INV;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ArmMemoryInstructionAnalyzer::evaluate(arm_instruction & inst, MemoryInstruction& result){
|
||||
void ArmMemoryInstructionAnalyzer::evaluate(arm_instruction & inst, MemoryInstruction& result){
|
||||
cout << "Memory Access: " << inst.text << " - Size: " << inst.instruction_size << " Type " << inst.type << endl;
|
||||
inst.info.load_store.evaluate();
|
||||
result.setValue(inst.info.load_store.value);
|
||||
result.setAddress(inst.info.load_store.address);
|
||||
result.setWidth(4); // TODO;
|
||||
result.setWriteAccess(inst.isStoreInstruction());
|
||||
}
|
||||
}
|
||||
|
||||
// The Cortex M3 Lauterbach is a pain in the ass, as a Memory Watchpoint does not stop
|
||||
// at the accessing instruction, but 1 or 2 instructions later.
|
||||
bool ArmMemoryInstructionAnalyzer::eval_cm3(address_t address, MemoryInstruction& result){
|
||||
// The Cortex M3 Lauterbach is a pain in the ass, as a Memory Watchpoint does not stop
|
||||
// at the accessing instruction, but 1 or 2 instructions later.
|
||||
bool ArmMemoryInstructionAnalyzer::eval_cm3(address_t address, MemoryInstruction& result){
|
||||
|
||||
arm_instruction inst;
|
||||
uint32_t opcode =0;
|
||||
@ -38,10 +38,10 @@ namespace fail {
|
||||
// OpenOCDs thumb2_opcode evaluation is not complete yet. :(
|
||||
thumb2_opcode(address, opcode, &inst);
|
||||
|
||||
if(inst.isMemoryAccess()){
|
||||
if (inst.isMemoryAccess()) {
|
||||
evaluate(inst, result);
|
||||
return true;
|
||||
}else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -54,16 +54,16 @@ namespace fail {
|
||||
// OpenOCDs thumb2_opcode evaluation is not complete yet. :(
|
||||
thumb2_opcode(address, opcode, &inst);
|
||||
|
||||
if(inst.isMemoryAccess()){
|
||||
if (inst.isMemoryAccess()) {
|
||||
evaluate(inst, result);
|
||||
return true;
|
||||
} else if(inst.isBranchInstruction()){
|
||||
} else if (inst.isBranchInstruction()) {
|
||||
// The memory access took place within the function previously branched
|
||||
int regop = inst.info.b_bl_bx_blx.reg_operand;
|
||||
uint32_t addr = inst.info.b_bl_bx_blx.target_address;
|
||||
//cout << " Reg:" << hex << regop << " address " << hex << addr << endl;
|
||||
// Lets look into this function
|
||||
if( regop == -1 ){
|
||||
if ( regop == -1 ) {
|
||||
// address should be set..
|
||||
const ElfSymbol & sym = m_elf.getSymbol(addr|1); // | 1 to set first bit -> thumbmode
|
||||
addr += sym.getSize(); // Go to end of function.
|
||||
@ -73,7 +73,7 @@ namespace fail {
|
||||
do { // go backwards until there is a memory instruction.
|
||||
addr = findPrevious(addr); // find previous
|
||||
thumb2_opcode(addr, m_dis.disassemble(addr).opcode, &inst);
|
||||
} while( !inst.isMemoryAccess() );
|
||||
} while ( !inst.isMemoryAccess() );
|
||||
evaluate(inst, result);
|
||||
return true;
|
||||
}
|
||||
@ -84,23 +84,23 @@ namespace fail {
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool ArmMemoryInstructionAnalyzer::eval_ca9(address_t address, MemoryInstruction& result){
|
||||
bool ArmMemoryInstructionAnalyzer::eval_ca9(address_t address, MemoryInstruction& result){
|
||||
arm_instruction inst;
|
||||
uint32_t opcode = m_dis.disassemble(address).opcode;
|
||||
arm_evaluate_opcode(address, opcode, &inst);
|
||||
if( inst.isMemoryAccess() ){
|
||||
if ( inst.isMemoryAccess() ) {
|
||||
evaluate(inst, result);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#define CORTEXM3
|
||||
|
||||
|
||||
bool ArmMemoryInstructionAnalyzer::eval(address_t address, MemoryInstruction & result){
|
||||
bool ArmMemoryInstructionAnalyzer::eval(address_t address, MemoryInstruction & result){
|
||||
#ifdef CORTEXM3
|
||||
#warning "Memory Accesses cannot be evaluated completely!"
|
||||
return eval_cm3(address, result);
|
||||
@ -110,7 +110,6 @@ namespace fail {
|
||||
#warning "Memory Accesses are not evaluated!"
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
namespace fail {
|
||||
|
||||
class ArmMemoryInstructionAnalyzer : public MemoryInstructionAnalyzer {
|
||||
class ArmMemoryInstructionAnalyzer : public MemoryInstructionAnalyzer {
|
||||
fail::ElfReader m_elf;
|
||||
fail::Disassembler m_dis;
|
||||
|
||||
@ -24,11 +24,8 @@ namespace fail {
|
||||
};
|
||||
|
||||
bool eval(address_t opcode, MemoryInstruction & result);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
} //end of namespace fail
|
||||
|
||||
|
||||
#endif // __ARMMEMORYINSTRUCITON_HPP__
|
||||
|
||||
|
||||
@ -14,17 +14,17 @@ regdata_t BochsCPU::getRegisterContent(const Register* reg) const
|
||||
return static_cast<regdata_t>(BX_CPU(id)->read_eflags());
|
||||
}
|
||||
|
||||
#ifdef SIM_SUPPORT_64
|
||||
#ifdef SIM_SUPPORT_64
|
||||
if (reg->getId() == RID_PC) // program counter?
|
||||
return static_cast<regdata_t>(BX_CPU(id)->gen_reg[BX_64BIT_REG_RIP].rrx);
|
||||
else // 64 bit general purpose registers
|
||||
return static_cast<regdata_t>(BX_CPU(id)->gen_reg[reg->getId()].rrx);
|
||||
#else // 32 bit mode
|
||||
#else // 32 bit mode
|
||||
if (reg->getId() == RID_PC)
|
||||
return static_cast<regdata_t>(BX_CPU(id)->gen_reg[BX_32BIT_REG_EIP].dword.erx);
|
||||
else // 32 bit general purpose registers
|
||||
return static_cast<regdata_t>(BX_CPU(id)->gen_reg[reg->getId()].dword.erx);
|
||||
#endif // SIM_SUPPORT_64
|
||||
#endif // SIM_SUPPORT_64
|
||||
}
|
||||
|
||||
void BochsCPU::setRegisterContent(const Register* reg, regdata_t value)
|
||||
@ -46,17 +46,17 @@ void BochsCPU::setRegisterContent(const Register* reg, regdata_t value)
|
||||
}
|
||||
|
||||
regdata_t* pData;
|
||||
#ifdef SIM_SUPPORT_64
|
||||
#ifdef SIM_SUPPORT_64
|
||||
if (reg->getId() == RID_PC) // program counter?
|
||||
pData = &(BX_CPU(id)->gen_reg[BX_64BIT_REG_RIP].rrx);
|
||||
else // 64 bit general purpose registers
|
||||
pData = &(BX_CPU(id)->gen_reg[reg->getId()].rrx);
|
||||
#else // 32 bit mode
|
||||
#else // 32 bit mode
|
||||
if (reg->getId() == RID_PC)
|
||||
pData = &(BX_CPU(id)->gen_reg[BX_32BIT_REG_EIP].dword.erx);
|
||||
else // 32 bit general purpose registers
|
||||
pData = &(BX_CPU(id)->gen_reg[reg->getId()].dword.erx);
|
||||
#endif // SIM_SUPPORT_64
|
||||
#endif // SIM_SUPPORT_64
|
||||
*pData = value;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __BOCHS_CPU_HPP__
|
||||
#define __BOCHS_CPU_HPP__
|
||||
#define __BOCHS_CPU_HPP__
|
||||
|
||||
#include "../x86/X86Architecture.hpp"
|
||||
#include "../x86/X86CPUState.hpp"
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __BOCHS_CONFIG_HPP__
|
||||
#define __BOCHS_CONFIG_HPP__
|
||||
#define __BOCHS_CONFIG_HPP__
|
||||
|
||||
#include "bochs.h"
|
||||
#include "config.h"
|
||||
@ -15,9 +15,9 @@ namespace fail {
|
||||
typedef bx_address guest_address_t; //!< the guest memory address type
|
||||
typedef Bit8u* host_address_t; //!< the host memory address type
|
||||
#if BX_SUPPORT_X86_64
|
||||
typedef Bit64u register_data_t; //!< register data type (64 bit)
|
||||
typedef Bit64u register_data_t; //!< register data type (64 bit)
|
||||
#else
|
||||
typedef Bit32u register_data_t; //!< register data type (32 bit)
|
||||
typedef Bit32u register_data_t; //!< register data type (32 bit)
|
||||
#endif
|
||||
typedef int timer_t; //!< type of timer IDs
|
||||
|
||||
|
||||
@ -164,12 +164,12 @@ const std::string& BochsController::getMnemonic() const
|
||||
ConcreteCPU& BochsController::detectCPU(BX_CPU_C* pCPU) const
|
||||
{
|
||||
unsigned i = 0;
|
||||
#if BX_SUPPORT_SMP
|
||||
#if BX_SUPPORT_SMP
|
||||
for (; i < BX_SMP_PROCESSORS; i++) {
|
||||
if (BX_CPU_C[i] == pCPU) // cmp this ptr with all possible CPU objects
|
||||
break; // index "i" found! -> stop!
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return getCPU(i);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __BOCHS_CONTROLLER_HPP__
|
||||
#define __BOCHS_CONTROLLER_HPP__
|
||||
#define __BOCHS_CONTROLLER_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __BOCHS_HELPERS_HPP__
|
||||
#define __BOCHS_HELPERS_HPP__
|
||||
#define __BOCHS_HELPERS_HPP__
|
||||
|
||||
#include "cpu/cpu.h"
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __BOCHS_LISTENER_HPP__
|
||||
#define __BOCHS_LISTENER_HPP__
|
||||
#define __BOCHS_LISTENER_HPP__
|
||||
|
||||
namespace fail {
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __BOCHS_MEMORY_HPP__
|
||||
#define __BOCHS_MEMORY_HPP__
|
||||
#define __BOCHS_MEMORY_HPP__
|
||||
|
||||
#include "../Memory.hpp"
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __FAIL_BOCHS_GLOBALS_HPP__
|
||||
#define __FAIL_BOCHS_GLOBALS_HPP__
|
||||
#define __FAIL_BOCHS_GLOBALS_HPP__
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -8,9 +8,9 @@
|
||||
namespace fail {
|
||||
|
||||
#ifdef DANCEOS_RESTORE
|
||||
extern bx_bool restore_bochs_request;
|
||||
extern bx_bool save_bochs_request;
|
||||
extern std::string sr_path;
|
||||
extern bx_bool restore_bochs_request;
|
||||
extern bx_bool save_bochs_request;
|
||||
extern std::string sr_path;
|
||||
#endif
|
||||
|
||||
extern bx_bool reboot_bochs_request;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __GEM5_ARM_CPU_HPP__
|
||||
#define __GEM5_ARM_CPU_HPP__
|
||||
#define __GEM5_ARM_CPU_HPP__
|
||||
|
||||
#include "../arm/ArmArchitecture.hpp"
|
||||
#include "../arm/ArmCPUState.hpp"
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __GEM5_CONFIG_HPP__
|
||||
#define __GEM5_CONFIG_HPP__
|
||||
#define __GEM5_CONFIG_HPP__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __GEM5_CONTROLLER_HPP__
|
||||
#define __GEM5_CONTROLLER_HPP__
|
||||
#define __GEM5_CONTROLLER_HPP__
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __GEM5_MEMORY_HPP__
|
||||
#define __GEM5_MEMORY_HPP__
|
||||
#define __GEM5_MEMORY_HPP__
|
||||
|
||||
#include "../Memory.hpp"
|
||||
#include "Gem5Wrapper.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __GEM5_WRAPPER_HPP__
|
||||
#define __GEM5_WRAPPER_HPP__
|
||||
#define __GEM5_WRAPPER_HPP__
|
||||
|
||||
#include "../Register.hpp"
|
||||
#include "../SALConfig.hpp"
|
||||
|
||||
@ -10,7 +10,7 @@ ResultSet& PerfVectorBreakpoints::gather(BPEvent* pData)
|
||||
static ResultSet res;
|
||||
res.clear(); // FIXME: This should not free the memory of the underlying std::vector.
|
||||
// Search for all indices of matching listener objects:
|
||||
for(std::vector<index_t>::iterator it = m_BufList.begin(); it != m_BufList.end(); ++it) {
|
||||
for (std::vector<index_t>::iterator it = m_BufList.begin(); it != m_BufList.end(); ++it) {
|
||||
BPListener* pLi = static_cast<BPListener*>(simulator.dereference(*it));
|
||||
if (pLi->isMatching(pData)) {
|
||||
// Update trigger IPtr:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __BREAKPOINT_BUFFER_HPP__
|
||||
#define __BREAKPOINT_BUFFER_HPP__
|
||||
#define __BREAKPOINT_BUFFER_HPP__
|
||||
|
||||
#include "BufferInterface.hpp"
|
||||
|
||||
@ -100,7 +100,7 @@ public:
|
||||
// TODO: Improve this by using binary search, too!
|
||||
ResultSet res;
|
||||
// Search for all indices of matching listener objects:
|
||||
for(std::vector<index_t>::iterator it = m_BufList.begin(); it != m_BufList.end(); ++it) {
|
||||
for (std::vector<index_t>::iterator it = m_BufList.begin(); it != m_BufList.end(); ++it) {
|
||||
BPListener* pLi = static_cast<BPListener*>(simulator.dereference(*it));
|
||||
if (pLi->isMatching(pData)) {
|
||||
// Update trigger IPtr:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __BUFFER_INTERFACE_HPP__
|
||||
#define __BUFFER_INTERFACE_HPP__
|
||||
#define __BUFFER_INTERFACE_HPP__
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
@ -11,7 +11,7 @@ ResultSet& PerfVectorWatchpoints::gather(MemAccessEvent* pData)
|
||||
static ResultSet res;
|
||||
res.clear(); // FIXME: This should not free the memory of the underlying std::vector.
|
||||
// Search for all indices of matching listener objects:
|
||||
for(std::vector<index_t>::iterator it = m_BufList.begin(); it != m_BufList.end(); ++it) {
|
||||
for (std::vector<index_t>::iterator it = m_BufList.begin(); it != m_BufList.end(); ++it) {
|
||||
MemAccessListener* pmal = static_cast<MemAccessListener*>(simulator.dereference(*it));
|
||||
if (pmal->isMatching(pData)) {
|
||||
// Update trigger data:
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __WATCHPOINT_BUFFER_HPP__
|
||||
#define __WATCHPOINT_BUFFER_HPP__
|
||||
#define __WATCHPOINT_BUFFER_HPP__
|
||||
|
||||
#include "BufferInterface.hpp"
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __QEMU_CONFIG_HPP__
|
||||
#define __QEMU_CONFIG_HPP__
|
||||
#define __QEMU_CONFIG_HPP__
|
||||
|
||||
// FIXME: qemu/targphys.h defines address types (but relies on a global preprocessor macro)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __QEMU_CONTROLLER_HPP__
|
||||
#define __QEMU_CONTROLLER_HPP__
|
||||
#define __QEMU_CONTROLLER_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __QEMU_MEMORY_HPP__
|
||||
#define __QEMU_MEMORY_HPP__
|
||||
#define __QEMU_MEMORY_HPP__
|
||||
|
||||
#include "../Memory.hpp"
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __QEMU_REGISTER_HPP__
|
||||
#define __QEMU_REGISTER_HPP__
|
||||
#define __QEMU_REGISTER_HPP__
|
||||
|
||||
#include "../Register.hpp"
|
||||
|
||||
|
||||
@ -16,8 +16,8 @@ regdata_t T32ArmCPU::getRegisterContent(const Register* reg) const
|
||||
// 1000 0000 0000 0000 0000 0000 -> R63
|
||||
uint64_t mask = (1 << reg->getIndex());
|
||||
|
||||
if(mask){
|
||||
if( T32_ReadRegister(static_cast<dword>(mask & lower ), static_cast<dword>(mask >> 32), m_regbuffer) == 0 ){
|
||||
if (mask) {
|
||||
if ( T32_ReadRegister(static_cast<dword>(mask & lower ), static_cast<dword>(mask >> 32), m_regbuffer) == 0 ) {
|
||||
// No error, return value.
|
||||
return m_regbuffer[reg->getIndex()];
|
||||
} else {
|
||||
@ -34,8 +34,8 @@ void T32ArmCPU::setRegisterContent(const Register* reg, regdata_t value)
|
||||
|
||||
// set value to be set by T32:
|
||||
m_regbuffer[reg->getIndex()] = value;
|
||||
if(mask){
|
||||
if( T32_WriteRegister(static_cast<dword>(mask & lower), static_cast<dword>(mask >> 32), m_regbuffer) == 0 ){
|
||||
if (mask) {
|
||||
if ( T32_WriteRegister(static_cast<dword>(mask & lower), static_cast<dword>(mask >> 32), m_regbuffer) == 0 ) {
|
||||
// No error, return value.
|
||||
return;
|
||||
} else {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __T32_ARM_CPU_HPP__
|
||||
#define __T32_ARM_CPU_HPP__
|
||||
#define __T32_ARM_CPU_HPP__
|
||||
|
||||
#include "../arm/ArmArchitecture.hpp"
|
||||
#include "../arm/ArmCPUState.hpp"
|
||||
|
||||
@ -6,9 +6,10 @@
|
||||
#define __T32_CONSTANTS_HPP__
|
||||
namespace fail {
|
||||
|
||||
namespace T32 {
|
||||
//!< Breakpoint configuration
|
||||
struct BP {
|
||||
namespace T32 {
|
||||
|
||||
//!< Breakpoint configuration
|
||||
struct BP {
|
||||
enum {
|
||||
EXECUTION = 1<<0,
|
||||
HLL_STEP = 1<<1,
|
||||
@ -20,11 +21,11 @@ namespace fail {
|
||||
CHARLY = 1<<7,
|
||||
CLEAR = 1<<8,
|
||||
};
|
||||
}; // struct BP
|
||||
}; // struct BP
|
||||
|
||||
|
||||
//!< Memory access variants
|
||||
struct MEMACCESS {
|
||||
//!< Memory access variants
|
||||
struct MEMACCESS {
|
||||
enum {
|
||||
DATA = 0,
|
||||
PROGRAM = 1,
|
||||
@ -32,9 +33,9 @@ namespace fail {
|
||||
AP = 13,
|
||||
USR = 15,
|
||||
};
|
||||
}; // struct MEMACCESS
|
||||
}; // struct MEMACCESS
|
||||
|
||||
}; // namespace T32
|
||||
}; // namespace T32
|
||||
}; // namespace fail
|
||||
#endif // __T32_CONSTANTS_HPP__
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __T32_MEMORY_HPP__
|
||||
#define __T32_MEMORY_HPP__
|
||||
#define __T32_MEMORY_HPP__
|
||||
|
||||
#include "../Memory.hpp"
|
||||
#include <t32.h>
|
||||
|
||||
@ -8,7 +8,7 @@ X86Architecture::X86Architecture()
|
||||
{
|
||||
// -------------------------------------
|
||||
// Add the general purpose register:
|
||||
#ifdef SIM_SUPPORT_64
|
||||
#ifdef SIM_SUPPORT_64
|
||||
// -- 64 bit register --
|
||||
const std::string names[] = { "RAX", "RCX", "RDX", "RBX", "RSP", "RBP", "RSI", "RDI", "R8",
|
||||
"R9", "R10", "R11", "R12", "R13", "R14", "R15" };
|
||||
@ -17,7 +17,7 @@ X86Architecture::X86Architecture()
|
||||
pReg->setName(names[i]);
|
||||
m_addRegister(pReg, RT_GP);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
// -- 32 bit register --
|
||||
const std::string names[] = { "EAX", "ECX", "EDX", "EBX", "ESP", "EBP", "ESI", "EDI" };
|
||||
for (unsigned short i = 0; i < 8; i++) {
|
||||
@ -25,16 +25,16 @@ X86Architecture::X86Architecture()
|
||||
pReg->setName(names[i]);
|
||||
m_addRegister(pReg, RT_GP);
|
||||
}
|
||||
#endif // SIM_SUPPORT_64
|
||||
#endif // SIM_SUPPORT_64
|
||||
// -------------------------------------
|
||||
// Add the program counter (PC) register:
|
||||
#ifdef SIM_SUPPORT_64
|
||||
#ifdef SIM_SUPPORT_64
|
||||
Register* pPCReg = new Register(RID_PC, 64);
|
||||
pPCReg->setName("RIP");
|
||||
#else
|
||||
#else
|
||||
Register* pPCReg = new Register(RID_PC, 32);
|
||||
pPCReg->setName("EIP");
|
||||
#endif // SIM_SUPPORT_64
|
||||
#endif // SIM_SUPPORT_64
|
||||
m_addRegister(pPCReg, RT_IP);
|
||||
// -------------------------------------
|
||||
// Add the status register (EFLAGS):
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __X86_ARCHITECTURE_HPP__
|
||||
#define __X86_ARCHITECTURE_HPP__
|
||||
#define __X86_ARCHITECTURE_HPP__
|
||||
|
||||
#include "../CPU.hpp"
|
||||
#include "../CPUState.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __X86_CPU_STATE_HPP__
|
||||
#define __X86_CPU_STATE_HPP__
|
||||
#define __X86_CPU_STATE_HPP__
|
||||
|
||||
#include "../CPU.hpp"
|
||||
#include "../CPUState.hpp"
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
|
||||
|
||||
namespace fail {
|
||||
CommandLine CommandLine::m_instance;
|
||||
CommandLine CommandLine::m_instance;
|
||||
|
||||
void CommandLine::collect_args(argument_count &argc, argument_value &argv) {
|
||||
void CommandLine::collect_args(argument_count &argc, argument_value &argv) {
|
||||
// Filter out all command line arguments that start with -Wf,
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if (strncmp(argv[i], "-Wf,", 4) == 0) {
|
||||
@ -22,9 +22,10 @@ namespace fail {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CommandLine::option_handle CommandLine::addOption(const std::string &shortopt,
|
||||
CommandLine::option_handle CommandLine::addOption(
|
||||
const std::string &shortopt,
|
||||
const std::string &longopt,
|
||||
const option::CheckArg & check_arg,
|
||||
const std::string &help) {
|
||||
@ -35,9 +36,9 @@ namespace fail {
|
||||
check_arg, strdup(help.c_str())};
|
||||
this->options.push_back(desc);
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
||||
bool CommandLine::parse() {
|
||||
bool CommandLine::parse() {
|
||||
// Terminate the descriptor list
|
||||
option::Descriptor desc = {0, 0, 0, 0, 0, 0};
|
||||
this->options.push_back(desc);
|
||||
@ -63,7 +64,6 @@ namespace fail {
|
||||
this->options.pop_back();
|
||||
|
||||
return !m_parser->error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
@ -17,23 +17,24 @@
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
namespace fail {
|
||||
/**
|
||||
|
||||
/**
|
||||
* @class CommandLine
|
||||
* @brief Implements a command line interface, that filters the
|
||||
* simulators command line. It is a Singleton.
|
||||
*/
|
||||
class CommandLine {
|
||||
public:
|
||||
class CommandLine {
|
||||
public:
|
||||
typedef int argument_count;
|
||||
typedef char **argument_value;
|
||||
private:
|
||||
private:
|
||||
static CommandLine m_instance;
|
||||
|
||||
std::vector<const char *> argv;
|
||||
std::vector<option::Descriptor> options;
|
||||
option::Option *parsed_options, *parsed_buffer;
|
||||
option::Parser *m_parser;
|
||||
public:
|
||||
public:
|
||||
/// Handle for accessing the parsed data of an option
|
||||
typedef int option_handle;
|
||||
|
||||
@ -103,7 +104,7 @@ namespace fail {
|
||||
option::Parser *parser() {
|
||||
return m_parser;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} // end of namespace
|
||||
|
||||
|
||||
@ -6,15 +6,15 @@
|
||||
|
||||
namespace fail {
|
||||
|
||||
const std::string Demangler::DEMANGLE_FAILED = "[Demangler] Demangle failed.";
|
||||
const std::string Demangler::DEMANGLE_FAILED = "[Demangler] Demangle failed.";
|
||||
|
||||
std::string Demangler::demangle(const std::string& name){
|
||||
std::string Demangler::demangle(const std::string& name){
|
||||
const char* res = cplus_demangle(name.c_str(), 0);
|
||||
if(res != NULL){
|
||||
if (res != NULL) {
|
||||
return std::string(res);
|
||||
}else{
|
||||
} else {
|
||||
return Demangler::DEMANGLE_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
|
||||
namespace fail {
|
||||
|
||||
class Demangler {
|
||||
public:
|
||||
class Demangler {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Get the demangled symbol name of a mangled string.
|
||||
@ -17,7 +17,7 @@ namespace fail {
|
||||
|
||||
//! Inform about failed demangling.
|
||||
static const std::string DEMANGLE_FAILED;
|
||||
};
|
||||
};
|
||||
|
||||
} // end of namespace
|
||||
|
||||
|
||||
@ -13,36 +13,36 @@
|
||||
|
||||
namespace fail {
|
||||
|
||||
const std::string DISASSEMBLER::FAILED = "[Disassembler] Disassemble failed.";
|
||||
const std::string DISASSEMBLER::FAILED = "[Disassembler] Disassemble failed.";
|
||||
|
||||
Disassembler::Disassembler() : m_log("Fail*Disassembler", false){ }
|
||||
Disassembler::Disassembler() : m_log("Fail*Disassembler", false) { }
|
||||
|
||||
int Disassembler::init() {
|
||||
int Disassembler::init() {
|
||||
// try to open elf file from environment variable
|
||||
char * elfpath = getenv("FAIL_ELF_PATH");
|
||||
if(elfpath == NULL){
|
||||
if (elfpath == NULL) {
|
||||
m_log << "FAIL_ELF_PATH not set :(" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}else{
|
||||
} else {
|
||||
return init(elfpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Disassembler::init(const char* path){
|
||||
int Disassembler::init(const char* path) {
|
||||
// Disassemble ELF
|
||||
#ifndef __puma
|
||||
std::string command = std::string(ARCH_TOOL_PREFIX) + std::string("objdump -d ") + std::string(path);
|
||||
m_log << "Executing: " << command << std::endl;
|
||||
redi::ipstream objdump( command );
|
||||
std::string str;
|
||||
while(std::getline(objdump, str)){
|
||||
while (std::getline(objdump, str)) {
|
||||
evaluate(str);
|
||||
}
|
||||
|
||||
objdump.close();
|
||||
if(objdump.rdbuf()->exited()){
|
||||
if (objdump.rdbuf()->exited()) {
|
||||
int ex = objdump.rdbuf()->status();
|
||||
if(ex != 0){
|
||||
if (ex != 0) {
|
||||
m_code.clear();
|
||||
m_log << "Could not disassemble!" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
@ -51,24 +51,24 @@ namespace fail {
|
||||
m_log << "disassembled " << m_code.size() << " lines." << std::endl;
|
||||
#endif
|
||||
return m_code.size();
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& operator <<(std::ostream & os, const fail::Instruction & i) {
|
||||
std::ostream& operator <<(std::ostream & os, const fail::Instruction & i) {
|
||||
#ifndef __puma
|
||||
os << std::hex << ((int)(i.address)) << "\t" << i.opcode << "\t" << i.instruction << "\t" << i.comment;
|
||||
#endif
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
||||
void Disassembler::evaluate(const std::string& line){
|
||||
void Disassembler::evaluate(const std::string& line) {
|
||||
#ifndef __puma
|
||||
// Only read in real code lines:
|
||||
// Code lines start with a leading whitespace! (hopefully in each objdump implementation!)
|
||||
if(line.size() > 0 && isspace(line[0])){
|
||||
if (line.size() > 0 && isspace(line[0])) {
|
||||
// a line looks like: 800156c:\tdd14 \tble.n 8001598 <_ZN2hw3hal7T32Term8PutBlockEPci+0x30>
|
||||
boost::regex expr("\\s+([A-Fa-f0-9]+):\\t(.*?)\\t(.+?)(;.*)?$");
|
||||
boost::smatch res;
|
||||
if(boost::regex_search(line, res, expr)){
|
||||
if (boost::regex_search(line, res, expr)) {
|
||||
std::string address = res[1];
|
||||
std::stringstream ss;
|
||||
ss << std::hex << address;
|
||||
@ -95,18 +95,17 @@ namespace fail {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static Instruction g_InstructionNotFound;
|
||||
const Instruction & Disassembler::disassemble(address_t address) const {
|
||||
static Instruction g_InstructionNotFound;
|
||||
const Instruction & Disassembler::disassemble(address_t address) const {
|
||||
InstructionMap_t::const_iterator it = m_code.find(address);
|
||||
if(it == m_code.end()){
|
||||
if (it == m_code.end()) {
|
||||
return g_InstructionNotFound;
|
||||
}else{
|
||||
} else {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
|
||||
@ -9,29 +9,29 @@
|
||||
|
||||
namespace fail {
|
||||
|
||||
struct DISASSEMBLER {
|
||||
struct DISASSEMBLER {
|
||||
//! Inform about failed disassembly
|
||||
static const std::string FAILED;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @class Instruction
|
||||
* @brief An Instruction represents an disassembled opcode
|
||||
*/
|
||||
struct Instruction {
|
||||
struct Instruction {
|
||||
address_t address; //!< The instruction address
|
||||
regdata_t opcode; //!< The opcode itself
|
||||
std::string instruction; //!< The disassembled instruction
|
||||
std::string comment; //!< Comment (rest of line after ; )
|
||||
Instruction(address_t address = ADDR_INV, regdata_t opcode = 0, const std::string& instr = DISASSEMBLER::FAILED, const std::string& comment = "")
|
||||
: address(address), opcode(opcode), instruction(instr), comment(comment) { };
|
||||
};
|
||||
//<! This allows to print an Instruction via Logger or cout
|
||||
std::ostream& operator <<(std::ostream & os, const fail::Instruction & i);
|
||||
};
|
||||
//<! This allows to print an Instruction via Logger or cout
|
||||
std::ostream& operator <<(std::ostream & os, const fail::Instruction & i);
|
||||
|
||||
class Disassembler {
|
||||
class Disassembler {
|
||||
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@ -67,12 +67,12 @@ namespace fail {
|
||||
*/
|
||||
int init(void);
|
||||
|
||||
private:
|
||||
private:
|
||||
Logger m_log;
|
||||
typedef std::map<address_t, Instruction> InstructionMap_t;
|
||||
InstructionMap_t m_code;
|
||||
void evaluate(const std::string &);
|
||||
};
|
||||
};
|
||||
} // end of namespace
|
||||
|
||||
#endif // DISASSEMBLER_HPP
|
||||
|
||||
@ -26,17 +26,17 @@ std::ostream& operator<< (std::ostream &out, const ElfSymbol &symbol) {
|
||||
|
||||
|
||||
|
||||
ElfReader::ElfReader() : m_log("Fail*Elfinfo", false){
|
||||
ElfReader::ElfReader() : m_log("Fail*Elfinfo", false) {
|
||||
// try to open elf file from environment variable
|
||||
char * elfpath = getenv("FAIL_ELF_PATH");
|
||||
if(elfpath == NULL){
|
||||
if (elfpath == NULL) {
|
||||
m_log << "FAIL_ELF_PATH not set :(" << std::endl;
|
||||
}else{
|
||||
} else {
|
||||
setup(elfpath);
|
||||
}
|
||||
}
|
||||
|
||||
ElfReader::ElfReader(const char* path) : m_log("Fail*Elfinfo", false){
|
||||
ElfReader::ElfReader(const char* path) : m_log("Fail*Elfinfo", false) {
|
||||
setup(path);
|
||||
}
|
||||
|
||||
@ -59,15 +59,15 @@ void ElfReader::setup(const char* path) {
|
||||
num_hdrs=ehdr.e_shnum;
|
||||
m_log << "Evaluating ELF File: " << path << std::endl;
|
||||
// Parse symbol table and generate internal map
|
||||
for(i=0;i<num_hdrs;i++)
|
||||
for (i=0;i<num_hdrs;i++)
|
||||
{
|
||||
if(read_ELF_section_header(i,&sec_hdr,fp)==-1)
|
||||
if (read_ELF_section_header(i,&sec_hdr,fp)==-1)
|
||||
{
|
||||
m_log << "Wrong Section to read" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((sec_hdr.sh_type==SHT_SYMTAB)||(sec_hdr.sh_type==SHT_DYNSYM))
|
||||
if ((sec_hdr.sh_type==SHT_SYMTAB)||(sec_hdr.sh_type==SHT_DYNSYM))
|
||||
{
|
||||
process_symboltable(i,fp);
|
||||
}
|
||||
@ -78,7 +78,7 @@ void ElfReader::setup(const char* path) {
|
||||
}
|
||||
}
|
||||
// Parse section information
|
||||
if(read_ELF_section_header(ehdr.e_shstrndx,&sec_hdr,fp)==-1)
|
||||
if (read_ELF_section_header(ehdr.e_shstrndx,&sec_hdr,fp)==-1)
|
||||
{
|
||||
m_log << "Error: reading section string table sect_num = " << ehdr.e_shstrndx << std::endl;
|
||||
}
|
||||
@ -89,14 +89,14 @@ void ElfReader::setup(const char* path) {
|
||||
m_log << "Malloc failed to allocate buffer for shstrtab" << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
//seek to the offset in the file,
|
||||
// seek to the offset in the file,
|
||||
fseek(fp,(off_t)sec_hdr.sh_offset,SEEK_SET);
|
||||
fread(buff,sec_hdr.sh_size,1,fp);
|
||||
m_log << "Total number of sections: " << num_hdrs << std::endl;
|
||||
|
||||
for(i=0;i<num_hdrs;i++)
|
||||
for (i=0;i<num_hdrs;i++)
|
||||
{
|
||||
if(read_ELF_section_header(i,&sec_hdr,fp)==-1)
|
||||
if (read_ELF_section_header(i,&sec_hdr,fp)==-1)
|
||||
{
|
||||
m_log << "Wrong Section to read\n" << std::endl;
|
||||
}
|
||||
@ -105,7 +105,7 @@ void ElfReader::setup(const char* path) {
|
||||
process_section(&sec_hdr, buff);
|
||||
}
|
||||
}
|
||||
if(buff)
|
||||
if (buff)
|
||||
free(buff);
|
||||
|
||||
fclose(fp);
|
||||
@ -115,16 +115,16 @@ void ElfReader::setup(const char* path) {
|
||||
}
|
||||
|
||||
|
||||
int ElfReader::process_section(Elf32_Shdr *sect_hdr, char* sect_name_buff){
|
||||
int ElfReader::process_section(Elf32_Shdr *sect_hdr, char* sect_name_buff) {
|
||||
// Add section name, start address and size to list
|
||||
int idx=sect_hdr->sh_name;
|
||||
// m_sections_map.push_back( sect_hdr->sh_addr, sect_hdr->sh_size, sect_name_buff+idx );
|
||||
// m_sections_map.push_back( sect_hdr->sh_addr, sect_hdr->sh_size, sect_name_buff+idx );
|
||||
m_sectiontable.push_back( ElfSymbol(sect_name_buff+idx, sect_hdr->sh_addr, sect_hdr->sh_size, ElfSymbol::SECTION) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ElfReader::process_symboltable(int sect_num, FILE* fp){
|
||||
int ElfReader::process_symboltable(int sect_num, FILE* fp) {
|
||||
|
||||
Elf32_Shdr sect_hdr;
|
||||
Elf32_Sym mysym;
|
||||
@ -132,40 +132,40 @@ int ElfReader::process_symboltable(int sect_num, FILE* fp){
|
||||
int num_sym,link,i,idx;
|
||||
off_t sym_data_offset;
|
||||
int sym_data_size;
|
||||
if(read_ELF_section_header(sect_num,§_hdr,fp)==-1)
|
||||
if (read_ELF_section_header(sect_num,§_hdr,fp)==-1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
//we have to check to which strtab it is linked
|
||||
// we have to check to which strtab it is linked
|
||||
link=sect_hdr.sh_link;
|
||||
sym_data_offset=sect_hdr.sh_offset;
|
||||
sym_data_size=sect_hdr.sh_size;
|
||||
num_sym=sym_data_size/sizeof(Elf32_Sym);
|
||||
|
||||
//read the coresponding strtab
|
||||
if(read_ELF_section_header(link,§_hdr,fp)==-1)
|
||||
// read the coresponding strtab
|
||||
if (read_ELF_section_header(link,§_hdr,fp)==-1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
//get the size of strtab in file and allocate a buffer
|
||||
// get the size of strtab in file and allocate a buffer
|
||||
name_buf=(char*)malloc(sect_hdr.sh_size);
|
||||
if(!name_buf)
|
||||
if (!name_buf)
|
||||
return -1;
|
||||
//get the offset of strtab in file and seek to it
|
||||
// get the offset of strtab in file and seek to it
|
||||
fseek(fp,sect_hdr.sh_offset,SEEK_SET);
|
||||
//read all data from the section to the buffer.
|
||||
// read all data from the section to the buffer.
|
||||
fread(name_buf,sect_hdr.sh_size,1,fp);
|
||||
//so we have the namebuf now seek to symtab data
|
||||
// so we have the namebuf now seek to symtab data
|
||||
fseek(fp,sym_data_offset,SEEK_SET);
|
||||
|
||||
for(i=0;i<num_sym;i++)
|
||||
for (i=0;i<num_sym;i++)
|
||||
{
|
||||
|
||||
fread(&mysym,sizeof(Elf32_Sym),1,fp);
|
||||
idx=mysym.st_name;
|
||||
|
||||
int type = ELF32_ST_TYPE(mysym.st_info);
|
||||
if((type != STT_SECTION) && (type != STT_FILE)){
|
||||
if ((type != STT_SECTION) && (type != STT_FILE)) {
|
||||
m_symboltable.push_back( ElfSymbol(name_buf+idx, mysym.st_value, mysym.st_size, ElfSymbol::SYMBOL,
|
||||
type) );
|
||||
}
|
||||
@ -174,9 +174,9 @@ int ElfReader::process_symboltable(int sect_num, FILE* fp){
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ElfSymbol& ElfReader::getSymbol(guest_address_t address){
|
||||
for(container_t::const_iterator it = m_symboltable.begin(); it !=m_symboltable.end(); ++it){
|
||||
if(it->contains(address)){
|
||||
const ElfSymbol& ElfReader::getSymbol(guest_address_t address) {
|
||||
for (container_t::const_iterator it = m_symboltable.begin(); it !=m_symboltable.end(); ++it) {
|
||||
if (it->contains(address)) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
@ -185,22 +185,22 @@ const ElfSymbol& ElfReader::getSymbol(guest_address_t address){
|
||||
}
|
||||
|
||||
// Symbol search
|
||||
const ElfSymbol& ElfReader::getSymbol( const std::string& name ){
|
||||
const ElfSymbol& ElfReader::getSymbol( const std::string& name ) {
|
||||
container_t::const_iterator it;
|
||||
// Fist, try to find as mangled symbol
|
||||
it = std::find(m_symboltable.begin(), m_symboltable.end(), name);
|
||||
if(it != m_symboltable.end()){
|
||||
if (it != m_symboltable.end()) {
|
||||
return *it;
|
||||
}
|
||||
|
||||
// Then, try to find as demangled symbol
|
||||
std::string dname = Demangler::demangle(name);
|
||||
if(dname == Demangler::DEMANGLE_FAILED){
|
||||
if (dname == Demangler::DEMANGLE_FAILED) {
|
||||
return g_SymbolNotFound;
|
||||
}
|
||||
|
||||
it = std::find(m_symboltable.begin(), m_symboltable.end(), dname);
|
||||
if(it != m_symboltable.end()){
|
||||
if (it != m_symboltable.end()) {
|
||||
return *it;
|
||||
}
|
||||
|
||||
@ -208,18 +208,18 @@ const ElfSymbol& ElfReader::getSymbol( const std::string& name ){
|
||||
}
|
||||
|
||||
// Section search
|
||||
const ElfSymbol& ElfReader::getSection(guest_address_t address){
|
||||
for(container_t::const_iterator it = m_sectiontable.begin(); it != m_sectiontable.end(); ++it){
|
||||
if(it->contains(address)){
|
||||
const ElfSymbol& ElfReader::getSection(guest_address_t address) {
|
||||
for (container_t::const_iterator it = m_sectiontable.begin(); it != m_sectiontable.end(); ++it) {
|
||||
if (it->contains(address)) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
return g_SymbolNotFound;
|
||||
}
|
||||
|
||||
const ElfSymbol& ElfReader::getSection( const std::string& name ){
|
||||
for(container_t::const_iterator it = m_sectiontable.begin(); it !=m_sectiontable.end(); ++it){
|
||||
if(it->getName() == name){
|
||||
const ElfSymbol& ElfReader::getSection( const std::string& name ) {
|
||||
for (container_t::const_iterator it = m_sectiontable.begin(); it !=m_sectiontable.end(); ++it) {
|
||||
if (it->getName() == name) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
@ -227,29 +227,27 @@ const ElfSymbol& ElfReader::getSection( const std::string& name ){
|
||||
}
|
||||
|
||||
// "Pretty" Print
|
||||
void ElfReader::printDemangled(){
|
||||
void ElfReader::printDemangled() {
|
||||
m_log << "Demangled: " << std::endl;
|
||||
for(container_t::const_iterator it = m_symboltable.begin(); it !=m_symboltable.end(); ++it){
|
||||
for (container_t::const_iterator it = m_symboltable.begin(); it !=m_symboltable.end(); ++it) {
|
||||
std::string str = Demangler::demangle(it->getName());
|
||||
if(str == Demangler::DEMANGLE_FAILED){
|
||||
if (str == Demangler::DEMANGLE_FAILED) {
|
||||
str = it->getName();
|
||||
}
|
||||
m_log << "0x" << std::hex << it->getAddress() << "\t" << str.c_str() << "\t" << it->getSize() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ElfReader::printMangled(){
|
||||
for(container_t::const_iterator it = m_symboltable.begin(); it !=m_symboltable.end(); ++it){
|
||||
void ElfReader::printMangled() {
|
||||
for (container_t::const_iterator it = m_symboltable.begin(); it !=m_symboltable.end(); ++it) {
|
||||
m_log << "0x" << std::hex << it->getAddress() << "\t" << it->getName().c_str() << "\t" << it->getSize() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ElfReader::printSections() {
|
||||
for(container_t::const_iterator it = m_sectiontable.begin(); it !=m_sectiontable.end(); ++it){
|
||||
for (container_t::const_iterator it = m_sectiontable.begin(); it !=m_sectiontable.end(); ++it) {
|
||||
m_log << "0x" << it->getAddress() << "\t" << it->getName().c_str() << "\t" << it->getSize() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end-of-namespace fail
|
||||
|
||||
|
||||
@ -12,11 +12,11 @@
|
||||
|
||||
namespace fail {
|
||||
|
||||
struct ELF {
|
||||
struct ELF {
|
||||
static const std::string NOTFOUND;
|
||||
};
|
||||
};
|
||||
|
||||
class ElfSymbol {
|
||||
class ElfSymbol {
|
||||
std::string name;
|
||||
guest_address_t address;
|
||||
size_t size;
|
||||
@ -26,8 +26,8 @@ namespace fail {
|
||||
public:
|
||||
enum { SECTION = 1, SYMBOL = 2, UNDEF = 3, };
|
||||
|
||||
ElfSymbol(const std::string & name = ELF::NOTFOUND, guest_address_t addr = ADDR_INV, size_t size = -1, int type = UNDEF,
|
||||
int symbol_type = 0)
|
||||
ElfSymbol(const std::string & name = ELF::NOTFOUND, guest_address_t addr = ADDR_INV,
|
||||
size_t size = -1, int type = UNDEF, int symbol_type = 0)
|
||||
: name(name), address(addr), size(size), m_type(type), m_symbol_type(symbol_type) {};
|
||||
|
||||
const std::string& getName() const { return name; };
|
||||
@ -43,10 +43,10 @@ namespace fail {
|
||||
bool isValid() const { return name != ELF::NOTFOUND; };
|
||||
|
||||
bool operator==(const std::string& rhs) const {
|
||||
if(rhs == name){
|
||||
if (rhs == name) {
|
||||
return true;
|
||||
}
|
||||
if( rhs == Demangler::demangle(name) ){
|
||||
if ( rhs == Demangler::demangle(name) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -60,22 +60,22 @@ namespace fail {
|
||||
bool contains(guest_address_t ad) const {
|
||||
return (ad >= address) && (ad < address+size);
|
||||
}
|
||||
};
|
||||
/**
|
||||
};
|
||||
/**
|
||||
* \fn
|
||||
* \relates ElfSymbol
|
||||
* overloaded stream operator for printing ElfSymbol
|
||||
*/
|
||||
std::ostream& operator<< (std::ostream &out, const ElfSymbol &symbol);
|
||||
std::ostream& operator<< (std::ostream &out, const ElfSymbol &symbol);
|
||||
|
||||
/**
|
||||
/**
|
||||
* \class ElfReader
|
||||
* Parses an ELF file and provides a list of symbol names
|
||||
* and corresponding addresses
|
||||
*/
|
||||
|
||||
class ElfReader {
|
||||
public:
|
||||
class ElfReader {
|
||||
public:
|
||||
typedef ElfSymbol entry_t;
|
||||
typedef std::vector<entry_t> container_t;
|
||||
typedef container_t::const_iterator symbol_iterator;
|
||||
@ -154,7 +154,7 @@ namespace fail {
|
||||
|
||||
const std::string & getFilename() { return m_filename; }
|
||||
|
||||
private:
|
||||
private:
|
||||
Logger m_log;
|
||||
std::string m_filename;
|
||||
|
||||
@ -167,9 +167,8 @@ namespace fail {
|
||||
|
||||
guest_address_t getAddress(const std::string& name);
|
||||
std::string getName(guest_address_t address);
|
||||
};
|
||||
};
|
||||
|
||||
} // end-of-namespace fail
|
||||
|
||||
#endif //__ELFREADER_HPP__
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __LOGGER_HPP__
|
||||
#define __LOGGER_HPP__
|
||||
#define __LOGGER_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __MEMORYMAP_HPP__
|
||||
#define __MEMORYMAP_HPP__
|
||||
#define __MEMORYMAP_HPP__
|
||||
|
||||
#ifdef BOOST_1_46_OR_NEWER
|
||||
#include <boost/icl/interval_set.hpp>
|
||||
|
||||
@ -9,7 +9,7 @@ ProtoOStream::ProtoOStream(std::ostream *outfile) : m_outfile(outfile)
|
||||
m_log.showTime(false);
|
||||
}
|
||||
|
||||
bool ProtoOStream::writeMessage(google::protobuf::Message* m)
|
||||
bool ProtoOStream::writeMessage(google::protobuf::Message *m)
|
||||
{
|
||||
m_size = htonl(m->ByteSize());
|
||||
m_outfile->write(reinterpret_cast<char*>(&m_size), sizeof(m_size));
|
||||
@ -38,7 +38,7 @@ void ProtoIStream::reset()
|
||||
m_infile->seekg(0, std::ios::beg);
|
||||
}
|
||||
|
||||
bool ProtoIStream::getNext(google::protobuf::Message* m)
|
||||
bool ProtoIStream::getNext(google::protobuf::Message *m)
|
||||
{
|
||||
m_infile->read(reinterpret_cast<char*>(&m_size), sizeof(m_size));
|
||||
if (!m_infile->good())
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __PROTOSTREAM_HPP__
|
||||
#define __PROTOSTREAM_HPP__
|
||||
#define __PROTOSTREAM_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
@ -45,7 +45,7 @@ public:
|
||||
* @param m The protobuf-message to be written
|
||||
* @return Returns \c true on success, \c false otherwise
|
||||
*/
|
||||
bool writeMessage(google::protobuf::Message* m);
|
||||
bool writeMessage(google::protobuf::Message *m);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -73,7 +73,7 @@ public:
|
||||
* @param m The output protobuf message
|
||||
* @return Returns \c true on success, \c false otherwise
|
||||
*/
|
||||
bool getNext(google::protobuf::Message* m);
|
||||
bool getNext(google::protobuf::Message * m);
|
||||
};
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __SYNCHRONIZED_COUNTER_HPP__
|
||||
#define __SYNCHRONIZED_COUNTER_HPP__
|
||||
#define __SYNCHRONIZED_COUNTER_HPP__
|
||||
|
||||
#ifndef __puma
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __SYNCHRONIZED_MAP_HPP__
|
||||
#define __SYNCHRONIZED_MAP_HPP__
|
||||
#define __SYNCHRONIZED_MAP_HPP__
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -83,10 +83,10 @@ public:
|
||||
#ifndef __puma
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
#endif
|
||||
if( m_map.find(key) == m_map.end() ){ // not present, add it
|
||||
if ( m_map.find(key) == m_map.end() ) { // not present, add it
|
||||
m_map[key] = value;
|
||||
return true;
|
||||
}else{ // item is already in, oops
|
||||
} else { // item is already in, oops
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __SYNCHRONIZED_QUEUE_HPP__
|
||||
#define __SYNCHRONIZED_QUEUE_HPP__
|
||||
#define __SYNCHRONIZED_QUEUE_HPP__
|
||||
|
||||
#include <queue>
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#ifndef __WALLCLOCKTIMER_HPP__
|
||||
#define __WALLCLOCKTIMER_HPP__
|
||||
#define __WALLCLOCKTIMER_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -6,7 +6,7 @@ using namespace llvm::object;
|
||||
|
||||
|
||||
LLVMtoFailTranslator & LLVMDisassembler::getTranslator() {
|
||||
if ( ltofail == 0 ){
|
||||
if ( ltofail == 0 ) {
|
||||
std::cout << "ArchType: " << llvm::Triple::getArchTypeName( llvm::Triple::ArchType(object->getArch()) ) << std::endl;
|
||||
|
||||
switch ( llvm::Triple::ArchType(object->getArch()) ) {
|
||||
|
||||
@ -5,7 +5,7 @@ using namespace fail;
|
||||
|
||||
const LLVMtoFailTranslator::reginfo_t & LLVMtoFailTranslator::getFailRegisterID(unsigned int regid) {
|
||||
ltof_map_t::iterator it = llvm_to_fail_map.find(regid);
|
||||
if( it != llvm_to_fail_map.end() ) {// found
|
||||
if ( it != llvm_to_fail_map.end() ) {// found
|
||||
return (*it).second;
|
||||
} else { // not found
|
||||
std::cout << "Fail ID for LLVM Register id " << std::dec << regid << " not found :(" << std::endl;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __ABO_SIMPLE_ARM_EXPERIMENT_HPP__
|
||||
#define __ABO_SIMPLE_ARM_EXPERIMENT_HPP__
|
||||
#define __ABO_SIMPLE_ARM_EXPERIMENT_HPP__
|
||||
|
||||
#include "efw/ExperimentFlow.hpp"
|
||||
#include "efw/JobClient.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __CHECKSUM_OOSTUBS_CAMPAIGN_HPP__
|
||||
#define __CHECKSUM_OOSTUBS_CAMPAIGN_HPP__
|
||||
#define __CHECKSUM_OOSTUBS_CAMPAIGN_HPP__
|
||||
|
||||
#include "cpn/Campaign.hpp"
|
||||
#include "comm/ExperimentData.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __CHECKSUM_OOSTUBS_EXPERIMENT_HPP__
|
||||
#define __CHECKSUM_OOSTUBS_EXPERIMENT_HPP__
|
||||
#define __CHECKSUM_OOSTUBS_EXPERIMENT_HPP__
|
||||
|
||||
#include "efw/ExperimentFlow.hpp"
|
||||
#include "efw/JobClient.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __EXPERIMENT_INFO_HPP__
|
||||
#define __EXPERIMENT_INFO_HPP__
|
||||
#define __EXPERIMENT_INFO_HPP__
|
||||
|
||||
// FIXME autogenerate this
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ bool CoolChecksumCampaign::run()
|
||||
Trace_Event ev;
|
||||
ps.reset();
|
||||
|
||||
while(ps.getNext(&ev)) {
|
||||
while (ps.getNext(&ev)) {
|
||||
// only count instruction events
|
||||
if (!ev.has_memaddr()) {
|
||||
// new instruction
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __COOLCAMPAIGN_HPP__
|
||||
#define __COOLCAMPAIGN_HPP__
|
||||
#define __COOLCAMPAIGN_HPP__
|
||||
|
||||
#include "cpn/Campaign.hpp"
|
||||
#include "comm/ExperimentData.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __COOLEXPERIMENT_HPP__
|
||||
#define __COOLEXPERIMENT_HPP__
|
||||
#define __COOLEXPERIMENT_HPP__
|
||||
|
||||
#include "efw/ExperimentFlow.hpp"
|
||||
#include "efw/JobClient.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __EXPERIMENT_INFO_HPP__
|
||||
#define __EXPERIMENT_INFO_HPP__
|
||||
#define __EXPERIMENT_INFO_HPP__
|
||||
|
||||
#define COOL_FAULTSPACE_PRUNING 0
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ bool EcosKernelTestCampaign::readTraceInfo(unsigned &instr_counter, unsigned &ti
|
||||
|
||||
while (getline(file, buf)) {
|
||||
stringstream ss(buf, ios::in);
|
||||
switch(count) {
|
||||
switch (count) {
|
||||
case 0:
|
||||
ss >> instr_counter;
|
||||
break;
|
||||
|
||||
@ -113,7 +113,7 @@ bool EcosKernelTestExperiment::establishState(guest_address_t addr_entry, guest_
|
||||
|
||||
while (true) {
|
||||
simulator.addListenerAndResume(&g);
|
||||
if(g.getData() == 'Q') {
|
||||
if (g.getData() == 'Q') {
|
||||
log << "Guest system triggered: " << g.getData() << endl;
|
||||
break;
|
||||
}
|
||||
@ -203,15 +203,15 @@ bool EcosKernelTestExperiment::performTrace(guest_address_t addr_entry, guest_ad
|
||||
|
||||
// do the job, 'till the end
|
||||
BaseListener* ev = simulator.resume();
|
||||
while(ev != &bp) {
|
||||
if(ev == &ev_count) {
|
||||
if(instr_counter++ == 0xFFFFFFFFU) {
|
||||
while (ev != &bp) {
|
||||
if (ev == &ev_count) {
|
||||
if (instr_counter++ == 0xFFFFFFFFU) {
|
||||
log << "ERROR: instr_counter overflowed" << endl;
|
||||
return false;
|
||||
}
|
||||
simulator.addListener(&ev_count);
|
||||
}
|
||||
else if(ev == &ev_mem) {
|
||||
else if (ev == &ev_mem) {
|
||||
unsigned lo = ev_mem.getTriggerAddress();
|
||||
unsigned hi = lo + ev_mem.getTriggerWidth() - 1;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __FAULT_COVERAGE_EXPERIMENT_HPP__
|
||||
#define __FAULT_COVERAGE_EXPERIMENT_HPP__
|
||||
#define __FAULT_COVERAGE_EXPERIMENT_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __FIREINTERRUPT_EXPERIMENT_HPP__
|
||||
#define __FIREINTERRUPT_EXPERIMENT_HPP__
|
||||
#define __FIREINTERRUPT_EXPERIMENT_HPP__
|
||||
|
||||
#include "efw/ExperimentFlow.hpp"
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ using namespace fail;
|
||||
|
||||
void GenericTracing::parseOptions() {
|
||||
CommandLine &cmd = CommandLine::Inst();
|
||||
CommandLine::option_handle IGNORE = cmd.addOption("", "", Arg::None, "USAGE: fail-client -Wf,[option] -Wf,[option] ... <BochsOptions...>\n\n");
|
||||
cmd.addOption("", "", Arg::None, "USAGE: fail-client -Wf,[option] -Wf,[option] ... <BochsOptions...>\n\n");
|
||||
CommandLine::option_handle HELP = cmd.addOption("h", "help", Arg::None, "-h,--help \tPrint usage and exit");
|
||||
|
||||
|
||||
@ -35,18 +35,18 @@ void GenericTracing::parseOptions() {
|
||||
CommandLine::option_handle SAVE_SYMBOL = cmd.addOption("S", "save-symbol", Arg::Required,
|
||||
"-S,--save-symbol \tELF symbol to save the state of the machine (default: main)\n");
|
||||
CommandLine::option_handle STATE_FILE = cmd.addOption("f", "state-file", Arg::Required,
|
||||
"-f,--state-file \tFile/dir to save the state to (default state)");
|
||||
"-f,--state-file \tFile/dir to save the state to (default: state)");
|
||||
CommandLine::option_handle TRACE_FILE = cmd.addOption("t", "trace-file", Arg::Required,
|
||||
"-t,--trace-file \tFile to save the execution trace to\n");
|
||||
"-t,--trace-file \tFile to save the execution trace to (default: trace.pb)\n");
|
||||
|
||||
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 (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>");
|
||||
" (Possible formats: 0x<address>, 0x<address>:0x<address>, 0x<address>:<length>)");
|
||||
|
||||
if(!cmd.parse()) {
|
||||
if (!cmd.parse()) {
|
||||
cerr << "Error parsing arguments." << endl;
|
||||
exit(-1);
|
||||
}
|
||||
@ -60,7 +60,7 @@ void GenericTracing::parseOptions() {
|
||||
elf_file = cmd[ELF_FILE].first()->arg;
|
||||
else {
|
||||
char * elfpath = getenv("FAIL_ELF_PATH");
|
||||
if(elfpath == NULL){
|
||||
if (elfpath == NULL) {
|
||||
m_log << "FAIL_ELF_PATH not set :( (alternative: --elf-file) " << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
@ -102,7 +102,7 @@ void GenericTracing::parseOptions() {
|
||||
use_memory_map = true;
|
||||
option::Option *opt = cmd[MEM_SYMBOL].first();
|
||||
|
||||
while(opt != 0) {
|
||||
while (opt != 0) {
|
||||
const ElfSymbol &symbol = m_elf->getSymbol(opt->arg);
|
||||
assert(symbol.isValid());
|
||||
|
||||
@ -118,7 +118,7 @@ void GenericTracing::parseOptions() {
|
||||
use_memory_map = true;
|
||||
option::Option *opt = cmd[MEM_REGION].first();
|
||||
|
||||
while(opt != 0) {
|
||||
while (opt != 0) {
|
||||
char *endptr;
|
||||
guest_address_t begin = strtol(opt->arg, &endptr, 16);
|
||||
guest_address_t size;
|
||||
@ -130,14 +130,14 @@ void GenericTracing::parseOptions() {
|
||||
char delim = *endptr;
|
||||
if (delim == 0) {
|
||||
size = 1;
|
||||
} else if(delim == ':') {
|
||||
} else if (delim == ':') {
|
||||
char *p = endptr +1;
|
||||
size = strtol(p, &endptr, 16) - begin;
|
||||
if (p == endptr || *endptr != 0) {
|
||||
m_log << "Couldn't parse " << opt->arg << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
} else if(delim == '+') {
|
||||
} else if (delim == '+') {
|
||||
char *p = endptr +1;
|
||||
size = strtol(p, &endptr, 10);
|
||||
if (p == endptr || *endptr != 0) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __HSC_SIMPLE_EXPERIMENT_HPP__
|
||||
#define __HSC_SIMPLE_EXPERIMENT_HPP__
|
||||
#define __HSC_SIMPLE_EXPERIMENT_HPP__
|
||||
|
||||
#include "efw/ExperimentFlow.hpp"
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ bool KESOrefs::run()
|
||||
while (executed_jobs < 25 || m_jc.getNumberOfUndoneJobs() > 0) {
|
||||
m_log << "asking jobserver for parameters" << endl;
|
||||
KesoRefExperimentData param;
|
||||
if(!m_jc.getParam(param)){
|
||||
if (!m_jc.getParam(param)) {
|
||||
m_log << "Dying." << endl; // We were told to die.
|
||||
simulator.terminate(1);
|
||||
}
|
||||
@ -218,7 +218,7 @@ bool KESOrefs::run()
|
||||
m_log << "CDX has ended" << std::endl;
|
||||
|
||||
// Evaluate result
|
||||
if(l == &l_error) {
|
||||
if (l == &l_error) {
|
||||
handleEvent(*result, result->EXC_ERROR, "exc error");
|
||||
} else if ( l == &l_nullp ) {
|
||||
handleEvent(*result, result->EXC_NULLPOINTER, "exc nullpointer");
|
||||
@ -241,10 +241,10 @@ bool KESOrefs::run()
|
||||
sstr << "trap #" << l_trap.getTriggerNumber();
|
||||
handleEvent(*result, result->TRAP, sstr.str());
|
||||
|
||||
} else if (l == &l_mem_text){
|
||||
} else if (l == &l_mem_text) {
|
||||
handleMemoryAccessEvent(*result, l_mem_text);
|
||||
|
||||
} else if (l == &l_mem_outerspace){
|
||||
} else if (l == &l_mem_outerspace) {
|
||||
handleMemoryAccessEvent(*result, l_mem_outerspace);
|
||||
|
||||
} else {
|
||||
|
||||
@ -452,7 +452,7 @@ void L4SysExperiment::collectInstructionTrace(fail::BPSingleListener* bp)
|
||||
log << "mem accesses: " << mem << ", valid: " << mem_valid << std::endl;
|
||||
#else
|
||||
bp->setWatchInstructionPointer(ANY_ADDR);
|
||||
while(bp->getTriggerInstructionPointer() != L4SYS_FUNC_EXIT)
|
||||
while (bp->getTriggerInstructionPointer() != L4SYS_FUNC_EXIT)
|
||||
{
|
||||
fail::BaseListener *res = simulator.resume();
|
||||
address_t curr_addr = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __NANOJPEG_EXPERIMENT_HPP__
|
||||
#define __NANOJPEG_EXPERIMENT_HPP__
|
||||
#define __NANOJPEG_EXPERIMENT_HPP__
|
||||
|
||||
#include "efw/ExperimentFlow.hpp"
|
||||
#include "efw/JobClient.hpp"
|
||||
|
||||
@ -30,7 +30,7 @@ char const *
|
||||
Udis86Helper::mnemonicToString(unsigned mnemonic)
|
||||
{
|
||||
|
||||
switch(mnemonic) {
|
||||
switch (mnemonic) {
|
||||
CASE(UD_Iinvalid) CASE(UD_I3dnow) CASE(UD_Inone) CASE(UD_Idb) CASE(UD_Ipause) CASE(UD_Iaaa)
|
||||
CASE(UD_Iaad) CASE(UD_Iaam) CASE(UD_Iaas) CASE(UD_Iadc) CASE(UD_Iadd) CASE(UD_Iaddpd)
|
||||
CASE(UD_Iaddps) CASE(UD_Iaddsd) CASE(UD_Iaddss) CASE(UD_Iand) CASE(UD_Iandpd) CASE(UD_Iandps)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef __RAMPAGE_EXPERIMENT_HPP__
|
||||
#define __RAMPAGE_EXPERIMENT_HPP__
|
||||
#define __RAMPAGE_EXPERIMENT_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user