From 04e96b977cd7e9f456286245547c7273d6264028 Mon Sep 17 00:00:00 2001 From: Christian Dietrich Date: Tue, 10 Sep 2013 14:59:10 +0200 Subject: [PATCH] tools/import-trace: add --do-not-split option to RegisterImporter The RegisterImporter splits each register into 1 byte chunks. The --do-not-split flag prohibits this splitting. Be aware, that def/use pruning won't work correctly in mixed-width cases (EAX/AX/AH/AL). Change-Id: Ifa1930bdd9f317a6fd3ae50c4ff3cffc97504640 --- tools/import-trace/RegisterImporter.cc | 28 ++++++++++++++++++++++--- tools/import-trace/RegisterImporter.hpp | 7 ++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/tools/import-trace/RegisterImporter.cc b/tools/import-trace/RegisterImporter.cc index a2b4a410..3df4dc58 100644 --- a/tools/import-trace/RegisterImporter.cc +++ b/tools/import-trace/RegisterImporter.cc @@ -23,6 +23,9 @@ bool RegisterImporter::cb_commandline_init() { "--flags: RegisterImporter: trace flags register\n"); IP = cmd.addOption("", "ip", Arg::None, "--ip: RegisterImporter: trace instruction pointer\n"); + NO_SPLIT = cmd.addOption("", "do-not-split", Arg::None, + "--do-not-split: RegisterImporter: Do not split the registers into one byte chunks\n"); + return true; } @@ -32,8 +35,23 @@ bool RegisterImporter::addRegisterTrace(simtime_t curtime, instruction_count_t i const Trace_Event &ev, const LLVMtoFailTranslator::reginfo_t &info, char access_type) { - address_t from = info.toDataAddress(); - address_t to = from + info.width / 8; + address_t from, to; + int chunk_width; + if (do_split_registers) { + /* If we want to split the registers into one byte chunks (to + enable proper pruning, we use a one byte window register, + to determine beginning and end address */ + LLVMtoFailTranslator::reginfo_t one_byte_window = info; + one_byte_window.width = 8; + from = one_byte_window.toDataAddress(); + to = one_byte_window.toDataAddress() + info.width / 8; + chunk_width = 1; // One byte chunks + } else { + /* We trace whole registers */ + from = info.toDataAddress(); + to = from + 1; /* exactly one trace event per register access*/ + chunk_width = (info.width / 8); + } // Iterate over all accessed bytes for (address_t data_address = from; data_address < to; ++data_address) { @@ -60,7 +78,7 @@ bool RegisterImporter::addRegisterTrace(simtime_t curtime, instruction_count_t i access_info_t access; access.access_type = access_type; // instruction fetch is always a read access.data_address = data_address; - access.data_width = 1; // exactly one byte + access.data_width = chunk_width; if (!add_trace_event(left_margin, right_margin, access)) { LOG << "add_trace_event failed" << std::endl; return false; @@ -95,6 +113,10 @@ bool RegisterImporter::handle_ip_event(fail::simtime_t curtime, instruction_coun if (cmd[IP].count() > 0) { do_ip = true; } + if (cmd[NO_SPLIT].count() > 0) { + do_split_registers = false; + } + /* Disassemble the binary if necessary */ llvm::InitializeAllTargetInfos(); diff --git a/tools/import-trace/RegisterImporter.hpp b/tools/import-trace/RegisterImporter.hpp index 5cfacd49..c3425d6b 100644 --- a/tools/import-trace/RegisterImporter.hpp +++ b/tools/import-trace/RegisterImporter.hpp @@ -17,11 +17,12 @@ class RegisterImporter : public Importer { const fail::LLVMtoFailTranslator::reginfo_t &info, char access_type); - fail::CommandLine::option_handle NO_GP, FLAGS, IP; - bool do_gp, do_flags, do_ip; + fail::CommandLine::option_handle NO_GP, FLAGS, IP, NO_SPLIT; + bool do_gp, do_flags, do_ip, do_split_registers; public: - RegisterImporter() : Importer(), do_gp(true), do_flags(false), do_ip(false) {} + RegisterImporter() : Importer(), do_gp(true), do_flags(false), do_ip(false), + do_split_registers(true) {} /** * Callback function that can be used to add command line options * to the cmd interface