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
This commit is contained in:
@ -23,6 +23,9 @@ bool RegisterImporter::cb_commandline_init() {
|
|||||||
"--flags: RegisterImporter: trace flags register\n");
|
"--flags: RegisterImporter: trace flags register\n");
|
||||||
IP = cmd.addOption("", "ip", Arg::None,
|
IP = cmd.addOption("", "ip", Arg::None,
|
||||||
"--ip: RegisterImporter: trace instruction pointer\n");
|
"--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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -32,8 +35,23 @@ bool RegisterImporter::addRegisterTrace(simtime_t curtime, instruction_count_t i
|
|||||||
const Trace_Event &ev,
|
const Trace_Event &ev,
|
||||||
const LLVMtoFailTranslator::reginfo_t &info,
|
const LLVMtoFailTranslator::reginfo_t &info,
|
||||||
char access_type) {
|
char access_type) {
|
||||||
address_t from = info.toDataAddress();
|
address_t from, to;
|
||||||
address_t to = from + info.width / 8;
|
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
|
// Iterate over all accessed bytes
|
||||||
for (address_t data_address = from; data_address < to; ++data_address) {
|
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_info_t access;
|
||||||
access.access_type = access_type; // instruction fetch is always a read
|
access.access_type = access_type; // instruction fetch is always a read
|
||||||
access.data_address = data_address;
|
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)) {
|
if (!add_trace_event(left_margin, right_margin, access)) {
|
||||||
LOG << "add_trace_event failed" << std::endl;
|
LOG << "add_trace_event failed" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -95,6 +113,10 @@ bool RegisterImporter::handle_ip_event(fail::simtime_t curtime, instruction_coun
|
|||||||
if (cmd[IP].count() > 0) {
|
if (cmd[IP].count() > 0) {
|
||||||
do_ip = true;
|
do_ip = true;
|
||||||
}
|
}
|
||||||
|
if (cmd[NO_SPLIT].count() > 0) {
|
||||||
|
do_split_registers = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Disassemble the binary if necessary */
|
/* Disassemble the binary if necessary */
|
||||||
llvm::InitializeAllTargetInfos();
|
llvm::InitializeAllTargetInfos();
|
||||||
|
|||||||
@ -17,11 +17,12 @@ class RegisterImporter : public Importer {
|
|||||||
const fail::LLVMtoFailTranslator::reginfo_t &info,
|
const fail::LLVMtoFailTranslator::reginfo_t &info,
|
||||||
char access_type);
|
char access_type);
|
||||||
|
|
||||||
fail::CommandLine::option_handle NO_GP, FLAGS, IP;
|
fail::CommandLine::option_handle NO_GP, FLAGS, IP, NO_SPLIT;
|
||||||
bool do_gp, do_flags, do_ip;
|
bool do_gp, do_flags, do_ip, do_split_registers;
|
||||||
|
|
||||||
public:
|
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
|
* Callback function that can be used to add command line options
|
||||||
* to the cmd interface
|
* to the cmd interface
|
||||||
|
|||||||
Reference in New Issue
Block a user