From 7394a2cd533284e9e747c5d0d184fc827853822c Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Wed, 25 Jun 2014 23:10:57 +0200 Subject: [PATCH] import-trace: let RegisterImporter ignore unknown IP This change makes the RegisterImporter continue importing if it encounters an instruction pointer that is not part of the disassembled ELF binary (and, thus, cannot be disassembled). This is OK if we don't want to inject into registers used by these instructions. Change-Id: Ia9b5e7f789367f8386d63f235451dae5d399610d --- tools/import-trace/RegisterImporter.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/import-trace/RegisterImporter.cc b/tools/import-trace/RegisterImporter.cc index 9467bf6a..0c2ad75f 100644 --- a/tools/import-trace/RegisterImporter.cc +++ b/tools/import-trace/RegisterImporter.cc @@ -148,10 +148,19 @@ bool RegisterImporter::handle_ip_event(fail::simtime_t curtime, instruction_coun LOG << "instructions disassembled: " << instr_map.size() << " Triple: " << disas->GetTriple() << std::endl; } + // instruction pointer is read + written at each instruction + const LLVMtoFailTranslator::reginfo_t info_pc(m_ip_register_id); + if (do_ip && + (!addRegisterTrace(curtime, instr, ev, info_pc, 'R') || + !addRegisterTrace(curtime, instr, ev, info_pc, 'W'))) { + return false; + } + const LLVMDisassembler::InstrMap &instr_map = disas->getInstrMap(); if (instr_map.find(ev.ip()) == instr_map.end()) { - LOG << "Could not find instruction for IP: " << std::hex << ev.ip() << std::endl; - return false; + LOG << "Could not find instruction for IP " << std::hex << ev.ip() + << ", skipping" << std::endl; + return true; } const LLVMDisassembler::Instr &opcode = instr_map.at(ev.ip()); //const MCRegisterInfo ®_info = disas->getRegisterInfo(); @@ -197,13 +206,5 @@ bool RegisterImporter::handle_ip_event(fail::simtime_t curtime, instruction_coun return false; } - const LLVMtoFailTranslator::reginfo_t info_pc(m_ip_register_id); - if (do_ip) { - if (!addRegisterTrace(curtime, instr, ev, info_pc, 'R')) - return false; - if (!addRegisterTrace(curtime, instr, ev, info_pc, 'W')) - return false; - } - return true; }