diff options
author | fche <fche> | 2005-06-13 14:27:49 +0000 |
---|---|---|
committer | fche <fche> | 2005-06-13 14:27:49 +0000 |
commit | 56e12059fd1e281889b708b3d351092d9e3ed0be (patch) | |
tree | 0d058b68c61782ddc2988d677c925e6be0387425 | |
parent | bb2e3076ea20631d4606050550bc9664204f2c62 (diff) | |
download | systemtap-steved-56e12059fd1e281889b708b3d351092d9e3ed0be.tar.gz systemtap-steved-56e12059fd1e281889b708b3d351092d9e3ed0be.tar.xz systemtap-steved-56e12059fd1e281889b708b3d351092d9e3ed0be.zip |
2005-06-13 Frank Ch. Eigler <fche@redhat.com>
Start separating out translator-side probe point recognition.
* tapsets.cxx: New file.
(be_derived_probe): Support for begin/end probes.
(derive_probe): Ditto. Reject anything unrecognized.
* translator.cxx: Move out old code.
* Makefile.am: Add new source file.
* testsuite/semok/*: Switch to begin/end probes only.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | Makefile.in | 9 | ||||
-rw-r--r-- | main.cxx | 10 | ||||
-rw-r--r-- | tapsets.cxx | 117 | ||||
-rwxr-xr-x | testsuite/semok/eleven.stp | 4 | ||||
-rwxr-xr-x | testsuite/semok/five.stp | 2 | ||||
-rwxr-xr-x | testsuite/semok/four.stp | 2 | ||||
-rwxr-xr-x | testsuite/semok/one.stp | 2 | ||||
-rwxr-xr-x | testsuite/semok/seven.stp | 2 | ||||
-rwxr-xr-x | testsuite/semok/six.stp | 2 | ||||
-rwxr-xr-x | testsuite/semok/three.stp | 2 | ||||
-rwxr-xr-x | testsuite/semok/two.stp | 2 | ||||
-rw-r--r-- | translate.cxx | 107 |
14 files changed, 149 insertions, 125 deletions
@@ -1,3 +1,13 @@ +2005-06-13 Frank Ch. Eigler <fche@redhat.com> + + Start separating out translator-side probe point recognition. + * tapsets.cxx: New file. + (be_derived_probe): Support for begin/end probes. + (derive_probe): Ditto. Reject anything unrecognized. + * translator.cxx: Move out old code. + * Makefile.am: Add new source file. + * testsuite/semok/*: Switch to begin/end probes only. + 2005-06-08 Frank Ch. Eigler <fche@redhat.com> systemtap/916 diff --git a/Makefile.am b/Makefile.am index b2eb770c..40bcd440 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,8 @@ AM_MAKEFLAGS = 'CXXFLAGS=$(CXXFLAGS)' 'LDFLAGS=$(LDFLAGS)' bin_PROGRAMS = noinst_PROGRAMS = stap -stap_SOURCES = parse.cxx staptree.cxx elaborate.cxx translate.cxx main.cxx +stap_SOURCES = main.cxx \ + parse.cxx staptree.cxx elaborate.cxx translate.cxx tapsets.cxx AM_CXXFLAGS = -Wall # Get extra libs as needed diff --git a/Makefile.in b/Makefile.in index b738a971..479563d5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -57,8 +57,8 @@ CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) -am_stap_OBJECTS = parse.$(OBJEXT) staptree.$(OBJEXT) \ - elaborate.$(OBJEXT) translate.$(OBJEXT) main.$(OBJEXT) +am_stap_OBJECTS = main.$(OBJEXT) parse.$(OBJEXT) staptree.$(OBJEXT) \ + elaborate.$(OBJEXT) translate.$(OBJEXT) tapsets.$(OBJEXT) stap_OBJECTS = $(am_stap_OBJECTS) stap_LDADD = $(LDADD) stap_DEPENDENCIES = @@ -174,7 +174,9 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ AM_MAKEFLAGS = 'CXXFLAGS=$(CXXFLAGS)' 'LDFLAGS=$(LDFLAGS)' -stap_SOURCES = parse.cxx staptree.cxx elaborate.cxx translate.cxx main.cxx +stap_SOURCES = main.cxx \ + parse.cxx staptree.cxx elaborate.cxx translate.cxx tapsets.cxx + AM_CXXFLAGS = -Wall # Get extra libs as needed @@ -290,6 +292,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/staptree.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tapsets.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translate.Po@am__quote@ .cxx.o: @@ -36,11 +36,11 @@ void usage () cerr << " or: stap [options] -e SCRIPT [ARGS ...] Run given script." << endl; cerr << endl; cerr << "Arguments:" << endl; - cerr << " --\tNo more options after this" << endl; - cerr << " -p NUM\tStop after pass NUM 1-3" << endl; - cerr << " \t(parse, elaborate, translate)" << endl; - cerr << " -I DIR\tLook in DIR for additional .stp script files." << endl; - cerr << " -o FILE\tSend output to file instead of stdout." << endl; + cerr << " -- No more options after this" << endl; + cerr << " -p NUM Stop after pass NUM 1-3" << endl; + cerr << " (parse, elaborate, translate)" << endl; + cerr << " -I DIR Look in DIR for additional .stp script files." << endl; + cerr << " -o FILE Send output to file instead of stdout." << endl; // XXX: other options: // -s: safe mode // -d: dump safety-related external references diff --git a/tapsets.cxx b/tapsets.cxx new file mode 100644 index 00000000..1d68dd2e --- /dev/null +++ b/tapsets.cxx @@ -0,0 +1,117 @@ +// tapset resolution +// Copyright (C) 2005 Red Hat Inc. +// +// This file is part of systemtap, and is free software. You can +// redistribute it and/or modify it under the terms of the GNU General +// Public License (GPL); either version 2, or (at your option) any +// later version. + +#include "config.h" +#include "staptree.h" +#include "elaborate.h" +#include "translate.h" +#include <iostream> +#include <sstream> + +using namespace std; + + + +// ------------------------------------------------------------------------ + + + +// begin or end probes +struct be_derived_probe: public derived_probe +{ + bool begin; + be_derived_probe (probe* p, bool b): derived_probe (p), begin (b) {} + be_derived_probe (probe* p, probe_point* l, bool b): + derived_probe (p, l), begin (b) {} + + void emit_registrations (translator_output* o, unsigned i); + void emit_deregistrations (translator_output* o, unsigned i); + void emit_probe_entries (translator_output* o, unsigned i); +}; + + +void +symresolution_info::derive_probes (probe *p, vector<derived_probe*>& dps) +{ + for (unsigned i=0; i<p->locations.size(); i++) + { + probe_point *l = p->locations[i]; + + // XXX: need a better probe_point matching technique + if (l->components.size() == 1 && + l->components[0]->functor == "begin" && + l->components[0]->arg == 0) + dps.push_back (new be_derived_probe (p, p->locations[i], true)); + else if (l->components.size() == 1 && + l->components[0]->functor == "end" && + l->components[0]->arg == 0) + dps.push_back (new be_derived_probe (p, p->locations[i], false)); + else + throw semantic_error ("no match for probe point", l->tok); + } +} + + +// ------------------------------------------------------------------------ + + +// begin/end probes are run right during registration / deregistration + + +void +be_derived_probe::emit_registrations (translator_output* o, unsigned j) +{ + if (begin) + for (unsigned i=0; i<locations.size(); i++) + { + o->newline() << "enter_" << j << "_" << i << " ()"; + o->newline() << "rc = errorcount;"; + } + else + o->newline() << "rc = 0;"; +} + + +void +be_derived_probe::emit_deregistrations (translator_output* o, unsigned j) +{ + if (begin) + o->newline() << "rc = 0;"; + else + for (unsigned i=0; i<locations.size(); i++) + { + o->newline() << "enter_" << j << "_" << i << " ()"; + o->newline() << "rc = errorcount;"; + } +} + + +void +be_derived_probe::emit_probe_entries (translator_output* o, unsigned j) +{ + for (unsigned i=0; i<locations.size(); i++) + { + probe_point *l = locations[i]; + o->newline() << "/* location " << i << ": " << *l << " */"; + o->newline() << "static void enter_" << j << "_" << i << " ()"; + o->newline() << "{"; + o->newline(1) << "struct context* c = & contexts [0];"; + // XXX: assert #0 is free; need locked search instead + o->newline() << "if (c->busy) { errorcount ++; return; }"; + o->newline() << "c->busy ++;"; + o->newline() << "c->actioncount = 0;"; + o->newline() << "c->nesting = 0;"; + // NB: locals are initialized by probe function itself + o->newline() << "probe_" << j << " (c);"; + o->newline() << "c->busy --;"; + o->newline(-1) << "}" << endl; + } +} + + +// ------------------------------------------------------------------------ diff --git a/testsuite/semok/eleven.stp b/testsuite/semok/eleven.stp index bcfa4222..f7fc6914 100755 --- a/testsuite/semok/eleven.stp +++ b/testsuite/semok/eleven.stp @@ -7,7 +7,7 @@ function string (v) { return "" } function hexstring (v) { return "" } function trace (s) { return 0 } -probe kernel.syscall("read") { +probe begin /* kernel.syscall("read") */ { $count=0 $timestamp=0 $fd=0 thread->entry_time = $timestamp # "macro" variable @@ -17,7 +17,7 @@ probe kernel.syscall("read") { "my_fd = " . string(thread->my_fd)) } -probe kernel.syscall("read").return { +probe end /* kernel.syscall("read").return */ { $syscall_name="" $retvalue=0 if (thread->entry_time) { diff --git a/testsuite/semok/five.stp b/testsuite/semok/five.stp index 4e229f42..31079d5a 100755 --- a/testsuite/semok/five.stp +++ b/testsuite/semok/five.stp @@ -1,7 +1,7 @@ #! stap -p2 global array -probe foo +probe begin { array[1] = array[2] = 3; statvar <<< value <<< 4; diff --git a/testsuite/semok/four.stp b/testsuite/semok/four.stp index 978ec557..3a7e38f3 100755 --- a/testsuite/semok/four.stp +++ b/testsuite/semok/four.stp @@ -17,7 +17,7 @@ function stamp (syscall) # probe kernel:syscall:read = kernel:function("sys_read"); -probe syscall ("read") +probe begin /* syscall ("read") */ { stamp ("read"); } diff --git a/testsuite/semok/one.stp b/testsuite/semok/one.stp index 909d8eac..beea8a4c 100755 --- a/testsuite/semok/one.stp +++ b/testsuite/semok/one.stp @@ -19,7 +19,7 @@ function stamp (syscall) # probe kernel:syscall:read = kernel:function("sys_read"); -probe syscall ("read") +probe begin /* syscall ("read") */ { stamp ("read"); } diff --git a/testsuite/semok/seven.stp b/testsuite/semok/seven.stp index b9ce8cb9..98d78f05 100755 --- a/testsuite/semok/seven.stp +++ b/testsuite/semok/seven.stp @@ -13,7 +13,7 @@ function search (key) return "no can do" # implies ar2[]: string } -probe syscall("zamboni") +probe begin /* syscall("zamboni") */ { thread->ar2 = string ($tgid); search ($pid) diff --git a/testsuite/semok/six.stp b/testsuite/semok/six.stp index ef14827c..f77baad8 100755 --- a/testsuite/semok/six.stp +++ b/testsuite/semok/six.stp @@ -2,7 +2,7 @@ global bar, baz -probe foo +probe begin { thread->bar = 4; process->baz = "5"; diff --git a/testsuite/semok/three.stp b/testsuite/semok/three.stp index 41d726a0..6d822d0d 100755 --- a/testsuite/semok/three.stp +++ b/testsuite/semok/three.stp @@ -1,7 +1,7 @@ #! stap -p2 global b -probe foo { +probe begin { a <<< 2; b[4] <<< 4; } diff --git a/testsuite/semok/two.stp b/testsuite/semok/two.stp index e68d596e..c5645d2b 100755 --- a/testsuite/semok/two.stp +++ b/testsuite/semok/two.stp @@ -7,7 +7,7 @@ function koo (p) { return p + 2; } -probe foo { +probe end { bar = 2 + koo (4); foo = bar + koo; } diff --git a/translate.cxx b/translate.cxx index dcccf1bd..7336d172 100644 --- a/translate.cxx +++ b/translate.cxx @@ -29,33 +29,6 @@ stringify(T t) } - -// ------------------------------------------------------------------------ -// toy provider/unparser pair - - -struct test_derived_probe: public derived_probe -{ - test_derived_probe (probe* p); - test_derived_probe (probe* p, probe_point* l); - - void emit_registrations (translator_output* o, unsigned i); - void emit_deregistrations (translator_output* o, unsigned i); - void emit_probe_entries (translator_output* o, unsigned i); -}; - - - -void -symresolution_info::derive_probes (probe *p, vector<derived_probe*>& dps) -{ - // XXX: there will be real ones coming later - for (unsigned i=0; i<p->locations.size(); i++) - dps.push_back (new test_derived_probe (p, p->locations[i])); -} - - - struct c_unparser: public unparser, public visitor { systemtap_session* session; @@ -120,32 +93,6 @@ struct c_unparser: public unparser, public visitor }; - -// ------------------------------------------------------------------------ - - -// Perform inter-script dependency analysis [XXX: later], -// then provider elaboration and derived probe construction -// and finally semantic analysis -// on the reachable set of probes/functions from the user_file -int -resolution_pass (systemtap_session& s) -{ - int rc = 0; - - for (unsigned i=0; i<s.user_file->probes.size(); i++) - { - probe* p = s.user_file->probes[i]; - // XXX: should of course be based on each probe_point - derived_probe *dp = new test_derived_probe (p); - s.probes.push_back (dp); - } - - // XXX: add builtin variables/functions - return rc; -} - - // ------------------------------------------------------------------------ @@ -195,60 +142,6 @@ translator_output::line () -// ------------------------------------------------------------------------ - - -test_derived_probe::test_derived_probe (probe* p): derived_probe (p) -{ -} - - -test_derived_probe::test_derived_probe (probe* p, probe_point* l): - derived_probe (p, l) -{ -} - - -void -test_derived_probe::emit_registrations (translator_output* o, unsigned i) -{ - // XXX - o->newline() << "rc = 0; /* no registration for probe " << i << " */"; -} - -void -test_derived_probe::emit_deregistrations (translator_output* o, unsigned i) -{ - // XXX - o->newline() << "rc = 0; /* no deregistration for probe " << i << " */"; -} - - -void -test_derived_probe::emit_probe_entries (translator_output* o, unsigned j) -{ - for (unsigned i=0; i<locations.size(); i++) - { - probe_point *l = locations[i]; - o->newline() << "/* location " << i << ": " << *l << " */"; - o->newline() << "static void enter_" << j << "_" << i << " ()"; - o->newline() << "{"; - o->newline(1) << "struct context* c = & contexts [0];"; - // XXX: assert #0 is free; need locked search instead - o->newline() << "if (c->busy) { errorcount ++; return; }"; - o->newline() << "c->busy ++;"; - o->newline() << "c->actioncount = 0;"; - o->newline() << "c->nesting = 0;"; - // NB: locals are initialized by probe function itself - o->newline() << "probe_" << j << " (c);"; - o->newline() << "c->busy --;"; - o->newline(-1) << "}" << endl; - } -} - - -// ------------------------------------------------------------------------ - // A shadow visitor, meant to generate temporary variable declarations // for function or probe bodies. Member functions should exactly match |