summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--Makefile.am4
-rw-r--r--Makefile.in8
-rw-r--r--README32
-rw-r--r--buildrun.cxx11
-rw-r--r--main.cxx64
-rw-r--r--translate.cxx12
7 files changed, 84 insertions, 57 deletions
diff --git a/ChangeLog b/ChangeLog
index 88cb0ca1..79df0253 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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.
+
2005-07-05 Graydon Hoare <graydon@redhat.com>
* elaborate.{h,cxx}: Revert previous changes.
diff --git a/Makefile.am b/Makefile.am
index f56f71a0..cc61811b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,6 +21,10 @@ stapdatadir = @datadir@/systemtap
DEFPATH="\".$(PATH_SEPARATOR)$(stapdatadir)\""
DEFS= -DDEFPATH=$(DEFPATH) -DHAVE_CONFIG_H
+EXTRA_DIST=testsuite runtime
+dist-hook:
+ find $(distdir)/testsuite -name CVS -o -name '*~' -o -name '.#*' | xargs rm -rf
+
p=$(srcdir)/testsuite/parse
s=$(srcdir)/testsuite/sem
t=$(srcdir)/testsuite/trans
diff --git a/Makefile.in b/Makefile.in
index 26edb195..b00e4297 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -187,6 +187,7 @@ stapdatadir = @datadir@/systemtap
# stuff for compiling gawk/pgawk
DEFPATH = "\".$(PATH_SEPARATOR)$(stapdatadir)\""
+EXTRA_DIST = testsuite runtime
p = $(srcdir)/testsuite/parse
s = $(srcdir)/testsuite/sem
t = $(srcdir)/testsuite/trans
@@ -463,6 +464,9 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$(top_distdir)" distdir="$(distdir)" \
+ dist-hook
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
@@ -648,7 +652,7 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am
.PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \
clean clean-binPROGRAMS clean-generic clean-local \
clean-noinstPROGRAMS ctags dist dist-all dist-bzip2 dist-gzip \
- dist-shar dist-tarZ dist-zip distcheck distclean \
+ dist-hook dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
@@ -660,6 +664,8 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am
tags uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-info-am
+dist-hook:
+ find $(distdir)/testsuite -name CVS -o -name '*~' -o -name '.#*' | xargs rm -rf
gcov:
@$(MAKE) clean CXXFLAGS="-g -fprofile-arcs -ftest-coverage" all check
diff --git a/README b/README
index bf4b67fa..93d3acb3 100644
--- a/README
+++ b/README
@@ -1,15 +1,17 @@
-systemtap prototype #3.3
-
-- demonstrates parsing of hypothetical systemtap script
- language using hand-written simpe LL(1) recursive-descent parser
- and similar little lexer: parse.cxx, parse.h
-- semantic analysis in elaborate.cxx; translation in translate.cxx;
- driven from main.cxx
-- examples under testsuite/*
-- "probe", "global", "function" top-level constructs parsed
-- some tapset library auto-inclusion supported
-- use autotools-style configure; make; make check
-- to see parse tree: stap -p1 -e 'SCRIPT FRAGMENT'
-- to see semantic/type analysis results: stap -p2 -e 'SCRIPT FRAGMENT'
-- to see translation of constructs: stap -e 'SCRIPT FRAGMENT';
- try compiling result with "gcc -c"!
+systemtap: a linux trace/probe tool
+
+Visit the project web site at <http://sources.redhat.com/systemtap>,
+for documentation and mailing lists for developers and users.
+
+This is free software.
+See the COPYING file for redistribution/modification terms.
+See the INSTALL file for generic build instructions.
+
+Prerequisites:
+
+- linux kernel 2.6.11+ with IBM kprobes
+- kernel module build environment
+- C compiler
+- elfutils with libdwfl
+- root privileges
+
diff --git a/buildrun.cxx b/buildrun.cxx
index af22f1c8..151c5ecd 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -24,6 +24,8 @@ compile_pass (systemtap_session& s)
string makefile_nm = s.tmpdir + "/Makefile";
ofstream o (makefile_nm.c_str());
o << "CFLAGS += -Werror" << endl;
+ if (s.test_mode)
+ o << "CFLAGS += -I \"" << s.runtime_path << "/user\"" << endl;
o << "CFLAGS += -I \"" << s.runtime_path << "\"" << endl;
o << "CFLAGS += -I \"" << s.runtime_path << "/relayfs\"" << endl;
o << "obj-m := " << s.module_name << ".o" << endl;
@@ -36,9 +38,14 @@ compile_pass (systemtap_session& s)
if (! s.verbose) make_cmd += " -s";
make_cmd += string(" M=\"") + s.tmpdir + string("\" modules");
- if (s.verbose) cerr << "Running " << make_cmd << endl;
+ if (s.verbose) clog << "Running " << make_cmd << endl;
int rc = system (make_cmd.c_str());
- if (s.verbose) cerr << "rc=" << rc << endl;
+
+
+ if (s.verbose) clog << "Pass 4: compiled into \""
+ << s.module_name << ".ko"
+ << "\"" << endl;
+
return rc;
}
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());
}
}
diff --git a/translate.cxx b/translate.cxx
index cb25044b..125c5b2b 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -177,12 +177,8 @@ struct c_tmpcounter: public traversing_visitor
void
c_unparser::emit_common_header ()
{
- o->newline() << "#if TEST_MODE";
- o->newline() << "#include <string.h>";
- o->newline() << "#else";
o->newline() << "#include <linux/string.h>";
// XXX: tapsets.cxx should be able to add additional definitions
- o->newline() << "#endif";
o->newline() << "#define NR_CPU 1";
o->newline() << "#define MAXNESTING 30";
@@ -1445,14 +1441,8 @@ translate_pass (systemtap_session& s)
try
{
- s.op->line() << "#define TEST_MODE " << (s.test_mode ? 1 : 0)
- << endl;
-
- // XXX: until the runtime can handle user-level tests properly
- s.op->newline() << "#if ! TEST_MODE";
- s.op->newline() << "#define STP_NETLINK_ONLY"; // XXX
+ s.op->line() << "#define TEST_MODE " << (s.test_mode ? 1 : 0) << endl;
s.op->newline() << "#include \"runtime.h\"";
- s.op->newline() << "#endif" << endl;
s.up->emit_common_header ();