]> sourceware.org Git - systemtap.git/commitdiff
Add $return context variables on per-process-syscall.return probes
authorMasami Hiramatsu <mhiramat@redhat.com>
Tue, 9 Sep 2008 20:16:30 +0000 (16:16 -0400)
committerMasami Hiramatsu <mhiramat@redhat.com>
Tue, 9 Sep 2008 20:16:30 +0000 (16:16 -0400)
ChangeLog
NEWS
stapprobes.5.in
tapset/ChangeLog
tapset/utrace.stp
tapsets.cxx

index df495cab6162fc444054240e6e808201e942face..44cfc4cc0f8fa1cd1f86924513147ea8d274e2e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-09-09  Masami Hiramatsu  <mhiramat@redhat.com>
+
+       * stapprobes.5.in: Added a description about $return.
+       * NEWS: Ditto.
+       * tapsets.cxx (utrace_var_expanding_copy_visitor): Change
+       visit_target_symbol_syscall() to visit_target_symbol_context().
+       (utrace_var_expanding_copy_visitor::visit_target_symbol_context):
+       Handle not only $syscall but also $return.
+       (utrace_var_expanding_copy_visitor::visit_target_symbol): Ditto.
+
 2008-09-09  Masami Hiramatsu  <mhiramat@redhat.com>
 
        * stapprobes.5.in: Added a description about $argN.
diff --git a/NEWS b/NEWS
index b48870e231c606896c12a9b78bd2a516e7209a12..04ba292e77029c2b28bc9918a3fa442c96dba490 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@
 - Additional context variables are available on user-space syscall probes.
   - $argN ($arg1, $arg2, ... $arg6) in process(PATH_OR_PID).syscall
     gives you the argument of the system call.
+  - $return in process(PATH_OR_PID).syscall.return gives you the return
+    value of the system call.
 
 - Target process mode (stap -c CMD or -x PID) now implicitly restricts all
   "process.*" probes to the given child process.  (It does not affect
index 6e8c3ff273a98d5e6eddbabe7bb0576959d78644..36b36156c353fef46a1ac144bd9b88a7c1c6773e 100644 (file)
@@ -427,11 +427,14 @@ context variable, and the first 6 arguments of the system call
 are available in the
 .BR $argN
 (ex. $arg1, $arg2, ...) context variable.
-
 A
 .B .syscall.return
 probe gets called when a thread described by PID or PATH returns from a
-system call.  The system call number is available in the "$syscall"
+system call.  The system call number is available in the
+.BR $syscall
+context variable, and the return value of the system call is available
+in the
+.BR $return
 context variable.
 A
 .B .itrace
index 5a08ac63bc3160bb614fc64a0f8aa3f76ad3c842..3e2ebaf7aff82fa4c34b84af4615623109e89d06 100644 (file)
@@ -1,3 +1,7 @@
+2008-09-09  Masami Hiramatsu  <mhiramat@redhat.com>
+
+       * utrace.stp: Added _utrace_syscall_return().
+
 2008-09-09  Masami Hiramatsu  <mhiramat@redhat.com>
 
        * utrace.stp: Added _utrace_syscall_arg().
index 2b661573b118b0c0257f2d7f38aa6cbbb7e72b1b..34cb32c5e183c197f6a6f35cd4c7ee3e7cb3581e 100644 (file)
@@ -12,3 +12,7 @@ function _utrace_syscall_nr:long () %{
 function _utrace_syscall_arg:long (n:long) %{
    THIS->__retvalue = *__stp_user_syscall_arg(current, CONTEXT->regs, (int)THIS->n); /* pure */
 %}
+
+function _utrace_syscall_return:long () %{
+   THIS->__retvalue = *__stp_user_syscall_return_value(current, CONTEXT->regs); /* pure */
+%}
index 5941339cf26e27b3ee02fbd6004d2eef86e8b5bc..28f945fe8e1869e8e4a40b77b658547dd44a808c 100644 (file)
@@ -5847,7 +5847,7 @@ struct utrace_var_expanding_copy_visitor: public var_expanding_copy_visitor
   bool target_symbol_seen;
 
   void visit_target_symbol_arg (target_symbol* e);
-  void visit_target_symbol_syscall (target_symbol* e);
+  void visit_target_symbol_context (target_symbol* e);
   void visit_target_symbol (target_symbol* e);
 };
 
@@ -5978,22 +5978,24 @@ utrace_var_expanding_copy_visitor::visit_target_symbol_arg (target_symbol* e)
 }
 
 void
-utrace_var_expanding_copy_visitor::visit_target_symbol_syscall (target_symbol* e)
+utrace_var_expanding_copy_visitor::visit_target_symbol_context (target_symbol* e)
 {
+  string sname = e->base_name;
+
   if (e->components.size() > 0)
     {
       switch (e->components[0].first)
        {
        case target_symbol::comp_literal_array_index:
-         throw semantic_error("utrace target variable '$syscall' may not be used as array",
+         throw semantic_error("utrace target variable '" + sname + "' may not be used as array",
                               e->tok);
          break;
        case target_symbol::comp_struct_member:
-         throw semantic_error("utrace target variable '$syscall' may not be used as a structure",
+         throw semantic_error("utrace target variable '" + sname + "' may not be used as a structure",
                               e->tok);
          break;
        default:
-         throw semantic_error ("invalid use of utrace target variable '$syscall'",
+         throw semantic_error ("invalid use of utrace target variable '" + sname + "'",
                                e->tok);
          break;
        }
@@ -6001,7 +6003,17 @@ utrace_var_expanding_copy_visitor::visit_target_symbol_syscall (target_symbol* e
 
   bool lvalue = is_active_lvalue(e);
   if (lvalue)
-    throw semantic_error("utrace '$syscall' variable is read-only", e->tok);
+    throw semantic_error("utrace '" + sname + "' variable is read-only", e->tok);
+
+  string fname;
+  if (sname == "$return")
+    {
+      if (flags != UDPF_SYSCALL_RETURN)
+       throw semantic_error ("only \"process(PATH_OR_PID).syscall.return\" support $return.", e->tok);
+      fname = "_utrace_syscall_return";
+    }
+  else
+    fname = "_utrace_syscall_nr";
 
   // Remember that we've seen a target variable.
   target_symbol_seen = true;
@@ -6010,7 +6022,7 @@ utrace_var_expanding_copy_visitor::visit_target_symbol_syscall (target_symbol* e
   // function call for the '$syscall' reference.
   functioncall* n = new functioncall;
   n->tok = e->tok;
-  n->function = "_utrace_syscall_nr";
+  n->function = fname;
   n->referent = 0; // NB: must not resolve yet, to ensure inclusion in session
 
   provide <functioncall*> (this, n);
@@ -6027,10 +6039,10 @@ utrace_var_expanding_copy_visitor::visit_target_symbol (target_symbol* e)
 
   if (e->base_name.substr(0,4) == "$arg")
     visit_target_symbol_arg(e);
-  else if (e->base_name == "$syscall")
-    visit_target_symbol_syscall(e);
+  else if (e->base_name == "$syscall" || e->base_name == "$return")
+    visit_target_symbol_context(e);
   else
-    throw semantic_error ("invalid target symbol for utrace probe, $syscall or $argN expected",
+    throw semantic_error ("invalid target symbol for utrace probe, $syscall, $return or $argN expected",
                          e->tok);
 }
 
This page took 0.048271 seconds and 5 git commands to generate.