Commit 922963a4 authored by Jason Hiser's avatar Jason Hiser 🚜

Merge branch 'master' of git.zephyr-software.com:opensrc/irdb-cookbook-examples

parents 7c63f999 f92b0126
Pipeline #2578 passed with stages
in 7 minutes and 47 seconds
......@@ -33,11 +33,11 @@ using namespace InitStack;
void usage(char* p_name)
{
cerr<<"Usage: "<<p_name<<" <variant_id>\n";
cerr<<"\t[--functions <file> | -f <file>] Read in the functions to auto-initialize "<<endl;
cerr<<"\t[--initvalue <value> | -i <value>] Specify stack initialization value (default=0)"<<endl;
cerr<<"\t[--verbose | -v] Verbose mode "<<endl;
cerr<<"\t[--help,--usage,-?,-h] Display this message "<<endl;
cerr << "Usage: " << p_name << " <variant_id>\n";
cerr << "\t[--functions <file> | -f <file>] Read in the functions to auto-initialize " << endl;
cerr << "\t[--initvalue <value> | -i <value>] Specify stack initialization value (default=0)" << endl;
cerr << "\t[--verbose | -v] Verbose mode " << endl;
cerr << "\t[--help,--usage,-?,-h] Display this message " << endl;
}
......@@ -79,11 +79,11 @@ int main(int argc, char **argv)
{
case 'f':
funcs_filename=optarg;
cout<<"Reading file with function specifiers: "<<funcs_filename<<endl;
cout << "Reading file with function specifiers: " << funcs_filename << endl;
break;
case 'i':
init_value=strtoll(optarg, NULL, 0);
cout<<" Stack initialization value: "<<hex<<init_value<<endl;
cout << " Stack initialization value: " << hex << init_value << endl;
break;
case 'v':
verbose=true;
......@@ -108,6 +108,7 @@ int main(int argc, char **argv)
// create and read the main file's IR from the datatbase
auto this_file = pidp->getMainFile();
auto url = this_file->getURL();
// declare for later so we can return the right value
auto success=false;
......@@ -115,13 +116,14 @@ int main(int argc, char **argv)
// now try to load the IR and execute a transform
try
{
// Create and download the file's IR.
auto firp = FileIR_t::factory(pidp.get(), this_file);
// sanity
assert(firp && pidp);
// log
cout<<"Transforming "<<this_file->getURL()<<endl;
cout << "Transforming " << this_file->getURL() << endl;
// create and invoke the transform
InitStack_t is(firp.get(), funcs_filename, init_value, verbose);
......@@ -130,24 +132,24 @@ int main(int argc, char **argv)
// conditionally write the IR back to the database on success
if (success)
{
cout<<"Writing changes for "<<this_file->getURL()<<endl;
cout << "Writing changes for " << url << endl;
firp->writeToDB();
pqxx_interface->commit();
}
else
{
cout<<"Skipping write back on failure. "<<this_file->getURL()<<endl;
cout << "Skipping write back on failure. " << url << endl;
}
}
catch (DatabaseError_t db_error)
{
// log any databse errors that might come up in the transform process
cerr << program_name << ": Unexpected database error: " << db_error << "file url: " << this_file->getURL() << endl;
cerr << program_name << ": Unexpected database error: " << db_error << "file url: " << url << endl;
}
catch (...)
{
// log any other errors
cerr << program_name << ": Unexpected error file url: " << this_file->getURL() << endl;
cerr << program_name << ": Unexpected error file url: " << url << endl;
}
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment