From 59c11f912be76f0a8e37541d9b25e621daff61ca Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 28 Sep 2009 17:12:04 +0200 Subject: Use dwlpp::setup_kernel for tracepoint modules. Tracepoint modules ended up going through dwflpp::setup_user() because there was no setup_kernel that takes a list of module names. * dwflpp.h: Add kernel_p bool to constructor that takes a module list. Add setup_kernel() variant that takes a module list. * dwflpp.cxx: Likewise. * tapsets.cxx (tracepoint_builder::init_dw): Call dwflpp constructor indicating we expect kernel modules. --- dwflpp.cxx | 37 +++++++++++++++++++++++++++++++++---- dwflpp.h | 3 ++- tapsets.cxx | 2 +- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/dwflpp.cxx b/dwflpp.cxx index 4ef9f76b..cc882e5d 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -83,16 +83,18 @@ dwflpp::dwflpp(systemtap_session & session, const string& name, bool kernel_p): } } - -dwflpp::dwflpp(systemtap_session & session, const vector& names): +dwflpp::dwflpp(systemtap_session & session, const vector& names, + bool kernel_p): sess(session), module(NULL), module_bias(0), mod_info(NULL), module_start(0), module_end(0), cu(NULL), dwfl(NULL), module_dwarf(NULL), function(NULL), blacklist_enabled(false) { - setup_user(names); + if (kernel_p) + setup_kernel(names); + else + setup_user(names); } - dwflpp::~dwflpp() { delete_map(module_cu_cache); @@ -318,6 +320,33 @@ dwflpp::setup_kernel(const string& name, bool debuginfo_needed) build_blacklist(); } +void +dwflpp::setup_kernel(const vector &names, bool debuginfo_needed) +{ + if (! sess.module_cache) + sess.module_cache = new module_cache (); + + unsigned offline_search_matches = 0; + set offline_search_names(names.begin(), names.end()); + dwfl = setup_dwfl_kernel(offline_search_names, + &offline_search_matches, + sess); + + if (offline_search_matches < offline_search_names.size()) + { + if (debuginfo_needed) { + // Suggest a likely kernel dir to find debuginfo rpm for + string dir = string("/lib/modules/" + sess.kernel_release ); + find_debug_rpms(sess, dir.c_str()); + } + throw semantic_error (string("missing ") + sess.architecture + + string(" kernel/module debuginfo under '") + + sess.kernel_build_tree + string("'")); + } + + build_blacklist(); +} + void dwflpp::setup_user(const vector& modules, bool debuginfo_needed) diff --git a/dwflpp.h b/dwflpp.h index 5f04d824..979ec868 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -173,7 +173,7 @@ struct dwflpp std::string function_name; dwflpp(systemtap_session & session, const std::string& user_module, bool kernel_p); - dwflpp(systemtap_session & session, const std::vector& user_modules); + dwflpp(systemtap_session & session, const std::vector& user_modules, bool kernel_p); ~dwflpp(); void get_module_dwarf(bool required = false, bool report = true); @@ -293,6 +293,7 @@ private: Dwarf_Die * function; void setup_kernel(const std::string& module_name, bool debuginfo_needed = true); + void setup_kernel(const std::vector& modules, bool debuginfo_needed = true); void setup_user(const std::vector& modules, bool debuginfo_needed = true); module_cu_cache_t module_cu_cache; diff --git a/tapsets.cxx b/tapsets.cxx index 0767d4bf..4a8432f7 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -6164,7 +6164,7 @@ tracepoint_builder::init_dw(systemtap_session& s) // TODO: consider other sources of tracepoint headers too, like from // a command-line parameter or some environment or .systemtaprc - dw = new dwflpp(s, tracequery_modules); + dw = new dwflpp(s, tracequery_modules, true); return true; } -- cgit