diff options
author | Masami Hiramatsu <mhiramat@redhat.com> | 2008-09-09 16:02:21 -0400 |
---|---|---|
committer | Masami Hiramatsu <mhiramat@redhat.com> | 2008-09-09 16:02:21 -0400 |
commit | bc54e71c6747fa2c234737d3a715b0decc3663b2 (patch) | |
tree | e522016f68ceadb254583de1a6d90391411f3508 | |
parent | 901a409a01da22778ea15f7b9f938885bdc38847 (diff) | |
download | systemtap-steved-bc54e71c6747fa2c234737d3a715b0decc3663b2.tar.gz systemtap-steved-bc54e71c6747fa2c234737d3a715b0decc3663b2.tar.xz systemtap-steved-bc54e71c6747fa2c234737d3a715b0decc3663b2.zip |
Add $name context variable support on marker probes
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | stapprobes.5.in | 2 | ||||
-rw-r--r-- | tapset/ChangeLog | 4 | ||||
-rw-r--r-- | tapset/marker.stp | 22 | ||||
-rw-r--r-- | tapsets.cxx | 49 | ||||
-rw-r--r-- | testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | testsuite/systemtap.base/marker.exp | 45 | ||||
-rw-r--r-- | translate.cxx | 2 |
8 files changed, 112 insertions, 29 deletions
@@ -1,3 +1,16 @@ +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. + * tapsets.cxx (common_probe_entryfn_prologue) : Ditto. + (mark_derived_probe_group::emit_module_decls) : Ditto. + (mark_var_expanding_copy_visitor) : change visit_target_symbol_format + to visit_target_symbol_context. + (mark_var_expanding_copy_visitor::visit_target_symbol_context): handle + not only $format but also $name. + (mark_var_expanding_copy_visitor::visit_target_symbol): Ditto. + 2008-09-07 Frank Ch. Eigler <fche@elastic.org> * tapsets.cxx (build_blacklist): Add some x86 raw port-io spots. diff --git a/stapprobes.5.in b/stapprobes.5.in index 5281c40e..ecc6956c 100644 --- a/stapprobes.5.in +++ b/stapprobes.5.in @@ -520,6 +520,8 @@ and string parameters are passed in a type-safe manner. The marker format string associated with a marker is available in .BR $format . +And also the marker name string is avalable in +.BR $name . .SS PERFORMANCE MONITORING HARDWARE diff --git a/tapset/ChangeLog b/tapset/ChangeLog index 39b6b93b..d3117620 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -1,3 +1,7 @@ +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> PR4225 merge. diff --git a/tapset/marker.stp b/tapset/marker.stp new file mode 100644 index 00000000..593ffaea --- /dev/null +++ b/tapset/marker.stp @@ -0,0 +1,22 @@ +// +// kernel marker tapset +// +// 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. + +/* marker-only context accessors */ + + +function _mark_name_get:string () %{ + strlcpy (THIS->__retvalue, + (CONTEXT->marker_name)?CONTEXT->marker_name:"", + MAXSTRINGLEN); /* pure */ +%} + +function _mark_format_get:string () %{ + strlcpy (THIS->__retvalue, + (CONTEXT->marker_format)?CONTEXT->marker_format:"", + MAXSTRINGLEN); /* pure */ +%} diff --git a/tapsets.cxx b/tapsets.cxx index 64fa9d34..4774c0f6 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -221,6 +221,8 @@ common_probe_entryfn_prologue (translator_output* o, string statestr, // reset unwound address cache o->newline() << "c->pi = 0;"; o->newline() << "c->regparm = 0;"; + o->newline() << "c->marker_name = NULL;"; + o->newline() << "c->marker_format = NULL;"; o->newline() << "c->probe_point = 0;"; if (! interruptible) o->newline() << "c->actionremaining = MAXACTION;"; @@ -7758,7 +7760,7 @@ struct mark_var_expanding_copy_visitor: public var_expanding_copy_visitor void visit_target_symbol (target_symbol* e); void visit_target_symbol_arg (target_symbol* e); - void visit_target_symbol_format (target_symbol* e); + void visit_target_symbol_context (target_symbol* e); }; @@ -7865,48 +7867,37 @@ mark_var_expanding_copy_visitor::visit_target_symbol_arg (target_symbol* e) void -mark_var_expanding_copy_visitor::visit_target_symbol_format (target_symbol* e) +mark_var_expanding_copy_visitor::visit_target_symbol_context (target_symbol* e) { - static bool function_synthesized = false; + string sname = e->base_name; if (is_active_lvalue (e)) - throw semantic_error("write to marker format not permitted", e->tok); + throw semantic_error("write to marker '" + sname + "' not permitted", e->tok); if (e->components.size() > 0) { switch (e->components[0].first) { case target_symbol::comp_literal_array_index: - throw semantic_error("marker format may not be used as array", + throw semantic_error("marker '" + sname + "' may not be used as array", e->tok); break; case target_symbol::comp_struct_member: - throw semantic_error("marker format may not be used as a structure", + throw semantic_error("marker '" + sname + "' may not be used as a structure", e->tok); break; default: - throw semantic_error ("invalid marker format use", e->tok); + throw semantic_error ("invalid marker '" + sname + "' use", e->tok); break; } } - string fname = string("_mark_format_get"); - - // Synthesize a function (if not already synthesized). - if (! function_synthesized) - { - function_synthesized = true; - functiondecl *fdecl = new functiondecl; - fdecl->tok = e->tok; - embeddedcode *ec = new embeddedcode; - ec->tok = e->tok; - - ec->code = string("strlcpy (THIS->__retvalue, CONTEXT->data, MAXSTRINGLEN); /* pure */"); - fdecl->name = fname; - fdecl->body = ec; - fdecl->type = pe_string; - sess.functions.push_back(fdecl); - } + string fname; + if (e->base_name == "$format") { + fname = string("_mark_format_get"); + } else { + fname = string("_mark_name_get"); + } // Synthesize a functioncall. functioncall* n = new functioncall; @@ -7923,10 +7914,10 @@ mark_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 == "$format") - visit_target_symbol_format (e); + else if (e->base_name == "$format" || e->base_name == "$name") + visit_target_symbol_context (e); else - throw semantic_error ("invalid target symbol for marker, $argN or $format expected", + throw semantic_error ("invalid target symbol for marker, $argN, $name or $format expected", e->tok); } @@ -8225,8 +8216,8 @@ mark_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(1) << "struct stap_marker_probe *smp = (struct stap_marker_probe *)probe_data;"; common_probe_entryfn_prologue (s.op, "STAP_SESSION_RUNNING"); s.op->newline() << "c->probe_point = smp->pp;"; - s.op->newline() << "c->data = (char *)smp->format;"; - + s.op->newline() << "c->marker_name = smp->name;"; + s.op->newline() << "c->marker_format = smp->format;"; s.op->newline() << "c->mark_va_list = args;"; s.op->newline() << "(*smp->ph) (c);"; s.op->newline() << "c->mark_va_list = NULL;"; diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 045772a3..52892e8d 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-09-09 Masami Hiramatsu <mhiramat@redhat.com> + + * systemtap.base/marker.exp : Added testcases of $name. + 2008-09-06 Frank Ch. Eigler <fche@elastic.org> * systemtap.base/cmd_parse.exp: Adapt to sh-c-less "stap -c" diff --git a/testsuite/systemtap.base/marker.exp b/testsuite/systemtap.base/marker.exp index 89c0b8c3..0cacf60d 100644 --- a/testsuite/systemtap.base/marker.exp +++ b/testsuite/systemtap.base/marker.exp @@ -230,3 +230,48 @@ if {$kernel_markers_found == 0} { [lindex $kernel_marker_names 0] "foo"] stap_compile $TEST_NAME 0 $script } + +set TEST_NAME "K_MARKER18" +if {$kernel_markers_found == 0} { + untested "$TEST_NAME : no kernel markers present" +} else { + # Try compiling a script that prints the name string of a + # marker. + set script [format $kernel_script_arg \ + [lindex $kernel_marker_names 0] {\$name}] + stap_compile $TEST_NAME 1 $script +} + +set TEST_NAME "K_MARKER19" +if {$kernel_markers_found == 0} { + untested "$TEST_NAME : no kernel markers present" +} else { + # Try compiling a script that writes to a marker name string + # (which isn't allowed). + set script [format $kernel_script_arg2 \ + [lindex $kernel_marker_names 0] {\$name}] + stap_compile $TEST_NAME 0 $script +} + +set TEST_NAME "K_MARKER20" +if {$kernel_markers_found == 0} { + untested "$TEST_NAME : no kernel markers present" +} else { + # Try compiling a script that treats the marker name string as a + # structure (which isn't allowed). + set script [format $kernel_script_arg \ + [lindex $kernel_marker_names 0] {\$name->foo}] + stap_compile $TEST_NAME 0 $script +} + +set TEST_NAME "K_MARKER21" +if {$kernel_markers_found == 0} { + untested "$TEST_NAME : no kernel markers present" +} else { + # Try compiling a script that treats the marker name string like + # an array (which isn't allowed). + set script [format $kernel_script_arg \ + [lindex $kernel_marker_names 0] {\$name\[0\]}] + stap_compile $TEST_NAME 0 $script +} + diff --git a/translate.cxx b/translate.cxx index 2fe33314..e5435fac 100644 --- a/translate.cxx +++ b/translate.cxx @@ -881,6 +881,8 @@ c_unparser::emit_common_header () o->newline() << "struct kretprobe_instance *pi;"; o->newline() << "int regparm;"; o->newline() << "va_list *mark_va_list;"; + o->newline() << "const char * marker_name;"; + o->newline() << "const char * marker_format;"; o->newline() << "void *data;"; o->newline() << "#ifdef STP_TIMING"; o->newline() << "Stat *statp;"; |