summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--NEWS2
-rw-r--r--stapprobes.5.in7
-rw-r--r--tapset/ChangeLog4
-rw-r--r--tapset/utrace.stp4
-rw-r--r--tapsets.cxx32
6 files changed, 47 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index df495cab..44cfc4cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
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.
* NEWS: Ditto.
* tapsets.cxx (utrace_var_expanding_copy_visitor): Added
diff --git a/NEWS b/NEWS
index b48870e2..04ba292e 100644
--- 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
diff --git a/stapprobes.5.in b/stapprobes.5.in
index 6e8c3ff2..36b36156 100644
--- a/stapprobes.5.in
+++ b/stapprobes.5.in
@@ -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
diff --git a/tapset/ChangeLog b/tapset/ChangeLog
index 5a08ac63..3e2ebaf7 100644
--- a/tapset/ChangeLog
+++ b/tapset/ChangeLog
@@ -1,5 +1,9 @@
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().
2008-09-09 Masami Hiramatsu <mhiramat@redhat.com>
diff --git a/tapset/utrace.stp b/tapset/utrace.stp
index 2b661573..34cb32c5 100644
--- a/tapset/utrace.stp
+++ b/tapset/utrace.stp
@@ -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 */
+%}
diff --git a/tapsets.cxx b/tapsets.cxx
index 5941339c..28f945fe 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -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);
}