From 0d49d7bcea3e40b3981918817aee8699c7ba0084 Mon Sep 17 00:00:00 2001 From: fche Date: Thu, 7 Jul 2005 18:43:36 +0000 Subject: [PATCH] 2005-07-07 Frank Ch. Eigler * 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. --- ChangeLog | 10 ++++++++ Makefile.am | 4 ++++ Makefile.in | 8 ++++++- README | 32 ++++++++++++++------------ buildrun.cxx | 11 +++++++-- main.cxx | 64 +++++++++++++++++++++++++++++---------------------- translate.cxx | 12 +--------- 7 files changed, 84 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88cb0ca13..79df02539 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-07-07 Frank Ch. Eigler + + * 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 * elaborate.{h,cxx}: Revert previous changes. diff --git a/Makefile.am b/Makefile.am index f56f71a01..cc61811ba 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 26edb195d..b00e42978 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 bf4b67fa9..93d3acb3f 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 , +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 af22f1c8a..151c5ecdf 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 ca2f4dd3e..5b6159c82 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 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 cb25044ba..125c5b2be 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 "; - o->newline() << "#else"; o->newline() << "#include "; // 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 (); -- 2.43.5