From c0f9d4b0f1e4d1d49d238e4b2546de46f51166eb Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 10 Apr 2008 13:09:19 -0400 Subject: PR6393: git version tagging at build time 2008-04-10 Frank Ch. Eigler PR 6393. * git_version.sh: New file, copied from radeonhd. * configure.ac: No longer generate $builddir/SNAPSHOT. * Makefile.am: Generate $builddir/git_version.h. (EXTRA_DIST): Add git_version.h and git_version.sh. * main.cxx (version): Print generated GIT_MESSAGE therefrom. * Makefile.in, configure: Regenerated. --- main.cxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'main.cxx') diff --git a/main.cxx b/main.cxx index 4364f664..e90f9f12 100644 --- a/main.cxx +++ b/main.cxx @@ -19,6 +19,7 @@ #include "cache.h" #include "util.h" #include "coveragedb.h" +#include "git_version.h" #include #include @@ -47,6 +48,7 @@ version () clog << "SystemTap translator/driver " << "(version " << VERSION << "/" << dwfl_version (NULL) + << " " << GIT_MESSAGE << " built " << DATE << ")" << endl << "Copyright (C) 2005-2008 Red Hat, Inc. and others" << endl << "This is free software; see the source for copying conditions." << endl; -- cgit From 2881ab63dced89cf57ccf5036eca0a2e6da8a00f Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 10 Apr 2008 13:36:34 -0400 Subject: PR6393: don't bother print build (configure) date any more, with reliable git ids --- main.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'main.cxx') diff --git a/main.cxx b/main.cxx index e90f9f12..98c1711b 100644 --- a/main.cxx +++ b/main.cxx @@ -48,8 +48,7 @@ version () clog << "SystemTap translator/driver " << "(version " << VERSION << "/" << dwfl_version (NULL) - << " " << GIT_MESSAGE - << " built " << DATE << ")" << endl + << " " << GIT_MESSAGE << ")" << endl << "Copyright (C) 2005-2008 Red Hat, Inc. and others" << endl << "This is free software; see the source for copying conditions." << endl; } -- cgit From 16442b904ea51eedfbef36edc9791f5904d81099 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 10 Apr 2008 15:38:18 -0400 Subject: PR2949: listings mode (stap -l PROBE) 2008-04-10 Frank Ch. Eigler PR 2949. * session.h (listing_mode): New field. * main.cxx (main): Test it. Enjoy it. (usage): Document it. * stap.1.in, stapex.5.in: Ditto. * elaborate.cxx (print_error): Disable error messages in listing mode. 2008-04-10 Frank Ch. Eigler PR 2949 * systemtap.base/cmd_parse.exp: Add "-l" listing test. --- main.cxx | 188 ++++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 126 insertions(+), 62 deletions(-) (limited to 'main.cxx') diff --git a/main.cxx b/main.cxx index 98c1711b..03021d8c 100644 --- a/main.cxx +++ b/main.cxx @@ -65,9 +65,11 @@ usage (systemtap_session& s, int exitcode) << endl << " or: stap [options] -e SCRIPT Run given script." << endl + << " or: stap [options] -l PROBE List matching probes." + << endl << endl << "Options:" << endl - << " -- no more options after this" << endl + << " -- end of translator options, script options follow" << endl << " -v increase verbosity [" << s.verbose << "]" << endl << " -h show help" << endl << " -V show version" << endl @@ -117,75 +119,118 @@ usage (systemtap_session& s, int exitcode) static void printscript(systemtap_session& s, ostream& o) { - if (s.embeds.size() > 0) - o << "# global embedded code" << endl; - for (unsigned i=0; iprint (o); - o << endl; - } + // We go through some heroic measures to produce clean output. + set seen; - if (s.globals.size() > 0) - o << "# globals" << endl; - for (unsigned i=0; iprintsig (o); - if (s.verbose && v->init) + for (unsigned i=0; iprintsig(cerr); cerr << endl; } + #endif + + stringstream tmps; + second->printsig (tmps); + string tmp = tmps.str(); + // trim anything other than the "head" of the probe point signature: + // alias1 *CUT* = exp1, exp2 + // probe1 *CUT* /* pc=0xdeadbeef */ /* <- foo */ + string::size_type space_pos = tmp.find(' '); + assert (space_pos != string::npos); + string pp = tmp.substr (0, space_pos); + + // Now duplicate-eliminate. An alias may have expanded to + // several actual derived probe points, but we only want to + // print the alias head name once. + if (seen.find (pp) == seen.end()) + { + o << pp << endl; + seen.insert (pp); + } } - o << endl; } - - if (s.functions.size() > 0) - o << "# functions" << endl; - for (unsigned i=0; iprintsig (o); - o << endl; - if (f->locals.size() > 0) - o << " # locals" << endl; - for (unsigned j=0; jlocals.size(); j++) + if (s.embeds.size() > 0) + o << "# global embedded code" << endl; + for (unsigned i=0; ilocals[j]; - o << " "; - v->printsig (o); - o << endl; - } - if (s.verbose) + embeddedcode* ec = s.embeds[i]; + ec->print (o); + o << endl; + } + + if (s.globals.size() > 0) + o << "# globals" << endl; + for (unsigned i=0; ibody->print (o); - o << endl; - } - } - - if (s.probes.size() > 0) - o << "# probes" << endl; - for (unsigned i=0; iprintsig (o); - o << endl; - if (p->locals.size() > 0) - o << " # locals" << endl; - for (unsigned j=0; jlocals.size(); j++) + vardecl* v = s.globals[i]; + v->printsig (o); + if (s.verbose && v->init) + { + o << " = "; + v->init->print(o); + } + o << endl; + } + + if (s.functions.size() > 0) + o << "# functions" << endl; + for (unsigned i=0; ilocals[j]; - o << " "; - v->printsig (o); - o << endl; - } - if (s.verbose) + functiondecl* f = s.functions[i]; + f->printsig (o); + o << endl; + if (f->locals.size() > 0) + o << " # locals" << endl; + for (unsigned j=0; jlocals.size(); j++) + { + vardecl* v = f->locals[j]; + o << " "; + v->printsig (o); + o << endl; + } + if (s.verbose) + { + f->body->print (o); + o << endl; + } + } + + if (s.probes.size() > 0) + o << "# probes" << endl; + for (unsigned i=0; ibody->print (o); - o << endl; - } + derived_probe* p = s.probes[i]; + p->printsig (o); + o << endl; + if (p->locals.size() > 0) + o << " # locals" << endl; + for (unsigned j=0; jlocals.size(); j++) + { + vardecl* v = p->locals[j]; + o << " "; + v->printsig (o); + o << endl; + } + if (s.verbose) + { + p->body->print (o); + o << endl; + } + } + } } -} int pending_interrupts; @@ -225,6 +270,7 @@ main (int argc, char * const argv []) s.bulk_mode = false; s.unoptimized = false; s.suppress_warnings = false; + s.listing_mode = false; #ifdef ENABLE_PROLOGUES s.prologue_searching = true; @@ -296,7 +342,7 @@ main (int argc, char * const argv []) while (true) { // NB: also see find_hash(), usage(), switch stmt below, stap.1 man page - int grc = getopt (argc, argv, "hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqw"); + int grc = getopt (argc, argv, "hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqwl:"); if (grc < 0) break; switch (grc) @@ -322,6 +368,11 @@ main (int argc, char * const argv []) break; case 'p': + if (s.listing_mode) + { + cerr << "Listing (-l) mode implies pass 2." << endl; + usage (s, 1); + } s.last_pass = atoi (optarg); if (s.last_pass < 1 || s.last_pass > 5) { @@ -454,6 +505,19 @@ main (int argc, char * const argv []) usage (s, 0); break; + case 'l': + s.listing_mode = true; + s.last_pass = 2; + if (have_script) + { + cerr << "Only one script can be given on the command line." + << endl; + usage (s, 1); + } + cmdline_script = string("probe ") + string(optarg) + " {}"; + have_script = true; + break; + default: usage (s, 1); break; @@ -719,7 +783,7 @@ main (int argc, char * const argv []) // PASS 2: ELABORATION rc = semantic_pass (s); - if (rc == 0 && s.last_pass == 2) + if (s.listing_mode || (rc == 0 && s.last_pass == 2)) printscript(s, cout); times (& tms_after); @@ -768,7 +832,7 @@ main (int argc, char * const argv []) } } - if (rc || s.last_pass == 2 || pending_interrupts) goto cleanup; + if (rc || s.listing_mode || s.last_pass == 2 || pending_interrupts) goto cleanup; // PASS 3: TRANSLATION -- cgit