From ff8bd809e1409525db178b3e8685f89f27c4ac1f Mon Sep 17 00:00:00 2001 From: Abegail Jakop Date: Tue, 15 Jul 2014 14:38:35 -0400 Subject: [PATCH] tapsets.cxx: rearranged code to reflect original order --- tapsets.cxx | 344 ++++++++++++++++++++++++++-------------------------- 1 file changed, 172 insertions(+), 172 deletions(-) diff --git a/tapsets.cxx b/tapsets.cxx index 23dda59e0..68b36ec0a 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -510,177 +510,6 @@ private: void saveargs(dwarf_query& q, Dwarf_Die* scope_die, Dwarf_Addr dwfl_addr); }; -// Helper struct to thread through the dwfl callbacks. -struct base_query -{ - base_query(dwflpp & dw, literal_map_t const & params); - base_query(dwflpp & dw, const string & module_val); - virtual ~base_query() {} - - systemtap_session & sess; - dwflpp & dw; - - // Used to keep track of which modules were visited during - // iterate_over_modules() - set visited_modules; - - // Parameter extractors. - static bool has_null_param(literal_map_t const & params, - string const & k); - static bool get_string_param(literal_map_t const & params, - string const & k, string & v); - static bool get_number_param(literal_map_t const & params, - string const & k, long & v); - static bool get_number_param(literal_map_t const & params, - string const & k, Dwarf_Addr & v); - static void query_library_callback (base_query *me, const char *data); - static void query_plt_callback (base_query *me, const char *link, size_t addr); - virtual void query_library (const char *data) = 0; - virtual void query_plt (const char *link, size_t addr) = 0; - - - // Extracted parameters. - bool has_kernel; - bool has_module; - bool has_process; - bool has_library; - bool has_plt; - bool has_statement; - string module_val; // has_kernel => module_val = "kernel" - string path; // executable path if module is a .so - string plt_val; // has_plt => plt wildcard - int64_t pid_val; - - virtual void handle_query_module() = 0; -}; - -struct dwarf_query : public base_query -{ - dwarf_query(probe * base_probe, - probe_point * base_loc, - dwflpp & dw, - literal_map_t const & params, - vector & results, - const string user_path, - const string user_lib); - - vector & results; - set inlined_non_returnable; // function names - probe * base_probe; - probe_point * base_loc; - string user_path; - string user_lib; - - set visited_libraries; - bool resolved_library; - - virtual void handle_query_module(); - void query_module_dwarf(); - void query_module_symtab(); - void query_library (const char *data); - void query_plt (const char *entry, size_t addr); - - void add_probe_point(string const & funcname, - char const * filename, - int line, - Dwarf_Die *scope_die, - Dwarf_Addr addr); - - void mount_well_formed_probe_point(); - void unmount_well_formed_probe_point(); - stack > previous_bases; - - void replace_probe_point_component_arg(const string& functor, - const string& new_functor, - int64_t new_arg, - bool hex = false); - void replace_probe_point_component_arg(const string& functor, - int64_t new_arg, - bool hex = false); - void replace_probe_point_component_arg(const string& functor, - const string& new_functor, - const string& new_arg); - void replace_probe_point_component_arg(const string& functor, - const string& new_arg); - void remove_probe_point_component(const string& functor); - - // Track addresses we've already seen in a given module - set alias_dupes; - - // Track inlines we've already seen as well - // NB: this can't be compared just by entrypc, as inlines can overlap - set inline_dupes; - - // Used in .callee[s] probes, when calling iterate_over_callees() (which - // provides the actual stack). Retains the addrs of the callers unwind addr - // where the callee is found. Specifies multiple callers. E.g. when a callee - // at depth 2 is found, callers[1] has the addr of the caller, and callers[0] - // has the addr of the caller's caller. - stack *callers; - - bool has_function_str; - bool has_statement_str; - bool has_function_num; - bool has_statement_num; - string statement_str_val; - string function_str_val; - Dwarf_Addr statement_num_val; - Dwarf_Addr function_num_val; - - bool has_call; - bool has_exported; - bool has_inline; - bool has_return; - - bool has_maxactive; - long maxactive_val; - - bool has_label; - string label_val; - - bool has_callee; - string callee_val; - - bool has_callees_num; - long callees_num_val; - - bool has_relative; - long relative_val; - - bool has_absolute; - - bool has_mark; - - enum dbinfo_reqt dbinfo_reqt; - enum dbinfo_reqt assess_dbinfo_reqt(); - - void parse_function_spec(const string & spec); - function_spec_type spec_type; - vector scopes; - string function; - string file; - lineno_t lineno_type; - vector linenos; - bool query_done; // Found exact match - - // Holds the prologue end of the current function - Dwarf_Addr prologue_end; - - set filtered_srcfiles; - - // Map official entrypc -> func_info object - inline_instance_map_t filtered_inlines; - func_info_map_t filtered_functions; - - // Helper when we want to iterate over both - base_func_info_map_t filtered_all(); - - void query_module_functions (); - - string final_function_name(const string& final_func, - const char* final_file, - int final_line); -}; struct uprobe_derived_probe: public dwarf_derived_probe { @@ -733,6 +562,50 @@ public: void emit_module_exit (systemtap_session& s); }; +// Helper struct to thread through the dwfl callbacks. +struct base_query +{ + base_query(dwflpp & dw, literal_map_t const & params); + base_query(dwflpp & dw, const string & module_val); + virtual ~base_query() {} + + systemtap_session & sess; + dwflpp & dw; + + // Used to keep track of which modules were visited during + // iterate_over_modules() + set visited_modules; + + // Parameter extractors. + static bool has_null_param(literal_map_t const & params, + string const & k); + static bool get_string_param(literal_map_t const & params, + string const & k, string & v); + static bool get_number_param(literal_map_t const & params, + string const & k, long & v); + static bool get_number_param(literal_map_t const & params, + string const & k, Dwarf_Addr & v); + static void query_library_callback (base_query *me, const char *data); + static void query_plt_callback (base_query *me, const char *link, size_t addr); + virtual void query_library (const char *data) = 0; + virtual void query_plt (const char *link, size_t addr) = 0; + + + // Extracted parameters. + bool has_kernel; + bool has_module; + bool has_process; + bool has_library; + bool has_plt; + bool has_statement; + string module_val; // has_kernel => module_val = "kernel" + string path; // executable path if module is a .so + string plt_val; // has_plt => plt wildcard + int64_t pid_val; + + virtual void handle_query_module() = 0; +}; + base_query::base_query(dwflpp & dw, literal_map_t const & params): sess(dw.sess), dw(dw), has_library(false), has_plt(false), has_statement(false), pid_val(0) @@ -855,8 +728,135 @@ base_query::get_number_param(literal_map_t const & params, return present; } -static void delete_session_module_cache (systemtap_session& s); // forward decl +struct dwarf_query : public base_query +{ + dwarf_query(probe * base_probe, + probe_point * base_loc, + dwflpp & dw, + literal_map_t const & params, + vector & results, + const string user_path, + const string user_lib); + + vector & results; + set inlined_non_returnable; // function names + probe * base_probe; + probe_point * base_loc; + string user_path; + string user_lib; + + set visited_libraries; + bool resolved_library; + + virtual void handle_query_module(); + void query_module_dwarf(); + void query_module_symtab(); + void query_library (const char *data); + void query_plt (const char *entry, size_t addr); + + void add_probe_point(string const & funcname, + char const * filename, + int line, + Dwarf_Die *scope_die, + Dwarf_Addr addr); + + void mount_well_formed_probe_point(); + void unmount_well_formed_probe_point(); + stack > previous_bases; + + void replace_probe_point_component_arg(const string& functor, + const string& new_functor, + int64_t new_arg, + bool hex = false); + void replace_probe_point_component_arg(const string& functor, + int64_t new_arg, + bool hex = false); + void replace_probe_point_component_arg(const string& functor, + const string& new_functor, + const string& new_arg); + void replace_probe_point_component_arg(const string& functor, + const string& new_arg); + void remove_probe_point_component(const string& functor); + + // Track addresses we've already seen in a given module + set alias_dupes; + + // Track inlines we've already seen as well + // NB: this can't be compared just by entrypc, as inlines can overlap + set inline_dupes; + + // Used in .callee[s] probes, when calling iterate_over_callees() (which + // provides the actual stack). Retains the addrs of the callers unwind addr + // where the callee is found. Specifies multiple callers. E.g. when a callee + // at depth 2 is found, callers[1] has the addr of the caller, and callers[0] + // has the addr of the caller's caller. + stack *callers; + + bool has_function_str; + bool has_statement_str; + bool has_function_num; + bool has_statement_num; + string statement_str_val; + string function_str_val; + Dwarf_Addr statement_num_val; + Dwarf_Addr function_num_val; + + bool has_call; + bool has_exported; + bool has_inline; + bool has_return; + + bool has_maxactive; + long maxactive_val; + + bool has_label; + string label_val; + + bool has_callee; + string callee_val; + + bool has_callees_num; + long callees_num_val; + + bool has_relative; + long relative_val; + + bool has_absolute; + + bool has_mark; + enum dbinfo_reqt dbinfo_reqt; + enum dbinfo_reqt assess_dbinfo_reqt(); + + void parse_function_spec(const string & spec); + function_spec_type spec_type; + vector scopes; + string function; + string file; + lineno_t lineno_type; + vector linenos; + bool query_done; // Found exact match + + // Holds the prologue end of the current function + Dwarf_Addr prologue_end; + + set filtered_srcfiles; + + // Map official entrypc -> func_info object + inline_instance_map_t filtered_inlines; + func_info_map_t filtered_functions; + + // Helper when we want to iterate over both + base_func_info_map_t filtered_all(); + + void query_module_functions (); + + string final_function_name(const string& final_func, + const char* final_file, + int final_line); +}; + +static void delete_session_module_cache (systemtap_session& s); // forward decl struct dwarf_builder: public derived_probe_builder { -- 2.43.5