(capstone) feat: add capstone disassembler to tools/import-trace/

This commit is contained in:
Robin Thunig
2019-11-01 01:24:28 +01:00
committed by Robin Thunig
parent d04afaac54
commit f7f982fec5
14 changed files with 407 additions and 14 deletions

View File

@ -5,10 +5,38 @@
#include "util/CommandLine.hpp"
#include "Importer.hpp"
#if defined(BUILD_CAPSTONE_DISASSEMBLER)
#include "util/capstonedisassembler/CapstoneDisassembler.hpp"
#elif defined(BUILD_LLVM_DISASSEMBLER)
#include "util/llvmdisassembler/LLVMDisassembler.hpp"
#endif
class RegisterImporter : public Importer {
#if defined(BUILD_CAPSTONE_DISASSEMBLER)
bool isDisassembled = false;
std::unique_ptr<fail::CapstoneDisassembler> disas;
fail::CapstoneToFailTranslator *m_ctof = 0;
bool addRegisterTrace(fail::simtime_t curtime, instruction_count_t instr,
Trace_Event &ev,
const fail::CapstoneToFailTranslator::reginfo_t &info,
char access_type);
fail::CommandLine::option_handle NO_GP, FLAGS, IP, NO_SPLIT;
bool do_gp, do_flags, do_ip, do_split_registers;
std::set<unsigned> m_register_ids;
unsigned m_ip_register_id;
// Data structures for recording failed LLVM -> FAIL* register mappings,
// including occurrence counts in the trace (to give an estimate on the
// impact) and instruction addresses (for debugging purposes).
struct RegNotFound {
uint64_t count = 0;
std::set<fail::guest_address_t> address;
};
std::map<fail::CapstoneDisassembler::register_t, RegNotFound> m_regnotfound;
#elif defined(BUILD_LLVM_DISASSEMBLER)
llvm::object::Binary *binary = 0;
std::unique_ptr<fail::LLVMDisassembler> disas;
fail::LLVMtoFailTranslator *m_ltof = 0;
@ -32,6 +60,8 @@ class RegisterImporter : public Importer {
std::set<fail::guest_address_t> address;
};
std::map<fail::LLVMDisassembler::register_t, RegNotFound> m_regnotfound;
#endif
public:
RegisterImporter() : Importer(), do_gp(true), do_flags(false), do_ip(false),