summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2008-09-09 16:02:56 -0400
committerMasami Hiramatsu <mhiramat@redhat.com>2008-09-09 16:02:56 -0400
commit6270adc1ec2b89a201c932b94fb8ec8abc4e977f (patch)
treedf0bf7331aa0889afee06bac90b6423ba71cb680
parentbc54e71c6747fa2c234737d3a715b0decc3663b2 (diff)
downloadsystemtap-steved-6270adc1ec2b89a201c932b94fb8ec8abc4e977f.tar.gz
systemtap-steved-6270adc1ec2b89a201c932b94fb8ec8abc4e977f.tar.xz
systemtap-steved-6270adc1ec2b89a201c932b94fb8ec8abc4e977f.zip
Add $argN context variables on per-process-syscall probes
-rw-r--r--ChangeLog11
-rw-r--r--NEWS4
-rw-r--r--stapprobes.5.in9
-rw-r--r--tapset/ChangeLog4
-rw-r--r--tapset/utrace.stp5
-rw-r--r--tapsets.cxx83
6 files changed, 103 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index cb5a6f4b..df495cab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
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
+ visit_target_symbol_arg() and visit_target_symbol_syscall().
+ (visit_target_symbol_arg): New function for handling $argN.
+ (visit_target_symbol_syscall): New function for handling $syscall.
+ (visit_target_symbol): Use visit_target_symbol_arg() and
+ visit_target_symbol_syscall().
+
+2008-09-09 Masami Hiramatsu <mhiramat@redhat.com>
+
* stapprobes.5.in : Added a line for $name context variable.
* translate.cxx (c_unparser::emit_common_header): Add marker_name and
marker_format fields to context.
diff --git a/NEWS b/NEWS
index c7ddce45..b48870e2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
* What's new
+- 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.
+
- Target process mode (stap -c CMD or -x PID) now implicitly restricts all
"process.*" probes to the given child process. (It does not affect
kernel.* or other probe types.) The CMD string is now executed directly,
diff --git a/stapprobes.5.in b/stapprobes.5.in
index ecc6956c..6e8c3ff2 100644
--- a/stapprobes.5.in
+++ b/stapprobes.5.in
@@ -421,8 +421,13 @@ probe gets called when a thread described by PID or PATH dies.
A
.B .syscall
probe gets called when a thread described by PID or PATH makes a
-system call. The system call number is available in the "$syscall"
-context variable.
+system call. The system call number is available in the
+.BR $syscall
+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
diff --git a/tapset/ChangeLog b/tapset/ChangeLog
index d3117620..5a08ac63 100644
--- a/tapset/ChangeLog
+++ b/tapset/ChangeLog
@@ -1,5 +1,9 @@
2008-09-09 Masami Hiramatsu <mhiramat@redhat.com>
+ * utrace.stp: Added _utrace_syscall_arg().
+
+2008-09-09 Masami Hiramatsu <mhiramat@redhat.com>
+
* marker.stp : New file, including marker context variable accessors.
2008-09-01 Frank Ch. Eigler <fche@elastic.org>
diff --git a/tapset/utrace.stp b/tapset/utrace.stp
index 3831ca3c..2b661573 100644
--- a/tapset/utrace.stp
+++ b/tapset/utrace.stp
@@ -5,7 +5,10 @@
#include "syscall.h"
%}
-
function _utrace_syscall_nr:long () %{
THIS->__retvalue = __stp_user_syscall_nr(CONTEXT->regs); /* pure */
%}
+
+function _utrace_syscall_arg:long (n:long) %{
+ THIS->__retvalue = *__stp_user_syscall_arg(current, CONTEXT->regs, (int)THIS->n); /* pure */
+%}
diff --git a/tapsets.cxx b/tapsets.cxx
index 4774c0f6..5941339c 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -5846,6 +5846,8 @@ struct utrace_var_expanding_copy_visitor: public var_expanding_copy_visitor
enum utrace_derived_probe_flags flags;
bool target_symbol_seen;
+ void visit_target_symbol_arg (target_symbol* e);
+ void visit_target_symbol_syscall (target_symbol* e);
void visit_target_symbol (target_symbol* e);
};
@@ -5923,18 +5925,61 @@ utrace_derived_probe::join_group (systemtap_session& s)
void
-utrace_var_expanding_copy_visitor::visit_target_symbol (target_symbol* e)
+utrace_var_expanding_copy_visitor::visit_target_symbol_arg (target_symbol* e)
{
- assert(e->base_name.size() > 0 && e->base_name[0] == '$');
+ string argnum_s = e->base_name.substr(4,e->base_name.length()-4);
+ int argnum = atoi (argnum_s.c_str());
- if (flags != UDPF_SYSCALL && flags != UDPF_SYSCALL_RETURN)
- throw semantic_error ("only \"process(PATH_OR_PID).syscall\" and \"process(PATH_OR_PID).syscall.return\" probes support target symbols",
- e->tok);
+ if (flags != UDPF_SYSCALL)
+ throw semantic_error ("only \"process(PATH_OR_PID).syscall\" support $argN.", e->tok);
- if (e->base_name != "$syscall")
- throw semantic_error ("invalid target symbol for utrace probe, $syscall expected",
- e->tok);
+ if (e->components.size() > 0)
+ {
+ switch (e->components[0].first)
+ {
+ case target_symbol::comp_literal_array_index:
+ throw semantic_error("utrace target variable '$argN' may not be used as array",
+ e->tok);
+ break;
+ case target_symbol::comp_struct_member:
+ throw semantic_error("utrace target variable '$argN' may not be used as a structure",
+ e->tok);
+ break;
+ default:
+ throw semantic_error ("invalid use of utrace target variable '$argN'",
+ e->tok);
+ break;
+ }
+ }
+
+ // FIXME: max argnument number should not be hardcoded.
+ if (argnum < 1 || argnum > 6)
+ throw semantic_error ("invalid syscall argument number (1-6)", e->tok);
+
+ bool lvalue = is_active_lvalue(e);
+ if (lvalue)
+ throw semantic_error("utrace '$argN' variable is read-only", e->tok);
+ // Remember that we've seen a target variable.
+ target_symbol_seen = true;
+
+ // We're going to substitute a synthesized '_utrace_syscall_arg'
+ // function call for the '$argN' reference.
+ functioncall* n = new functioncall;
+ n->tok = e->tok;
+ n->function = "_utrace_syscall_arg";
+ n->referent = 0; // NB: must not resolve yet, to ensure inclusion in session
+
+ literal_number *num = new literal_number(argnum - 1);
+ num->tok = e->tok;
+ n->args.push_back(num);
+
+ provide <functioncall*> (this, n);
+}
+
+void
+utrace_var_expanding_copy_visitor::visit_target_symbol_syscall (target_symbol* e)
+{
if (e->components.size() > 0)
{
switch (e->components[0].first)
@@ -5956,12 +6001,12 @@ utrace_var_expanding_copy_visitor::visit_target_symbol (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 '$syscall' variable is read-only", e->tok);
// Remember that we've seen a target variable.
target_symbol_seen = true;
- // We're going to substitute a synthesized '_syscall_nr_get'
+ // We're going to substitute a synthesized '_utrace_syscall_nr'
// function call for the '$syscall' reference.
functioncall* n = new functioncall;
n->tok = e->tok;
@@ -5971,6 +6016,24 @@ utrace_var_expanding_copy_visitor::visit_target_symbol (target_symbol* e)
provide <functioncall*> (this, n);
}
+void
+utrace_var_expanding_copy_visitor::visit_target_symbol (target_symbol* e)
+{
+ assert(e->base_name.size() > 0 && e->base_name[0] == '$');
+
+ if (flags != UDPF_SYSCALL && flags != UDPF_SYSCALL_RETURN)
+ throw semantic_error ("only \"process(PATH_OR_PID).syscall\" and \"process(PATH_OR_PID).syscall.return\" probes support target symbols",
+ e->tok);
+
+ 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
+ throw semantic_error ("invalid target symbol for utrace probe, $syscall or $argN expected",
+ e->tok);
+}
+
struct utrace_builder: public derived_probe_builder
{