tools/import-trace: import timing information + various additions

- Import timing information from traces that were recorded with timing.
- Allow restricting import to a memory map ("vertical" restriction).
- Proper fault-space right-margin handling.
- Cleanups, data-type usage, etc.

Change-Id: I7a49e8e9e49894c458e884bfc234f36b9ba8b130
This commit is contained in:
Horst Schirmeier
2013-04-08 15:02:53 +02:00
parent 0f16f18d75
commit 9273872d43
6 changed files with 193 additions and 77 deletions

View File

@ -3,6 +3,7 @@
#include "util/CommandLine.hpp"
#include "util/Database.hpp"
#include "util/ElfReader.hpp"
#include "util/MemoryMap.hpp"
#include "util/gzstream/gzstream.h"
#include "util/Logger.hpp"
#include <fstream>
@ -49,6 +50,7 @@ int main(int argc, char *argv[]) {
std::string trace_file, username, hostname, database, benchmark;
std::string variant, importer_args;
ElfReader *elf_file = 0;
MemoryMap *memorymap = 0;
// Manually fill the command line option parser
CommandLine &cmd = CommandLine::Inst();
@ -56,23 +58,47 @@ int main(int argc, char *argv[]) {
cmd.add_args(argv[i]);
cmd.addOption("", "", Arg::None, "USAGE: import-trace [options]");
CommandLine::option_handle HELP = cmd.addOption("h", "help", Arg::None, "-h/--help\t Print usage and exit");
CommandLine::option_handle TRACE_FILE = cmd.addOption("t", "trace-file", Arg::Required,
"-t/--trace-file\t File to load the execution trace from\n");
CommandLine::option_handle HELP =
cmd.addOption("h", "help", Arg::None, "-h/--help \tPrint usage and exit");
CommandLine::option_handle TRACE_FILE =
cmd.addOption("t", "trace-file", Arg::Required,
"-t/--trace-file \tFile to load the execution trace from\n");
// setup the database command line options
Database::cmdline_setup();
CommandLine::option_handle VARIANT = cmd.addOption("v", "variant", Arg::Required,
"-v/--variant\t Variant label (default: \"none\")");
CommandLine::option_handle BENCHMARK = cmd.addOption("b", "benchmark", Arg::Required,
"-b/--benchmark\t Benchmark label (default: \"none\")\n");
CommandLine::option_handle IMPORTER = cmd.addOption("i", "importer", Arg::Required,
"-i/--importer\t Which import method to use (default: BasicImporter)");
CommandLine::option_handle IMPORTER_ARGS = cmd.addOption("I", "importer-args", Arg::Required,
"-I/--importer-args\t Which import method to use (default: "")");
CommandLine::option_handle ELF_FILE = cmd.addOption("e", "elf-file", Arg::Required,
"-e/--elf-file\t ELF File (default: UNSET)");
CommandLine::option_handle VARIANT =
cmd.addOption("v", "variant", Arg::Required,
"-v/--variant \tVariant label (default: \"none\")");
CommandLine::option_handle BENCHMARK =
cmd.addOption("b", "benchmark", Arg::Required,
"-b/--benchmark \tBenchmark label (default: \"none\")\n");
CommandLine::option_handle IMPORTER =
cmd.addOption("i", "importer", Arg::Required,
"-i/--importer \tWhich import method to use (default: BasicImporter)");
CommandLine::option_handle IMPORTER_ARGS =
cmd.addOption("I", "importer-args", Arg::Required,
"-I/--importer-args \tWhich import method to use (default: "")");
CommandLine::option_handle ELF_FILE =
cmd.addOption("e", "elf-file", Arg::Required,
"-e/--elf-file \tELF File (default: UNSET)");
CommandLine::option_handle MEMORYMAP =
cmd.addOption("m", "memorymap", Arg::Required,
"-m/--memorymap \tMemory map to intersect with trace (may be used more than once; default: UNSET)");
// variant 1: care (synthetic Rs)
// variant 2: don't care (synthetic Ws)
CommandLine::option_handle FAULTSPACE_RIGHTMARGIN =
cmd.addOption("", "faultspace-rightmargin", Arg::Required,
"--faultspace-rightmargin \tMemory access type (R or W) to "
"complete fault space at the right margin "
"(default: W -- don't care)");
// (don't) cutoff at first R
// (don't) cutoff at last R
//CommandLine::option_handle FAULTSPACE_CUTOFF =
// cmd.addOption("", "faultspace-cutoff-end", Arg::Required,
// "--faultspace-cutoff-end \tCut off fault space end (no, lastr) "
// "(default: no)");
if (!cmd.parse()) {
@ -129,14 +155,36 @@ int main(int argc, char *argv[]) {
if (cmd[ELF_FILE].count() > 0) {
elf_file = new ElfReader(cmd[ELF_FILE].first()->arg);
}
importer->set_elf_file(elf_file);
if (cmd[MEMORYMAP].count() > 0) {
memorymap = new MemoryMap();
for (option::Option *o = cmd[MEMORYMAP]; o; o = o->next()) {
if (!memorymap->readFromFile(o->arg)) {
LOG << "failed to load memorymap " << o->arg << endl;
}
}
}
importer->set_memorymap(memorymap);
if (cmd[FAULTSPACE_RIGHTMARGIN].count() > 0) {
std::string rightmargin(cmd[FAULTSPACE_RIGHTMARGIN].first()->arg);
if (rightmargin == "W") {
importer->set_faultspace_rightmargin('W');
} else if (rightmargin == "R") {
importer->set_faultspace_rightmargin('R');
} else {
LOG << "unknown memory access type '" << rightmargin << "', using default" << endl;
importer->set_faultspace_rightmargin('W');
}
} else {
importer->set_faultspace_rightmargin('W');
}
if (!importer->init(variant, benchmark, db)) {
LOG << "importer->init() failed" << endl;
exit(-1);
}
importer->set_elf_file(elf_file);
////////////////////////////////////////////////////////////////
// Do the actual import