formatting, typos, comments, details

Change-Id: Iae5f1acb653a694622e9ac2bad93efcfca588f3a
This commit is contained in:
Horst Schirmeier
2013-10-14 14:43:39 +02:00
parent 7591c9edc5
commit 4cb97a7fa5
138 changed files with 1566 additions and 1576 deletions

View File

@ -1,5 +1,5 @@
#ifndef __DISASSEMBLER_HPP
#define __DISASSEMBLER_HPP
#define __DISASSEMBLER_HPP
#include <string>
#include "Logger.hpp"
@ -9,70 +9,70 @@
namespace fail {
struct DISASSEMBLER {
//! Inform about failed disassembly
static const std::string FAILED;
};
struct DISASSEMBLER {
//! Inform about failed disassembly
static const std::string FAILED;
};
/**
* @class Instruction
* @brief An Instruction represents an disassembled opcode
*/
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);
/**
* @class Instruction
* @brief An Instruction represents an disassembled opcode
*/
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);
class Disassembler {
class Disassembler {
public:
/**
* Constructor.
*/
Disassembler();
public:
/**
* Constructor.
*/
Disassembler();
/**
* Get disassembler instruction
* @param address The instruction address
* @return The according disassembled instruction if found, else DISASSEMBLER::FAILED
*/
const Instruction & disassemble(address_t address) const;
/**
* Get disassembler instruction
* @param address The instruction address
* @return The according disassembled instruction if found, else DISASSEMBLER::FAILED
*/
const Instruction & disassemble(address_t address) const;
/**
* Test if there is an instruction at a given address
* @param address The address to test
* @return true if found, else false
*/
bool hasInstructionAt(address_t address) const {
return m_code.find(address) != m_code.end();;
};
/**
* Test if there is an instruction at a given address
* @param address The address to test
* @return true if found, else false
*/
bool hasInstructionAt(address_t address) const {
return m_code.find(address) != m_code.end();;
};
/**
* Evaluate new ELF file
* @param elfpath Path to ELF file.
* @return Number of disassembled lines.
*/
int init(const char* elfpath);
/**
* Evaluate new ELF file
* @param elfpath Path to ELF file.
* @return Number of disassembled lines.
*/
int init(const char* elfpath);
/**
* Evaluate new ELF file from env variable $FAIL_ELF_PATH
* @return Number of disassembled lines.
* @note The path is guessed from a FAIL_ELF_PATH environment variable
*/
int init(void);
/**
* Evaluate new ELF file from env variable $FAIL_ELF_PATH
* @return Number of disassembled lines.
* @note The path is guessed from a FAIL_ELF_PATH environment variable
*/
int init(void);
private:
Logger m_log;
typedef std::map<address_t, Instruction> InstructionMap_t;
InstructionMap_t m_code;
void evaluate(const std::string &);
};
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