summaryrefslogtreecommitdiffstats
path: root/tapsets.cxx
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2008-08-15 12:21:22 -0400
committerFrank Ch. Eigler <fche@elastic.org>2008-08-15 12:21:22 -0400
commita43ba4339f5b291d139e0be59bba4bc46c55ea25 (patch)
treeb53e416e8f36e483f5d8bd4a348759c8f9113755 /tapsets.cxx
parente9737939bdde53cfd6a2a16f0bd6494a05634ce8 (diff)
downloadsystemtap-steved-a43ba4339f5b291d139e0be59bba4bc46c55ea25.tar.gz
systemtap-steved-a43ba4339f5b291d139e0be59bba4bc46c55ea25.tar.xz
systemtap-steved-a43ba4339f5b291d139e0be59bba4bc46c55ea25.zip
PR6836: $$vars extensions, $$return
Diffstat (limited to 'tapsets.cxx')
-rw-r--r--tapsets.cxx121
1 files changed, 78 insertions, 43 deletions
diff --git a/tapsets.cxx b/tapsets.cxx
index 664dfb1f..1f7d2555 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -4002,7 +4002,11 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e)
if (lvalue && !q.sess.guru_mode)
throw semantic_error("write to target variable not permitted", e->tok);
- if (q.has_return && e->base_name != "$return")
+ // See if we need to generate a new probe to save/access function
+ // parameters from a return probe. PR 1382.
+ if (q.has_return
+ && e->base_name != "$return" // not the special return-value variable handled below
+ && e->base_name != "$$return") // nor the other special variable handled below
{
if (lvalue)
throw semantic_error("write to target variable not permitted in .return probes", e->tok);
@@ -4287,7 +4291,8 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e)
if (e->base_name == "$$vars"
|| e->base_name == "$$parms"
- || e->base_name == "$$locals")
+ || e->base_name == "$$locals"
+ || (q.has_return && (e->base_name == "$$return")))
{
Dwarf_Die *scopes;
if (dwarf_getscopes_die (scope_die, &scopes) == 0)
@@ -4298,55 +4303,85 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e)
// 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;
+
+ // NB: we synthesize a new token here rather than reusing
+ // e->tok, because print_format::print likes to use
+ // its tok->content.
+ token* pf_tok = new token;
+ pf_tok->location = e->tok->location;
+ pf_tok->type = tok_identifier;
+ pf_tok->content = "sprint";
+
+ pf->tok = pf_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;
- break;
- case DW_TAG_formal_parameter:
- if (e->base_name == "$$locals")
- continue;
- break;
-
- default:
- continue;
- }
+ if (q.has_return && (e->base_name == "$$return"))
+ {
+ tsym->tok = e->tok;
+ tsym->base_name = "$return";
+
+ // Ignore any variable that isn't accessible.
+ tsym->saved_conversion_error = 0;
+ this->visit_target_symbol(tsym); // NB: throws nothing ...
+ if (tsym->saved_conversion_error) // ... but this is how we know it happened.
+ {
- 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;
-
- // Ignore any variable that isn't accessible.
- tsym->saved_conversion_error = 0;
- this->visit_target_symbol(tsym); // NB: throws nothing ...
- if (! tsym->saved_conversion_error) // ... but this is how we know it happened.
+ }
+ else
+ {
+ pf->raw_components += "$return";
+ pf->raw_components += "=%#x ";
+ pf->args.push_back(*(expression**)this->targets.top());
+ }
+ }
+ else
+ {
+ // non-.return probe: support $$parms, $$vars, $$locals
+ Dwarf_Die result;
+ if (dwarf_child (&scopes[0], &result) == 0)
+ do
{
- pf->raw_components += diename;
- pf->raw_components += "=%#x ";
- pf->args.push_back(*(expression**)this->targets.top());
+ switch (dwarf_tag (&result))
+ {
+ case DW_TAG_variable:
+ if (e->base_name == "$$parms")
+ continue;
+ break;
+ case DW_TAG_formal_parameter:
+ if (e->base_name == "$$locals")
+ continue;
+ break;
+
+ default:
+ continue;
+ }
+
+ const char *diename = dwarf_diename (&result);
+ tsym->tok = e->tok;
+ tsym->base_name = "$";
+ tsym->base_name += diename;
+
+ // Ignore any variable that isn't accessible.
+ tsym->saved_conversion_error = 0;
+ this->visit_target_symbol(tsym); // NB: throws nothing ...
+ if (tsym->saved_conversion_error) // ... but this is how we know it happened.
+ {
+ pf->raw_components += diename;
+ pf->raw_components += "=? ";
+ }
+ else
+ {
+ pf->raw_components += diename;
+ pf->raw_components += "=%#x ";
+ pf->args.push_back(*(expression**)this->targets.top());
+ }
}
- }
- while (dwarf_siblingof (&result, &result) == 0);
+ while (dwarf_siblingof (&result, &result) == 0);
+ }
pf->components = print_format::string_to_components(pf->raw_components);
provide <print_format*> (this, pf);
@@ -4366,7 +4401,7 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e)
try
{
- if (q.has_return && e->base_name == "$return")
+ if (q.has_return && (e->base_name == "$return"))
{
ec->code = q.dw.literal_stmt_for_return (scope_die,
addr,