From 5f8ca04fbb0682ff8647b4df5de68cd1042e312d Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 29 Sep 2009 00:12:26 +0200 Subject: Factor out duplicated code to setup user/module Dwfl from dwflpp/translate. * setupdwfl.h: Add setup_dwfl_user() and is_user_module(). * setupdwfl.cxx: Likewise. * dwflpp.cxx (setup_user): Use setup_dwfl_user(). * translate.cxx (emit_symbol_data): Likewise and is_user_module(). * tapsets.cxx (dwarf_cast_expanding_visitor::visit_cast_op): Use is_user_module(). --- translate.cxx | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'translate.cxx') diff --git a/translate.cxx b/translate.cxx index 1bb6252f..0f53dc78 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4957,8 +4957,9 @@ emit_symbol_data (systemtap_session& s) it++) { string foo = *it; - if (foo[0] != '/') /* Omit user-space, since we're only using this for - kernel space offline searches. */ + if (! is_user_module (foo)) /* Omit user-space, since we're only + using this for kernel space + offline searches. */ offline_search_modules.insert (foo); } Dwfl *dwfl = setup_dwfl_kernel (offline_search_modules, &count, s); @@ -4978,37 +4979,15 @@ emit_symbol_data (systemtap_session& s) // ---- step 2: process any user modules (files) listed - // XXX: see dwflpp::setup_user. - - // XXX: copied from tapsets.cxx dwflpp::, sadly - static const char *debuginfo_path_arr = "+:.debug:/usr/lib/debug:build"; - static const char *debuginfo_env_arr = getenv("SYSTEMTAP_DEBUGINFO_PATH"); - static const char *debuginfo_path = (debuginfo_env_arr ?: debuginfo_path_arr); - - static const Dwfl_Callbacks user_callbacks = - { - NULL, /* dwfl_linux_kernel_find_elf, */ - dwfl_standard_find_debuginfo, - NULL, /* ET_REL not supported for user space, only ET_EXEC and ET_DYN. - dwfl_offline_section_address, */ - (char **) & debuginfo_path - }; - for (std::set::iterator it = s.unwindsym_modules.begin(); it != s.unwindsym_modules.end(); it++) { string modname = *it; assert (modname.length() != 0); - if (modname[0] != '/') continue; // user-space files must be full paths - Dwfl *dwfl = dwfl_begin (&user_callbacks); - if (!dwfl) - throw semantic_error ("cannot create dwfl for " + modname); - - dwfl_report_begin (dwfl); - Dwfl_Module* mod = dwfl_report_offline (dwfl, modname.c_str(), modname.c_str(), -1); - dwfl_report_end (dwfl, NULL, NULL); - if (mod != 0) // tolerate missing data; will warn below + if (! is_user_module (modname)) continue; + Dwfl *dwfl = setup_dwfl_user (modname); + if (dwfl != NULL) // tolerate missing data; will warn below { ptrdiff_t off = 0; do -- cgit