From ac4229f1050ee69b3ebfe57e6f7fcee08aaeceec Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Mon, 11 Aug 2008 19:52:00 -0400 Subject: let $$vars work even with unsupported c types (e.g., funkytown floats) --- tapsets.cxx | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 73a104b4..b35bc338 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2060,6 +2060,33 @@ struct dwflpp case DW_TAG_enumeration_type: case DW_TAG_base_type: + + // Reject types we can't handle in systemtap + { + dname = dwarf_diename(die); + diestr = (dname != NULL) ? dname : ""; + + Dwarf_Attribute encoding_attr; + Dwarf_Word encoding = -1; + dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding, &encoding_attr), + & encoding); + if (encoding < 0) + { + // clog << "bad type1 " << encoding << " diestr" << endl; + throw semantic_error ("unsupported type (mystery encoding " + lex_cast(encoding) + ")" + + " for " + diestr); + } + + if (encoding == DW_ATE_float + || encoding == DW_ATE_complex_float + /* XXX || many others? */) + { + // clog << "bad type " << encoding << " diestr" << endl; + throw semantic_error ("unsupported type (encoding " + lex_cast(encoding) + ")" + + " for " + diestr); + } + } + ty = pe_long; if (lvalue) c_translate_store (pool, 1, module_bias, die, typedie, tail, @@ -2198,7 +2225,6 @@ struct dwflpp throw semantic_error("failed to retrieve type " "attribute for local '" + local + "'"); - /* Translate the ->bar->baz[NN] parts. */ Dwarf_Die die_mem, *die = NULL; @@ -4309,24 +4335,16 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e) 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()); - } + 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 += "=%#x "; + pf->args.push_back(*(expression**)this->targets.top()); + } } while (dwarf_siblingof (&result, &result) == 0); -- cgit From 6503a1cce1cb2a2b88819b414650bd85340a4381 Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Mon, 11 Aug 2008 20:25:51 -0400 Subject: Fixed compilation warning on gcc 3.x --- tapsets.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index b35bc338..6dcd2c00 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2067,7 +2067,7 @@ struct dwflpp diestr = (dname != NULL) ? dname : ""; Dwarf_Attribute encoding_attr; - Dwarf_Word encoding = -1; + Dwarf_Word encoding = (Dwarf_Word) -1; dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding, &encoding_attr), & encoding); if (encoding < 0) -- cgit From 6cdf2889024b6538665a00f2ecd7321626624bb8 Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 12 Aug 2008 10:18:56 -0500 Subject: PR 6445 (partial). Implemented system-wide utrace probes. 2008-08-12 David Smith PR 6445 (partial) * tapsets.cxx (utrace_builder::build): Validates pid and allows probing of "*" to mean all threads. * stapprobes.5.in: Added note about a process path of "*" means to probe all threads. 2008-08-12 David Smith PR 6445 (partial) * task_finder.c (stap_register_task_finder_target): Handles probing all threads. (__stp_utrace_attach_match_filename): Ditto. (stap_start_task_finder): Ditto. 2008-08-12 David Smith PR 6445 (partial) * systemtap.base/utrace_p4.exp: Added test that probes all threads. * semko/utrace14.stp: New test. --- tapsets.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 6dcd2c00..664dfb1f 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -5931,8 +5931,25 @@ struct utrace_builder: public derived_probe_builder else if (has_null_param (parameters, TOK_END)) flags = UDPF_END; - // If we have a path, we need to validate it. - if (has_path) + // Validate pid. + if (has_pid) + { + // We can't probe 'init' (pid 1). + if (pid < 2) + throw semantic_error ("process pid must be greater than 1", + location->tok); + } + // If we have a path whose value is "*", this means to probe + // everything. Convert this to a pid-based probe. + else if (has_path && path == "*") + { + has_path = false; + path.clear(); + has_pid = true; + pid = 0; + } + // If we have a regular path, we need to validate it. + else if (has_path) { string::size_type start_pos, end_pos; string component; -- cgit From a43ba4339f5b291d139e0be59bba4bc46c55ea25 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 15 Aug 2008 12:21:22 -0400 Subject: PR6836: $$vars extensions, $$return --- tapsets.cxx | 121 +++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 43 deletions(-) (limited to 'tapsets.cxx') 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 (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, -- cgit From fd5747054ac2a5c90d209195c55e6310972f969a Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 15 Aug 2008 14:46:27 -0400 Subject: PR6836: tweak $$return formatting --- tapsets.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 1f7d2555..f661b7e4 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -4333,7 +4333,7 @@ dwarf_var_expanding_copy_visitor::visit_target_symbol (target_symbol *e) } else { - pf->raw_components += "$return"; + pf->raw_components += "return"; pf->raw_components += "=%#x "; pf->args.push_back(*(expression**)this->targets.top()); } -- cgit From 986e98de88e5a55451aaf24a6ead7f44725124c1 Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 15 Aug 2008 14:02:31 -0500 Subject: Change system-wide probes from 'process("*").begin' to 'process.begin'. 2008-08-15 David Smith * tapsets.cxx (utrace_builder::build): Change system-wide probes from 'process("*").begin' to 'process.begin'. (register_standard_tapsets): Add new 'process' binding. * stapprobes.5.in: Change system-wide probes from 'process("*").begin' to 'process.begin'. 2008-08-15 David Smith * systemtap.base/utrace_p4.exp: Change system-wide probes from 'process("*").begin' to 'process.begin'. --- tapsets.cxx | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 1f7d2555..60d9a377 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -5945,7 +5945,6 @@ struct utrace_builder: public derived_probe_builder bool has_path = get_param (parameters, TOK_PROCESS, path); bool has_pid = get_param (parameters, TOK_PROCESS, pid); enum utrace_derived_probe_flags flags = UDPF_NONE; - assert (has_path || has_pid); if (has_null_param (parameters, TOK_THREAD)) { @@ -5966,23 +5965,23 @@ struct utrace_builder: public derived_probe_builder else if (has_null_param (parameters, TOK_END)) flags = UDPF_END; + // If we didn't get a path or pid, this means to probe everything. + // Convert this to a pid-based probe. + if (! has_path && ! has_pid) + { + has_path = false; + path.clear(); + has_pid = true; + pid = 0; + } // Validate pid. - if (has_pid) + else if (has_pid) { // We can't probe 'init' (pid 1). if (pid < 2) throw semantic_error ("process pid must be greater than 1", location->tok); } - // If we have a path whose value is "*", this means to probe - // everything. Convert this to a pid-based probe. - else if (has_path && path == "*") - { - has_path = false; - path.clear(); - has_pid = true; - pid = 0; - } // If we have a regular path, we need to validate it. else if (has_path) { @@ -8897,18 +8896,26 @@ register_standard_tapsets(systemtap_session & s) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_BEGIN) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_BEGIN) + ->bind(new utrace_builder ()); s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_END) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_END) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_END) + ->bind(new utrace_builder ()); s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_BEGIN) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_BEGIN) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_BEGIN) + ->bind(new utrace_builder ()); s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_END) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_END) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_END) + ->bind(new utrace_builder ()); // itrace user-space probes s.pattern_root->bind_str(TOK_PROCESS)->bind("itrace") -- cgit