This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] support $$vars and $$parms
- From: Stan Cox <scox at redhat dot com>
- To: systemtap at sources dot redhat dot com
- Date: Thu, 24 Jul 2008 09:20:25 -0400
- Subject: [PATCH] support $$vars and $$parms
Given:
probe kernel.statement("bio_map_kern@fs/bio.c:850") {print ($$vars) }
Results:
q=0xffffffffdea58ca8 data=0xffffffffdf5c6d88 gfp_mask=0x10
bio=0xd5362c00
$$vars expands to sprintf("%#x %#x %#x %#x\n", parm1, parm2, var1, var2)
$$parms expands to sprintf("%#x %#x\n", parm1, parm2)
where parm are the function parameters and var are local variables live
at that location.
Testing and documentation are in progress.
/work/scox/systemtap/src /work/scox/systemtap/bld/i386-redhat-linux /work/scox/systemtap ~
diff --git a/ChangeLog b/ChangeLog
index d38a370..12680a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-07-24 Stan Cox <scox@redhat.com>
+
+ * tapsets.cxx (dwarf_var_expanding_copy_visitor::visit_target_symbol):
+ Add support for $$vars and $$parms.
+
2008-07-23 Frank Ch. Eigler <fche@elastic.org>
From James Bottomley <James.Bottomley@HansenPartnership.com>:
diff --git a/tapsets.cxx b/tapsets.cxx
index 5a3fbdc..185019b 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -2534,7 +2534,7 @@ struct dwarf_query : public base_query
// It arises because we sometimes try to fix up slightly-off
// .statement() probes (something we find out in fairly low-level).
//
-// An alternative would be to put some more intellgence into query_cu(),
+// An alternative would be to put some more intelligence into query_cu(),
// and have it print additional suggestions after finding that
// q->dw.iterate_over_srcfile_lines resulted in no new finished_results.
@@ -4248,6 +4248,79 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e)
return;
}
+ if (e->base_name == "$$vars" || e->base_name == "$$parms")
+ {
+ Dwarf_Die *scopes;
+ if (dwarf_getscopes_die (scope_die, &scopes) == 0)
+ return;
+
+ target_symbol *tsym = new target_symbol;
+ print_format* pf = new print_format;
+
+ // Convert $$parms to sprintf of a list of parms and active local vars
+ // which we recursively evaluate
+ token* tmp_tok = new token;
+ tmp_tok->type = tok_identifier;
+ tmp_tok->content = "sprintf";
+ pf->tok = tmp_tok;
+ pf->print_to_stream = false;
+ pf->print_with_format = true;
+ pf->print_with_delim = false;
+ pf->print_with_newline = false;
+ pf->print_char = false;
+
+ Dwarf_Die result;
+ if (dwarf_child (&scopes[0], &result) == 0)
+ do
+ {
+ switch (dwarf_tag (&result))
+ {
+ case DW_TAG_variable:
+ if (e->base_name == "$$parms")
+ continue;
+ case DW_TAG_formal_parameter:
+ break;
+
+ default:
+ continue;
+ }
+
+ const char *diename = dwarf_diename (&result);
+ token* sym_tok = new token;
+ sym_tok->location = e->get_tok()->location;
+ sym_tok->type = tok_identifier;
+ sym_tok->content = diename;
+ tsym->tok = sym_tok;
+ tsym->base_name = "$";
+ tsym->base_name += diename;
+ Dwarf_Attribute attr_mem;
+
+ // Ignore any variable that isn't accessible.
+ // dwarf_attr_integrate is checked by literal_stmt_for_local
+ // dwarf_getlocation_addr is checked by translate_location
+ // but if those fail we cannot catch semantic_error.
+ if (dwarf_attr_integrate (&result, DW_AT_location, &attr_mem) != NULL)
+ {
+ Dwarf_Op *expr;
+ size_t len;
+ if (dwarf_getlocation_addr (&attr_mem, addr - q.dw.module_bias,
+ &expr, &len, 1) == 0)
+ continue;
+ this->visit_target_symbol(tsym);
+ pf->raw_components += diename;
+ pf->raw_components += "=%#x ";
+ pf->args.push_back(*(expression**)this->targets.top());
+ }
+ }
+ while (dwarf_siblingof (&result, &result) == 0);
+
+ pf->raw_components += "\\n";
+ pf->components = print_format::string_to_components(pf->raw_components);
+ provide <print_format*> (this, pf);
+
+ return;
+ }
+
// Synthesize a function.
functiondecl *fdecl = new functiondecl;
fdecl->tok = e->tok;