formatting, typos, comments, details
Change-Id: Iae5f1acb653a694622e9ac2bad93efcfca588f3a
This commit is contained in:
@ -75,16 +75,16 @@ bool ElfImporter::import_with_objdump(const std::string &binary) {
|
||||
LOG << "Executing: " << command << std::endl;
|
||||
redi::ipstream objdump( command );
|
||||
std::string str;
|
||||
while(std::getline(objdump, str)){
|
||||
while (std::getline(objdump, str)) {
|
||||
if (!evaluate_objdump_line(str)) {
|
||||
objdump.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
objdump.close();
|
||||
if(objdump.rdbuf()->exited()){
|
||||
if (objdump.rdbuf()->exited()) {
|
||||
int ex = objdump.rdbuf()->status();
|
||||
if(ex != 0){
|
||||
if (ex != 0) {
|
||||
clear_database();
|
||||
LOG << "Could not disassemble!" << std::endl;
|
||||
return false;
|
||||
@ -99,11 +99,11 @@ bool ElfImporter::evaluate_objdump_line(const std::string& line){
|
||||
#ifndef __puma
|
||||
// Only read in real code lines:
|
||||
// Code lines start with a leading whitespace! (hopefully in each objdump implementation!)
|
||||
if(line.size() > 0 && isspace(line[0])){
|
||||
if (line.size() > 0 && isspace(line[0])) {
|
||||
// a line looks like: 800156c:\tdd14 \tble.n 8001598 <_ZN2hw3hal7T32Term8PutBlockEPci+0x30>
|
||||
static boost::regex expr("\\s+([A-Fa-f0-9]+):((?:\\s+[A-Fa-f0-9]{2})+)\\s+(.+?)(;.*)?$");
|
||||
boost::smatch res;
|
||||
if(boost::regex_search(line, res, expr)){
|
||||
if (boost::regex_search(line, res, expr)) {
|
||||
std::string address = res[1];
|
||||
std::stringstream ss;
|
||||
ss << std::hex << address;
|
||||
|
||||
@ -88,7 +88,7 @@ bool Importer::copy_to_database(fail::ProtoIStream &ps) {
|
||||
curtime += ev.time_delta();
|
||||
}
|
||||
|
||||
// instruction events just get counted
|
||||
// instruction event?
|
||||
if (!ev.has_memaddr()) {
|
||||
// new instruction
|
||||
// sanity check for overflow
|
||||
|
||||
@ -146,7 +146,7 @@ int main(int argc, char *argv[]) {
|
||||
importer = new ElfImporter();
|
||||
#endif
|
||||
} else {
|
||||
LOG << "Unkown import method: " << imp << endl;
|
||||
LOG << "Unknown import method: " << imp << endl;
|
||||
exit(-1);
|
||||
}
|
||||
LOG << "Using " << imp << endl;
|
||||
|
||||
@ -20,7 +20,7 @@ bool BasicPruner::prune_all() {
|
||||
" data_address, width, " << m_method_id << " "
|
||||
"FROM trace "
|
||||
"WHERE variant_id IN (" << m_variant_id_query << ") AND accesstype = 'R'";
|
||||
if (!db->query(ss.str().c_str())) return false;
|
||||
if (!db->query(ss.str().c_str())) return false;
|
||||
ss.str("");
|
||||
|
||||
int rows = db->affected_rows();
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
class BasicPruner : public Pruner {
|
||||
bool use_instr1;
|
||||
public:
|
||||
BasicPruner(bool use_instr1 = false) : Pruner(), use_instr1(use_instr1) {}
|
||||
BasicPruner(bool use_instr1 = false) : use_instr1(use_instr1) {}
|
||||
virtual std::string method_name() { return std::string("basic") + (use_instr1 ? "-left" : ""); }
|
||||
virtual bool prune_all();
|
||||
};
|
||||
|
||||
@ -17,8 +17,9 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Manually fill the command line option parser
|
||||
CommandLine &cmd = CommandLine::Inst();
|
||||
for (int i = 1; i < argc; ++i)
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
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 \tPrint usage and exit");
|
||||
@ -44,23 +45,23 @@ int main(int argc, char *argv[]) {
|
||||
cmd.addOption("", "no-delete", Arg::None,
|
||||
"--no-delete \tAssume there are no DB entries for this variant/benchmark, don't issue a DELETE");
|
||||
|
||||
if(!cmd.parse()) {
|
||||
if (!cmd.parse()) {
|
||||
std::cerr << "Error parsing arguments." << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Pruner *pruner;
|
||||
if (cmd[PRUNER].count() > 0) {
|
||||
if (cmd[PRUNER]) {
|
||||
std::string imp(cmd[PRUNER].first()->arg);
|
||||
if (imp == "basic") {
|
||||
if (imp == "BasicPruner" || imp == "basic") {
|
||||
LOG << "Using BasicPruner" << endl;
|
||||
pruner = new BasicPruner();
|
||||
} else if (imp == "basic-left") {
|
||||
} else if (imp == "BasicPrunerLeft" || imp == "basic-left") {
|
||||
LOG << "Using BasicPruner (use left border, instr1)" << endl;
|
||||
pruner = new BasicPruner(true);
|
||||
|
||||
} else {
|
||||
LOG << "Unkown import method: " << imp << endl;
|
||||
LOG << "Unknown pruning method: " << imp << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -77,7 +78,7 @@ int main(int argc, char *argv[]) {
|
||||
Database *db = Database::cmdline_connect();
|
||||
|
||||
std::vector<std::string> variants, benchmarks, variants_exclude, benchmarks_exclude;
|
||||
if (cmd[VARIANT].count() > 0) {
|
||||
if (cmd[VARIANT]) {
|
||||
for (option::Option *o = cmd[VARIANT]; o; o = o->next()) {
|
||||
variants.push_back(std::string(o->arg));
|
||||
}
|
||||
@ -85,13 +86,13 @@ int main(int argc, char *argv[]) {
|
||||
variants.push_back(std::string("none"));
|
||||
}
|
||||
|
||||
if (cmd[VARIANT_EXCLUDE].count() > 0) {
|
||||
if (cmd[VARIANT_EXCLUDE]) {
|
||||
for (option::Option *o = cmd[VARIANT_EXCLUDE]; o; o = o->next()) {
|
||||
variants_exclude.push_back(std::string(o->arg));
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd[BENCHMARK].count() > 0) {
|
||||
if (cmd[BENCHMARK]) {
|
||||
for (option::Option *o = cmd[BENCHMARK]; o; o = o->next()) {
|
||||
benchmarks.push_back(std::string(o->arg));
|
||||
}
|
||||
@ -99,7 +100,7 @@ int main(int argc, char *argv[]) {
|
||||
benchmarks.push_back(std::string("none"));
|
||||
}
|
||||
|
||||
if (cmd[BENCHMARK_EXCLUDE].count() > 0) {
|
||||
if (cmd[BENCHMARK_EXCLUDE]) {
|
||||
for (option::Option *o = cmd[BENCHMARK_EXCLUDE]; o; o = o->next()) {
|
||||
benchmarks_exclude.push_back(std::string(o->arg));
|
||||
}
|
||||
@ -118,7 +119,7 @@ int main(int argc, char *argv[]) {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (cmd[NO_DELETE].count() == 0 && !pruner->clear_database()) {
|
||||
if (!cmd[NO_DELETE] && !pruner->clear_database()) {
|
||||
LOG << "clear_database() failed" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user