misc cleanups
This change touches several subsystems, tools and experiments (sal, util, cmake, import-trace, generic-tracing, nanojpeg), and changes details not worth separate commits. Change-Id: Icd1d664d1be5cfc2212dbf77801c271183214d08
This commit is contained in:
@ -49,8 +49,7 @@ ProtoIStream openProtoStream(std::string input_file) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::string trace_file, username, hostname, database, benchmark;
|
||||
std::string variant;
|
||||
std::string trace_file, variant, benchmark;
|
||||
ElfReader *elf_file = 0;
|
||||
MemoryMap *memorymap = 0;
|
||||
|
||||
@ -108,7 +107,7 @@ int main(int argc, char *argv[]) {
|
||||
CommandLine::option_handle ENABLE_SANITYCHECKS =
|
||||
cmd.addOption("", "enable-sanitychecks", Arg::None,
|
||||
"--enable-sanitychecks \tEnable sanity checks "
|
||||
"(in case something looks fishy)"
|
||||
"(in case something looks fishy) "
|
||||
"(default: disabled)");
|
||||
|
||||
if (!cmd.parse()) {
|
||||
@ -118,28 +117,28 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
Importer *importer;
|
||||
|
||||
if (cmd[IMPORTER].count() > 0) {
|
||||
if (cmd[IMPORTER]) {
|
||||
std::string imp(cmd[IMPORTER].first()->arg);
|
||||
if (imp == "BasicImporter" || imp == "MemoryImporter" || imp == "memory" || imp == "mem") {
|
||||
LOG << "Using MemoryImporter" << endl;
|
||||
imp = "MemoryImporter";
|
||||
importer = new MemoryImporter();
|
||||
#ifdef BUILD_LLVM_DISASSEMBLER
|
||||
} else if (imp == "InstructionImporter" || imp == "code") {
|
||||
LOG << "Using InstructionImporter" << endl;
|
||||
imp = "InstructionImporter";
|
||||
importer = new InstructionImporter();
|
||||
|
||||
} else if (imp == "RegisterImporter" || imp == "regs") {
|
||||
LOG << "Using RegisterImporter" << endl;
|
||||
imp = "RegisterImporter";
|
||||
importer = new RegisterImporter();
|
||||
|
||||
} else if (imp == "RandomJumpImporter") {
|
||||
LOG << "Using RandomJumpImporter" << endl;
|
||||
importer = new RandomJumpImporter();
|
||||
#endif
|
||||
} else {
|
||||
LOG << "Unkown import method: " << imp << endl;
|
||||
exit(-1);
|
||||
}
|
||||
LOG << "Using " << imp << endl;
|
||||
|
||||
} else {
|
||||
LOG << "Using MemoryImporter" << endl;
|
||||
@ -160,30 +159,33 @@ int main(int argc, char *argv[]) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (cmd[TRACE_FILE].count() > 0)
|
||||
if (cmd[TRACE_FILE]) {
|
||||
trace_file = std::string(cmd[TRACE_FILE].first()->arg);
|
||||
else
|
||||
} else {
|
||||
trace_file = "trace.pb";
|
||||
}
|
||||
|
||||
ProtoIStream ps = openProtoStream(trace_file);
|
||||
Database *db = Database::cmdline_connect();
|
||||
|
||||
if (cmd[VARIANT].count() > 0)
|
||||
if (cmd[VARIANT]) {
|
||||
variant = std::string(cmd[VARIANT].first()->arg);
|
||||
else
|
||||
} else {
|
||||
variant = "none";
|
||||
}
|
||||
|
||||
if (cmd[BENCHMARK].count() > 0)
|
||||
if (cmd[BENCHMARK]) {
|
||||
benchmark = std::string(cmd[BENCHMARK].first()->arg);
|
||||
else
|
||||
} else {
|
||||
benchmark = "none";
|
||||
}
|
||||
|
||||
if (cmd[ELF_FILE].count() > 0) {
|
||||
if (cmd[ELF_FILE]) {
|
||||
elf_file = new ElfReader(cmd[ELF_FILE].first()->arg);
|
||||
}
|
||||
importer->set_elf(elf_file);
|
||||
|
||||
if (cmd[MEMORYMAP].count() > 0) {
|
||||
if (cmd[MEMORYMAP]) {
|
||||
memorymap = new MemoryMap();
|
||||
for (option::Option *o = cmd[MEMORYMAP]; o; o = o->next()) {
|
||||
if (!memorymap->readFromFile(o->arg)) {
|
||||
@ -193,7 +195,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
importer->set_memorymap(memorymap);
|
||||
|
||||
if (cmd[FAULTSPACE_RIGHTMARGIN].count() > 0) {
|
||||
if (cmd[FAULTSPACE_RIGHTMARGIN]) {
|
||||
std::string rightmargin(cmd[FAULTSPACE_RIGHTMARGIN].first()->arg);
|
||||
if (rightmargin == "W") {
|
||||
importer->set_faultspace_rightmargin('W');
|
||||
@ -207,12 +209,8 @@ int main(int argc, char *argv[]) {
|
||||
importer->set_faultspace_rightmargin('W');
|
||||
}
|
||||
|
||||
if (cmd[ENABLE_SANITYCHECKS].count() > 0) {
|
||||
importer->set_sanitychecks(true);
|
||||
}
|
||||
if (cmd[EXTENDED_TRACE].count() > 0) {
|
||||
importer->set_extended_trace(true);
|
||||
}
|
||||
importer->set_sanitychecks(cmd[ENABLE_SANITYCHECKS]);
|
||||
importer->set_extended_trace(cmd[EXTENDED_TRACE]);
|
||||
|
||||
if (!importer->init(variant, benchmark, db)) {
|
||||
LOG << "importer->init() failed" << endl;
|
||||
@ -228,7 +226,7 @@ int main(int argc, char *argv[]) {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (cmd[NO_DELETE].count() == 0 && !importer->clear_database()) {
|
||||
if (!cmd[NO_DELETE] && !importer->clear_database()) {
|
||||
LOG << "clear_database() failed" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user