summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfche <fche>2005-07-28 18:42:58 +0000
committerfche <fche>2005-07-28 18:42:58 +0000
commit3d49c6154591958c1e12f70aa5b89de70e8fb988 (patch)
treea08853945b533ccc2a64c48e5e4f60400f07806b
parent24cb178fd82936f55d254ebd0cd79802da21134a (diff)
downloadsystemtap-steved-3d49c6154591958c1e12f70aa5b89de70e8fb988.tar.gz
systemtap-steved-3d49c6154591958c1e12f70aa5b89de70e8fb988.tar.xz
systemtap-steved-3d49c6154591958c1e12f70aa5b89de70e8fb988.zip
2005-07-28 Frank Ch. Eigler <fche@redhat.com>
* translate.cxx: Add "pt_regs*" field to context. * tapsets.cxx (*): Correct kprobes API interface. * testsuite/buildok/three.stp: New test, copied from semok. * Makefile.am (install-data-local): Also install runtime/relayfs, so scripts can build against headers located thereunder. * Makefile.in: Regenerated.
-rw-r--r--ChangeLog9
-rw-r--r--Makefile.am3
-rw-r--r--Makefile.in3
-rw-r--r--tapsets.cxx49
-rwxr-xr-xtestsuite/buildok/three.stp25
-rw-r--r--translate.cxx1
6 files changed, 65 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 84085e26..a8d5cb0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2005-07-28 Frank Ch. Eigler <fche@redhat.com>
+ * translate.cxx: Add "pt_regs*" field to context.
+ * tapsets.cxx (*): Correct kprobes API interface.
+ * testsuite/buildok/three.stp: New test, copied from semok.
+ * Makefile.am (install-data-local): Also install runtime/relayfs,
+ so scripts can build against headers located thereunder.
+ * Makefile.in: Regenerated.
+
+2005-07-28 Frank Ch. Eigler <fche@redhat.com>
+
translator/1120
* main.cxx (main): Preset -R and -I options from environment
variables (if set). Pass guru mode flags to parser.
diff --git a/Makefile.am b/Makefile.am
index 327bdbaf..0da0a1bc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,6 +38,9 @@ install-data-local:
tar -f - -c --exclude=CVS --exclude='*~' --exclude='.#*' \
-C $(srcdir)/runtime transport \
| (cd $(DESTDIR)$(pkgdatadir)/runtime && tar xpf -)
+ tar -f - -c --exclude=CVS --exclude='*~' --exclude='.#*' \
+ -C $(srcdir)/runtime relayfs \
+ | (cd $(DESTDIR)$(pkgdatadir)/runtime && tar xpf -)
-mkdir $(DESTDIR)$(pkgdatadir)/tapset
(cd $(srcdir)/tapset ; find . -name '*.stp' | cpio -pdmv $(DESTDIR)$(pkgdatadir)/tapset)
diff --git a/Makefile.in b/Makefile.in
index 53ec3b03..7e4d7c39 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -862,6 +862,9 @@ install-data-local:
tar -f - -c --exclude=CVS --exclude='*~' --exclude='.#*' \
-C $(srcdir)/runtime transport \
| (cd $(DESTDIR)$(pkgdatadir)/runtime && tar xpf -)
+ tar -f - -c --exclude=CVS --exclude='*~' --exclude='.#*' \
+ -C $(srcdir)/runtime relayfs \
+ | (cd $(DESTDIR)$(pkgdatadir)/runtime && tar xpf -)
-mkdir $(DESTDIR)$(pkgdatadir)/tapset
(cd $(srcdir)/tapset ; find . -name '*.stp' | cpio -pdmv $(DESTDIR)$(pkgdatadir)/tapset)
diff --git a/tapsets.cxx b/tapsets.cxx
index 040c8424..bbe0481c 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -116,15 +116,16 @@ be_derived_probe::emit_probe_entries (translator_output* o, unsigned j)
o->newline() << "c->errorcount = 0;";
o->newline() << "c->actioncount = 0;";
o->newline() << "c->nesting = 0;";
+ o->newline() << "c->regs = 0;";
// NB: locals are initialized by probe function itself
o->newline() << "probe_" << j << " (c);";
// see translate.cxx: visit_functioncall and elsewhere to see all the
// possible context indications that a probe exited prematurely
- o->newline() << "if (c->errorcount || c->actioncount > MAXACTION";
- o->newline(1) << "|| c->nesting+2 >= MAXNESTING) {";
- o->newline() << "printk (KERN_ERR \"probe execution failure (e%d,n%d,a%d)\",";
+ o->newline() << "if (c->errorcount || c->actioncount > MAXACTION"
+ << " || c->nesting+2 >= MAXNESTING) {";
+ o->newline(1) << "printk (KERN_ERR \"probe execution failure (e%d,n%d,a%d)\",";
o->newline(1) << "c->errorcount, c->nesting, c->actioncount);";
o->newline(-1) << "atomic_set (& session_state, STAP_SESSION_ERROR);";
o->newline(-1) << "}";
@@ -1069,8 +1070,8 @@ dwarf_derived_probe::emit_registrations (translator_output* o, unsigned probenum
if (module_name.empty())
{
o->newline() << probe_entry_struct_kprobe_name(probenum)
- << ".addr = 0x" << hex << addr << ";";
- o->newline() << "register_probe (&"
+ << ".addr = (void *) 0x" << hex << addr << ";";
+ o->newline() << "rc = register_kprobe (&"
<< probe_entry_struct_kprobe_name(probenum)
<< ");";
}
@@ -1087,8 +1088,8 @@ dwarf_derived_probe::emit_registrations (translator_output* o, unsigned probenum
o->newline() << "{";
o->indent(1);
o->newline() << probe_entry_struct_kprobe_name(probenum)
- << ".addr = mod->module_core + 0x" << hex << addr << ";";
- o->newline() << "register_probe (&"
+ << ".addr = (void *) (mod->module_core + 0x" << hex << addr << ");";
+ o->newline() << "rc = register_kprobe (&"
<< probe_entry_struct_kprobe_name(probenum)
<< ");";
o->indent(-1);
@@ -1102,7 +1103,7 @@ void
dwarf_derived_probe::emit_deregistrations (translator_output* o, unsigned probenum)
{
o->newline();
- o->newline() << "deregister_probe (&"
+ o->newline() << "unregister_kprobe (& "
<< probe_entry_struct_kprobe_name(probenum)
<< ");";
}
@@ -1114,22 +1115,20 @@ dwarf_derived_probe::emit_probe_entries (translator_output* o, unsigned probenum
// Construct a single entry function, and a struct kprobe pointing into
// the entry function. The entry function will call the probe function.
o->newline();
- o->newline() << "static void ";
- o->newline() << probe_entry_function_name(probenum) << " (void);";
- o->newline() << "void ";
- o->newline() << probe_entry_function_name(probenum) << " ()";
- o->newline() << "{";
- o->newline(1) << "struct context* c = & contexts [smp_processor_id()];";
+ o->newline() << "static int ";
+ o->newline() << probe_entry_function_name(probenum)
+ << " (struct kprobe *_ignored, struct pt_regs *regs) {";
+ o->newline(1) << "struct context *c = & contexts [smp_processor_id()];";
o->newline();
// A precondition for running a probe handler is that we're in RUNNING
// state (not ERROR), and that no one else is already using this context.
o->newline() << "if (atomic_read (&session_state) != STAP_SESSION_RUNNING)";
- o->newline(1) << "return;";
+ o->newline(1) << "return 0;";
o->newline(-1) << "if (c->busy) {";
o->newline(1) << "printk (KERN_ERR \"probe reentrancy\");";
o->newline() << "atomic_set (& session_state, STAP_SESSION_ERROR);";
- o->newline() << "return;";
+ o->newline() << "return 0;";
o->newline(-1) << "}";
o->newline();
@@ -1138,14 +1137,15 @@ dwarf_derived_probe::emit_probe_entries (translator_output* o, unsigned probenum
o->newline() << "c->errorcount = 0;";
o->newline() << "c->actioncount = 0;";
o->newline() << "c->nesting = 0;";
+ o->newline() << "c->regs = regs;";
// NB: locals are initialized by probe function itself
o->newline() << "probe_" << probenum << " (c);";
// see translate.cxx: visit_functioncall and elsewhere to see all the
// possible context indications that a probe exited prematurely
- o->newline() << "if (c->errorcount || c->actioncount > MAXACTION";
- o->newline(1) << "|| c->nesting+2 >= MAXNESTING) {";
- o->newline() << "printk (KERN_ERR \"probe execution failure (e%d,n%d,a%d)\",";
+ o->newline() << "if (c->errorcount || c->actioncount > MAXACTION"
+ << " || c->nesting+2 >= MAXNESTING) {";
+ o->newline(1) << "printk (KERN_ERR \"probe execution failure (e%d,n%d,a%d)\",";
o->newline(1) << "c->errorcount, c->nesting, c->actioncount);";
o->newline(-1) << "atomic_set (& session_state, STAP_SESSION_ERROR);";
o->newline(-1) << "}";
@@ -1153,17 +1153,16 @@ dwarf_derived_probe::emit_probe_entries (translator_output* o, unsigned probenum
o->newline() << "c->busy --;";
o->newline() << "mb ();";
+ o->newline() << "return 0;";
o->newline(-1) << "}" << endl;
o->newline();
o->newline() << "static struct kprobe "
- << probe_entry_struct_kprobe_name(probenum);
- o->newline() << "{";
- o->indent(1);
- o->newline() << ".addr = 0x0, /* filled in during module init */" ;
+ << probe_entry_struct_kprobe_name(probenum)
+ << "= {";
+ o->newline(1) << ".addr = 0x0, /* filled in during module init */" ;
o->newline() << ".pre_handler = &" << probe_entry_function_name(probenum) << ",";
- o->indent(-1);
- o->newline() << "}";
+ o->newline(-1) << "};";
o->newline();
}
diff --git a/testsuite/buildok/three.stp b/testsuite/buildok/three.stp
new file mode 100755
index 00000000..013b5ac5
--- /dev/null
+++ b/testsuite/buildok/three.stp
@@ -0,0 +1,25 @@
+#! stap -p4
+
+# define some aliases which resolve to kernel functions
+
+probe pipe_read = kernel.function("pipe_read")
+{
+ fname = "pipe_read"
+ reading_from_pipe = 1
+}
+
+probe pipe_write = kernel.function("pipe_write")
+{
+ fname = "pipe_write"
+ reading_from_pipe = 0
+}
+
+# use the aliases, including variables defined in them
+
+probe pipe_read, pipe_write
+{
+ if (reading_from_pipe)
+ log ("reading from pipe in " . fname)
+ else
+ log ("writing to pipe in " . fname)
+}
diff --git a/translate.cxx b/translate.cxx
index 3623799c..2667d7ab 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -513,6 +513,7 @@ c_unparser::emit_common_header ()
o->newline() << "unsigned actioncount;";
o->newline() << "unsigned errorcount;";
o->newline() << "unsigned nesting;";
+ o->newline() << "struct pt_regs *regs;";
o->newline() << "union {";
o->indent(1);
// XXX: this handles only scalars!