summaryrefslogtreecommitdiffstats
path: root/main.cxx
diff options
context:
space:
mode:
authorfche <fche>2005-07-07 18:43:36 +0000
committerfche <fche>2005-07-07 18:43:36 +0000
commit0d49d7bcea3e40b3981918817aee8699c7ba0084 (patch)
tree655be88752b13995444cc26841d2704ee1ef98c2 /main.cxx
parent3521501aeb982e103bf867afa0a7b4b4c3f2ac25 (diff)
downloadsystemtap-steved-0d49d7bcea3e40b3981918817aee8699c7ba0084.tar.gz
systemtap-steved-0d49d7bcea3e40b3981918817aee8699c7ba0084.tar.xz
systemtap-steved-0d49d7bcea3e40b3981918817aee8699c7ba0084.zip
2005-07-07 Frank Ch. Eigler <fche@redhat.com>
* Makefile.am (dist): Package up the source tree, including testsuite and runtime. * main.cxx: Use clog instead of cerr for logging messages. * buildrun.cxx: Ditto. (compile_pass): Add -Iruntime/user for test mode. * translate.cxx (*): Commonalize test/real mode output. * Makefile.in: Regenerated.
Diffstat (limited to 'main.cxx')
-rw-r--r--main.cxx64
1 files changed, 36 insertions, 28 deletions
diff --git a/main.cxx b/main.cxx
index ca2f4dd3..5b6159c8 100644
--- a/main.cxx
+++ b/main.cxx
@@ -31,7 +31,7 @@ using namespace std;
void
usage (systemtap_session& s)
{
- cerr
+ clog
<< "SystemTap translator "
<< "(version " << VERSION << " built " << DATE << ")" << endl
<< "Copyright (C) 2005 Red Hat, Inc." << endl
@@ -55,12 +55,12 @@ usage (systemtap_session& s)
<< " (parse, elaborate, translate, compile, run)" << endl
<< " -I DIR look in DIR for additional .stp script files";
if (s.include_path.size() == 0)
- cerr << endl;
+ clog << endl;
else
- cerr << ", instead of" << endl;
+ clog << ", instead of" << endl;
for (unsigned i=0; i<s.include_path.size(); i++)
- cerr << " " << s.include_path[i] << endl;
- cerr
+ clog << " " << s.include_path[i] << endl;
+ clog
<< " -R DIR look in DIR for runtime, instead of "
<< s.runtime_path
<< endl
@@ -207,6 +207,9 @@ main (int argc, char * const argv [])
}
else
s.tmpdir = tmpdir;
+
+ if (s.verbose)
+ clog << "Created temporary directory \"" << s.tmpdir << "\"" << endl;
}
@@ -260,10 +263,14 @@ main (int argc, char * const argv [])
}
}
+ if (s.verbose) clog << "Pass 1: parsed user script and "
+ << s.library_files.size()
+ << " library script(s)." << endl;
+
+ if (rc || s.last_pass == 1) goto cleanup;
// PASS 2: ELABORATION
- if (rc == 0 && s.last_pass > 1)
- rc = semantic_pass (s);
+ rc = semantic_pass (s);
if (rc == 0 && s.last_pass == 2)
{
@@ -313,51 +320,52 @@ main (int argc, char * const argv [])
}
}
+ if (s.verbose) clog << "Pass 2: analyzed user script. "
+ << s.probes.size() << " probe(s), "
+ << s.functions.size() << " function(s), "
+ << s.globals.size() << " global(s)." << endl;
+
+ if (rc || s.last_pass == 2) goto cleanup;
// PASS 3: TRANSLATION
- if (rc == 0 && s.last_pass > 2)
- {
- s.translated_source = string(s.tmpdir) + "/" + s.module_name + ".c";
- rc = translate_pass (s);
- }
+ s.translated_source = string(s.tmpdir) + "/" + s.module_name + ".c";
+ rc = translate_pass (s);
if (rc == 0 && s.last_pass == 3)
{
ifstream i (s.translated_source.c_str());
cout << i.rdbuf();
}
+
+ if (s.verbose) clog << "Pass 3: translated to C into \""
+ << s.translated_source
+ << "\"" << endl;
+
+ if (rc || s.last_pass == 3) goto cleanup;
// PASS 4: COMPILATION
- if (rc == 0 && s.last_pass > 3)
- {
- rc = compile_pass (s);
- }
+ rc = compile_pass (s);
- // PASS 5: RUN
- if (rc == 0 && s.last_pass > 4)
- {
- rc = run_pass (s);
- }
+ if (rc || s.last_pass == 4) goto cleanup;
- // Pull out saved output
- if (output_file != "-")
- s.op = new translator_output (output_file);
- else
- s.op = new translator_output (cout);
+ // PASS 5: RUN
+ rc = run_pass (s);
+ // if (rc) goto cleanup;
+ cleanup:
// Clean up temporary directory. Obviously, be careful with this.
if (s.tmpdir == "")
; // do nothing
else
{
if (s.keep_tmpdir)
- cerr << "Keeping temporary directory \"" << s.tmpdir << "\"" << endl;
+ clog << "Keeping temporary directory \"" << s.tmpdir << "\"" << endl;
else
{
string cleanupcmd = "/bin/rm -rf ";
cleanupcmd += s.tmpdir;
- if (s.verbose) cerr << "Running " << cleanupcmd << endl;
+ if (s.verbose) clog << "Running " << cleanupcmd << endl;
(void) system (cleanupcmd.c_str());
}
}