diff options
Diffstat (limited to 'tapsets.cxx')
-rw-r--r-- | tapsets.cxx | 121 |
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, |