+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.
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
# 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
|| 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 \
.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 \
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
-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
+
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;
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;
}
void
usage (systemtap_session& s)
{
- cerr
+ clog
<< "SystemTap translator "
<< "(version " << VERSION << " built " << DATE << ")" << endl
<< "Copyright (C) 2005 Red Hat, Inc." << endl
<< " (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
}
else
s.tmpdir = tmpdir;
+
+ if (s.verbose)
+ clog << "Created temporary directory \"" << s.tmpdir << "\"" << endl;
}
}
}
+ 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)
{
}
}
+ 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());
}
}
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";
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 ();