From 64c6aab0a7992ed950d01fec0d9592630af39ca4 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Tue, 24 Mar 2009 12:40:05 -0400 Subject: Keep static probe parameters visible while inlining. * includes/sys/sdt.h (STAP_PROBEN): Revive the STAP_LABEL macro to prevent inlining to keep probe parameters visible. Use +rm constraints. * tapsets.cxx (build): Use .probes section for all uses of static probes. --- tapsets.cxx | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index e9ade595..bc16d6fa 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -5731,8 +5731,6 @@ dwarf_builder::build(systemtap_session & sess, Elf* elf = dwfl_module_getelf (dw->module, &bias); size_t shstrndx; Elf_Scn *probe_scn = NULL; - bool probe_found = false; - bool dynamic = (dwfl_module_relocations (dw->module) == 1); dwfl_assert ("getshstrndx", elf_getshstrndx (elf, &shstrndx)); GElf_Shdr *shdr = NULL; @@ -5750,8 +5748,6 @@ dwarf_builder::build(systemtap_session & sess, break; } } - if (dynamic || sess.listing_mode) - probe_type = dwarf_no_probes; if (probe_type == probes_and_dwarf) { @@ -5779,9 +5775,7 @@ dwarf_builder::build(systemtap_session & sess, probe_arg = *((__uint64_t*)((char*)pdata->d_buf + probe_scn_offset)); if (probe_scn_offset % (sizeof(__uint64_t)*2)) probe_scn_offset = (probe_scn_offset + sizeof(__uint64_t)*2) - (probe_scn_offset % (sizeof(__uint64_t)*2)); - if (strcmp (location->components[1]->arg->tok->content.c_str(), probe_name.c_str()) == 0) - probe_found = true; - else + if (strcmp (location->components[1]->arg->tok->content.c_str(), probe_name.c_str()) != 0) continue; const token* sv_tok = location->components[1]->arg->tok; location->components[1]->functor = TOK_STATEMENT; @@ -5791,11 +5785,10 @@ dwarf_builder::build(systemtap_session & sess, dwarf_query q(sess, base, location, *dw, parameters, finished_results); dw->query_modules(&q); } - if (probe_found) - return; + return; } - if (probe_type == dwarf_no_probes || ! probe_found) + if (probe_type == dwarf_no_probes) { location->components[1]->functor = TOK_FUNCTION; location->components[1]->arg = new literal_string("*"); -- cgit From 3c1b3d06ef3134b30e804d189d346c5f83c6f3a6 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 24 Mar 2009 12:53:17 -0400 Subject: PR9993: tracepoint toleration for undeclared types in trace/*.h headers * tapsets.cxx (tracepoint_extra_headers): New function to return needed header file names. (emit_module_decls): Emit them. * buildrun.cxx (make_tracequery): Emit them. * testsuite/systemtap.base/tracepoints.exp: Rewrite to exercise building each tracepoint. --- tapsets.cxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index bc16d6fa..3a181cb3 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -9582,6 +9582,7 @@ tracepoint_derived_probe::tracepoint_derived_probe (systemtap_session& s, // tracepoints from FOO_event_types.h should really be included from FOO.h // XXX can dwarf tell us the include hierarchy? it would be better to // ... walk up to see which one was directly included by tracequery.c + // XXX: see also PR9993. header_pos = header.find("_event_types"); if (header_pos != string::npos) header.erase(header_pos, 12); @@ -9757,6 +9758,16 @@ tracepoint_derived_probe::emit_probe_context_vars (translator_output* o) } +static vector tracepoint_extra_headers () +{ + vector they_live; + // PR 9993 + // XXX: may need this to be configurable + they_live.push_back ("linux/skbuff.h"); + return they_live; +} + + void tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s) { @@ -9766,6 +9777,12 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "/* ---- tracepoint probes ---- */"; s.op->newline(); + // PR9993: Add extra headers to work around undeclared types in individual + // include/trace/foo.h files + const vector& extra_headers = tracepoint_extra_headers (); + for (unsigned z=0; znewline() << "#include <" << extra_headers[z] << ">\n"; + for (unsigned i = 0; i < probes.size(); ++i) { tracepoint_derived_probe *p = probes[i]; @@ -9963,6 +9980,7 @@ private: bool init_dw(systemtap_session& s); public: + tracepoint_builder(): dw(0) {} ~tracepoint_builder() { delete dw; } @@ -10009,7 +10027,7 @@ tracepoint_builder::init_dw(systemtap_session& s) // no cached module, time to make it string tracequery_ko; - int rc = make_tracequery(s, tracequery_ko); + int rc = make_tracequery(s, tracequery_ko, tracepoint_extra_headers()); if (rc != 0) return false; -- cgit From 30369ac1fe0ed4e022691eceaddb848689935f87 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 24 Mar 2009 15:11:33 -0400 Subject: build fix for RHEL4-era gcc 3.4.6 * tapsets.cxx (stringhash): Go to __gnu_cxx. (dwarf_cast_expanding_visitor::visit_cast_op): Use ~0 for all-ones. --- tapsets.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 3a181cb3..c36a1aa0 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -603,7 +603,8 @@ typedef tr1::unordered_map cu_function_cache_t; typedef tr1::unordered_map mod_cu_function_cache_t; // module:cu -> function -> die #else struct stringhash { - size_t operator() (const string& s) const { hash h; return h(s.c_str()); } + // __gnu_cxx:: is needed because our own hash.h has an ambiguous hash<> decl too. + size_t operator() (const string& s) const { __gnu_cxx::hash h; return h(s.c_str()); } }; typedef hash_map cu_function_cache_t; @@ -5022,7 +5023,7 @@ void dwarf_cast_expanding_visitor::visit_cast_op (cast_op* e) string code; exp_type type = pe_long; - size_t mod_end = -1; + size_t mod_end = ~0; do { // split the module string by ':' for alternatives -- cgit