Bugfixing in L4-Sys
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1379 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -14,6 +14,8 @@ set(MY_CAMPAIGN_SRCS
|
|||||||
experiment.cc
|
experiment.cc
|
||||||
campaign.hpp
|
campaign.hpp
|
||||||
campaign.cc
|
campaign.cc
|
||||||
|
UDIS86.hpp
|
||||||
|
UDIS86.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
#### PROTOBUFS ####
|
#### PROTOBUFS ####
|
||||||
|
|||||||
60
src/experiments/l4-sys/UDIS86.cc
Normal file
60
src/experiments/l4-sys/UDIS86.cc
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#include "sal/bochs/BochsController.hpp"
|
||||||
|
#include "UDIS86.hpp"
|
||||||
|
|
||||||
|
using namespace fail;
|
||||||
|
|
||||||
|
Udis86::Udis86(const unsigned char *instr, size_t size) {
|
||||||
|
// initialise the buffer
|
||||||
|
unsigned char *udis_instr = static_cast<unsigned char*>(malloc(size));
|
||||||
|
memcpy(udis_instr, instr, size);
|
||||||
|
|
||||||
|
// initialise the internal data structure
|
||||||
|
memset(&ud_obj, 0, sizeof(ud_t));
|
||||||
|
ud_init(&ud_obj);
|
||||||
|
|
||||||
|
// assign the buffer to the data structure
|
||||||
|
ud_set_input_buffer(&ud_obj, udis_instr, size);
|
||||||
|
|
||||||
|
// free the buffer
|
||||||
|
free(udis_instr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Udis86::fetchNextInstruction() {
|
||||||
|
return (ud_disassemble(&ud_obj) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
GPRegisterId Udis86::udisGPRToFailBochsGPR(ud_type_t udisReg) {
|
||||||
|
#define REG_CASE(REG) case UD_R_##REG: return RID_##REG
|
||||||
|
switch (udisReg) {
|
||||||
|
#if BX_SUPPORT_X86_64 // 64 bit register id's:
|
||||||
|
REG_CASE(RAX);
|
||||||
|
REG_CASE(RCX);
|
||||||
|
REG_CASE(RDX);
|
||||||
|
REG_CASE(RBX);
|
||||||
|
REG_CASE(RSP);
|
||||||
|
REG_CASE(RBP);
|
||||||
|
REG_CASE(RSI);
|
||||||
|
REG_CASE(RDI);
|
||||||
|
REG_CASE(R8);
|
||||||
|
REG_CASE(R9);
|
||||||
|
REG_CASE(R10);
|
||||||
|
REG_CASE(R11);
|
||||||
|
REG_CASE(R12);
|
||||||
|
REG_CASE(R13);
|
||||||
|
REG_CASE(R14);
|
||||||
|
REG_CASE(R15);
|
||||||
|
#else
|
||||||
|
REG_CASE(EAX);
|
||||||
|
REG_CASE(ECX);
|
||||||
|
REG_CASE(EDX);
|
||||||
|
REG_CASE(EBX);
|
||||||
|
REG_CASE(ESP);
|
||||||
|
REG_CASE(EBP);
|
||||||
|
REG_CASE(ESI);
|
||||||
|
REG_CASE(EDI);
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
return RID_LAST_GP_ID;
|
||||||
|
}
|
||||||
|
#undef REG_CASE
|
||||||
|
}
|
||||||
41
src/experiments/l4-sys/UDIS86.hpp
Normal file
41
src/experiments/l4-sys/UDIS86.hpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef __UDIS86_HPP__
|
||||||
|
#define __UDIS86_HPP__
|
||||||
|
|
||||||
|
#include <udis86.h>
|
||||||
|
#include "sal/bochs/BochsRegister.hpp"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class Udis86
|
||||||
|
*
|
||||||
|
* \brief Class to disassemble instructions
|
||||||
|
*
|
||||||
|
* This class disassembles a stream of machine code instruction
|
||||||
|
* by instruction.
|
||||||
|
* It provides a (thin) wrapper around the C API of UDIS86.
|
||||||
|
*/
|
||||||
|
class Udis86
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
ud_t ud_obj; //<! the ud object of udis86
|
||||||
|
public:
|
||||||
|
Udis86(const unsigned char *instr, size_t size);
|
||||||
|
/**
|
||||||
|
* retrieves the private ud structure of udis86
|
||||||
|
* @returns a reference pointer to a ud_t variable
|
||||||
|
*/
|
||||||
|
inline const ud_t &getCurrentState() const { return ud_obj; }
|
||||||
|
/**
|
||||||
|
* Tries to decode the next instruction from the given buffer.
|
||||||
|
* @returns \c true if a new instruction could be retrieved, \c false if the object has expired
|
||||||
|
*/
|
||||||
|
bool fetchNextInstruction();
|
||||||
|
/**
|
||||||
|
* Returns the FailBochs equivalent to a UDIS86 GPR identifier.
|
||||||
|
* Attention: this only returns either 32-bit or 64-bit registers, no general IDs
|
||||||
|
* @param udisReg the udis86 GPR ID
|
||||||
|
* @returns the FailBochs GPR ID, usable with the BochsRegisterManager class
|
||||||
|
*/
|
||||||
|
static fail::GPRegisterId udisGPRToFailBochsGPR(ud_type_t udisReg);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __UDIS86_HPP__
|
||||||
@ -9,6 +9,7 @@
|
|||||||
#include "experiment.hpp"
|
#include "experiment.hpp"
|
||||||
#include "experimentInfo.hpp"
|
#include "experimentInfo.hpp"
|
||||||
#include "UDIS86.hpp"
|
#include "UDIS86.hpp"
|
||||||
|
#include "campaign.hpp"
|
||||||
|
|
||||||
#include "sal/SALConfig.hpp"
|
#include "sal/SALConfig.hpp"
|
||||||
#include "sal/SALInst.hpp"
|
#include "sal/SALInst.hpp"
|
||||||
|
|||||||
@ -5,9 +5,10 @@
|
|||||||
|
|
||||||
#include "efw/ExperimentFlow.hpp"
|
#include "efw/ExperimentFlow.hpp"
|
||||||
#include "efw/JobClient.hpp"
|
#include "efw/JobClient.hpp"
|
||||||
#include "campaign.hpp"
|
|
||||||
#include "util/Logger.hpp"
|
#include "util/Logger.hpp"
|
||||||
|
|
||||||
|
class L4SysExperimentData;
|
||||||
|
|
||||||
class L4SysExperiment : public fail::ExperimentFlow {
|
class L4SysExperiment : public fail::ExperimentFlow {
|
||||||
fail::JobClient m_jc;
|
fail::JobClient m_jc;
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user