| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
* dwflpp.cxx (build_blacklist): Add a few more entries.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we have many individual function lookups, like the nearly 1000 with
syscall.*, each one will iterate every CU in the module (M) and then do a
cache lookup in N entries. That's a thousand MlogN lookups.
We can instead keep the functions in a module-wide map, and then the
complexity is just a thousand logMN lookups.
Before:
$ ./run-stap -l 'syscall.**' --vp 01 >/dev/null
Pass 2: analyzed script: 793 probe(s), 11 function(s), 20 embed(s),
0 global(s) using 245872virt/147304res/78272shr kb,
in 1390usr/60sys/1448real ms.
After:
$ ./run-stap -l 'syscall.**' --vp 01 >/dev/null
Pass 2: analyzed script: 793 probe(s), 11 function(s), 20 embed(s),
0 global(s) using 246228virt/147616res/78276shr kb,
in 720usr/60sys/782real ms.
* dwflpp.cxx (dwflpp::iterate_single_function): Do a simple function
lookup based on a module-wide cache.
(dwflpp::mod_function_caching_callback): Helper for above.
* tapsets.cxx (dwarf_query::query_module_functions): Query a single
function from the module-wide cache.
(dwarf_query::query_module_dwarf): Use above for simple cases.
|
|
|
|
|
|
| |
* dwflpp.cxx (dwflpp::iterate_over_functions): No caller is using
has_statement_num anymore (since 6b517475), so kill it.
* tapsets.cxx (query_cu): Let the default call rule the day.
|
|
|
|
| |
* dwflpp.cxx (build_blacklist): Add special_mapping_*
|
|
|
|
| |
* dwflpp.cxx (get_cfa_ops): Guard new cfi related code and variables.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
dwflpp::translate_location() works on the dw address space, but
get_cfa_ops() starts out with dwfl calls (only dwarf_cfi_addrframe()
needs to be adjusted for bias).
* dwflpp.cxx (translate_location): Pass pc plus module bias through to
get_cfa_ops.
(get_cfa_ops): Adjust for bias when calling dwarf_cfi_addrframe(),
add frame start/end address when found if verbose logging.
* testsuite/systemtap.exelib/lib.stp: Add $foo and $bar variables to
process.function probes.
* testsuite/systemtap.exelib/libmarkunamestack.stp: Likewise.
* testsuite/systemtap.exelib/lib.tcl: Expect correct values for
process.function probe variables.
* testsuite/systemtap.exelib/libmarkunamestack.tcl: Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Our literal_addr_to_sym_addr() function was just wrong. To compensate for
raw addresses read from elf (either given by the user or through a mark
transformation) we need to know what the elf_bias is (as returned by
dwfl_module_getelf) before feeding them to any libdwfl functions.
* tapsets.cxx (query_module_dwarf): Always add elf_bias to raw function or
statement addresses before calling query_addr().
(query_addr): Don't call literal_addr_to_sym_addr().
* dwflpp.h (literal_addr_to_sym_addr): Removed.
* dwflpp.cxx (literal_addr_to_sym_addr): Likewise.
|
|
|
|
|
|
|
|
|
| |
If a line number is invalid for a source file, that should not be a
fatal error, as it may still be valid for some other matching source
file.
* dwflpp.cxx (dwflpp::iterate_over_srcfile_lines): Don't assert that the
line must be found, just break out quietly.
|
|
|
|
|
|
|
|
| |
The fix for PR10923 (fafeaf) wasn't completely correct. All cfa lookups
need to be done through the relative pc (without bias) of the module we
are looking in.
* dwflpp.cxx (translate_location): Call get_cfa_ops with relative pc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* runtime/task_finder_vma.c (stap_remove_vma_map_info): Return negative
status on failure.
(stap_find_vma_map_info): Likewise.
(stap_find_vma_map_info_user): New function.
(stap_drop_vma_maps): New function.
* runtime/sym.h (addr): Renamed to static_addr, to store addresses for
sections which are always mapped at the same address.
(_stp_module_relocate): Add extra struct task_struct *tsk argument.
* runtime/sym.c (_stp_tf_exec_cb): New callback, calls stap_drop_vma_maps.
(_stp_tf_mmap_cb): Don't store address in module.section, but call
stap_add_vma_map_info() per tsk->group_leader for matched module.
Don't register empty/null modules.
(_stp_module_relocate): Take extra struct task_struct *tsk argument,
cache last tsk used. Only use section->static_addr for none dynamic
modules. Use stap_find_vma_map_info_user() to locate dynamic modules.
(_stp_mod_sec_lookup): Add extra argument unsigned long *rel_addr to
optionally store relative address when module/section found.
(_stp_kallsyms_lookup): Use _stp_mod_sec_lookup to find relative address.
(_stp_sym_init): Register _stp_tf_exec_cb in stap_task_finder_target.
Add error check to see if task finder could be initialized.
* dwflpp.cxx (emit_address): Pass NULL for kernel/modules and current for
user tasks to _stp_module_relocate.
* runtime/transport/symbols.c (_stp_do_relocation): Set new static_addr
_stp_section field.
* runtime/unwind.c (adjustStartLoc): Take new struct task_struct *tsk
argument and pass to stap_find_vma_map_info_user and _stp_module_relocate
to find adjusted addr.
(_stp_search_unwind_hdr): Pass through struct task_struct *tsk.
(unwind_frame): Likewise.
* tapset/context-symbols.stp (probemod): Add NULL to _stp_mod_sec_lookup
call to indicate we aren't interested in relative address.
* tapsets.cxx (dwarf_derived_probe_group::emit_module_init): Pass NULL to
_stp_module_relocate to indicate kernel/module address.
|
|
|
|
| |
* dwflpp.cxx (resolve_prologue_endings): Skip entrypc=0.
|
|
|
|
|
|
|
|
|
|
|
| |
* dwflpp.h (declaration_resolve_other_cus): New method.
(iterate_over_globals): Mark as static and takes a CU to iterate over.
(global_alias_caching_callback_cus): New method.
* dwflpp.cxx (global_alias_caching_callback_cus): New method.
(declaration_resolve_other_cus): New method.
(declaration_resolve): Call iterate_over_globals() with current cu.
Call declaration_resolve_other_cus() when name not found.
(iterate_over_globals): Takes cu_die to iterate over as argument.
|
|
|
|
|
|
|
|
| |
If there is a DW_AT_MIPS_linkage_name it encodes the actual name of
the variable as used in the symbol table.
* dwflpp.cpp (vardie_from_symtable): Check whether there is a
DW_AT_MIPS_linkage_name attribute and use its value if so.
|
|
|
|
|
|
|
|
|
|
| |
Caching of the address is only safe for kernel addresses that can never
change. For kernel module or dynamic shared library addresses it isn't
safe to cache the address since they can be unloaded, reloaded or mapped
differently in separate executables.
* dwflpp.cxx (emit_address): Remove static from addr definition for
kernel and dynamic modules.
|
|
|
|
|
|
|
|
| |
* dwflpp.cxx (dwflpp::emit_address): Enable task finder and emit a
_stp_module_relocate for the ".dynamic" section when seeing a
user-space dso address.
* runtime/sym.c (_stp_mod_sec_lookup): Remove .dynamic section addr cheat.
(_stp_tf_mmap_cb): Add cheat here.
|
|
|
|
|
|
|
|
| |
* dwflpp.h (vardie_from_symtable): New method.
* dwflpp.cxx (vardie_from_symtable): New method.
(literal_stmt_for_local): Use vardie_from_symtable when no location
attribute and DW_AT_external.
* testsuite/buildok/xtime.stp: New testcase from PR10622.
|
|
|
|
|
|
|
|
| |
dwarf_cfi_addrframe should not be called with pc adjusted to the bias
of the dwfl_module_dwarf_cfi or dwfl_module_eh_cfi. This just happened to
work in the .eh_frame case because bias was always zero.
* dwflpp.cxx (get_cfa_ops): Don't adjust pc for bias.
|
|
|
|
| |
* dwflpp.cxx (dwflpp::express_as_string): Limit stack depth to 32.
|
| |
|
|
|
|
|
|
| |
* dwflpp.cxx (translate_location): Call c_translate_constant when
attribute is DW_AT_const_value.
(literal_stmt_for_local): Allow both DW_AT_location and DW_AT_const_value.
|
|
|
|
|
|
|
|
|
|
| |
* setupdwfl.h: Introduce DwflPtr.
* setupdwfl.cxx: Cache kernel_dwfl and user_dwfl. Keep track of last used
module strings. Return cached versions if same query used.
* dwflpp.h: Use DwflPtr instead of Dwfl*.
* dwflpp.cxx: Use DwflPtr and don't dwfl_end().
* translate.cxx: Likewise. Run through dwfl_getmodules() with returned
ptr offset.
|
|
|
|
|
|
|
|
|
| |
* 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().
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
* setupdwfl.h: New header file.
* setupdwfl.cxx: New source file containing shared setup_dwfl_kernel() code.
* dwflpp.cxx (dwfl_report_offline_predicate): Removed.
(setup_kernel): Call setup_dwfl_kernel().
* translate.cxx (dwfl_report_offline_predicate2): Remove.
(emit_symbol_data): Call setup_dwfl_kernel().
* Makefile.am (stap_SOURCES): Add setupdwfl.cxx.
* Makefile.in: Regenerated.
|
|
|
|
| |
* dwflpp.c (die_entrypc): Reject entrypc=0 functions.
|
|
|
|
|
| |
* dwflpp.cxx (translate_location) [!_ELFUTILS_PREREQ (0,142)]:
Pass new argument to c_translate_location.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Preparation for retrieving the Dwarf_Block that holds the value of an
DW_OP_implicit_value. We need the Dwarf_Attribute that is associated with
the location expression operants. Depends on new elfutils 0.143
functionality. Recognizes, but does not yet handle the new operants
DW_OP_{implicit,stack}_value.
* loc2c.h (c_translate_location): Take an Dwarf_Attribute.
* loc2c.c (c_translate_location): Likewise and pass it on.
(location_relative): Likewise.
(location_from_address): Likewise.
(translate): Likewise and capture Dwarf_Block.
* loc2c-test.c (handle_variable): Pass in Dwarf_Attribute.
* dwflpp.cxx (translate_location): Likewise.
(literal_stmt_for_return): Pass in NULL to indicate no attribute.
|
|
|
|
|
| |
* dwflpp.cxx(translate_location): Separate setting value from
declaration and add missing parameter.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The function spec for dwarf probes now supports scopes, so you can limit
the probes to specific namespaces or classes. Multiple scopes can be
specified, and they will be matched progressively outward.
probe process("foo").function("std::vector<*>::*") { ... }
probe process("foo").function("::global_function") { ... }
* dwflpp.cxx (dwflpp::get_parent_scope): New, finds the containing
scopes of the specified DIE.
(dwflpp::function_scope_matches): New, checks that the scopes
containing the function all match the given scope patterns.
* tapsets.cxx (dwarf_query::parse_function_spec): Rewrite, now handles
multiple scope separators too.
(query_dwarf_func): Check that the functions scopes match.
|
|
|
|
| |
* dwflpp.cxx (dwflpp::function_name_final_match): Removed.
|
|
|
|
|
|
|
|
|
|
|
| |
Do the same workaround as loc2c-test.c does. Just treat a constant member
location offset as a DW_OP_plus_uconst and call c_translate_location for it.
Also Remove c_translate_add_offset.
* dwflpp.cxx (dwflpp::translate_location): Check elfutils version and only
do workaround for elfutils < 0.142.
* loc2c.h (c_translate_add_offset): Removed.
* loc2c.c (c_translate_add_offset): Likewise.
|
|
|
|
|
|
|
|
|
|
|
| |
We already have filtered functions and inlines, so just iterate in each
of those to look for labels.
* dwflpp.cxx (dwflpp::iterate_over_labels): Assume that the die we're
looking at is already a matching function, and don't descend into
inlined functions in this body.
* tapsets.cxx (query_srcfile_label): Iterate through inlines too.
(query_cu): Iterate over functions and inlines instead of the CU.
|
|
|
|
|
| |
* dwflpp.cxx (translate_location): Add hex pc address to semantic error
when dwarf_getlocation_addr() doesn't return expression.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Variable lookup is usually done through the scopes from dwarf_getscopes
at a particular pc. This requires an expensive traversal to find the
inner-most die containing the pc. For cases where that containing die
is known, e.g. at a particular function entry, we can do much better
with our die_parent_cache.
This may also help get more accurate variable scopes in cases where
multiple dies contain a pc and the innermost isn't what we're trying to
probe. For example, an inlined call chain of foo->bar->baz may all have
the same entry pc, but if the probe was on function("bar"), we would
want the variables in bar's scope, not baz's.
* dwflpp.h (struct dwflpp): Remove pc_cached_scopes, num_cached_scopes,
and cached_scopes, as they are now remembered by the caller.
* dwflpp.cxx (dwflpp::getscopes): New - the DIE version uses the parent
cache, and the pc version just defers to dwarf_getscopes.
(dwflpp::print_locals, literal_stmt_for_local): Take a scopes vector.
(dwflpp::find_variable_and_frame_base): Take a scopes vector from the
caller instead of computing it every time.
(dwflpp::dwarf_getscopes_cached): Removed.
* tapsets.cxx (dwarf_var_expanding_visitor::getscopes): New cached
lookup function which gets the scopes from the DIE if possible.
(dwarf_var_expanding_visitor::visit_target_symbol): Call getscopes.
|
|
|
|
|
|
| |
* util.h (delete_map): New templated map deleter.
* dwflpp.cxx (dwflpp::~dwflpp): Use it.
* tapsets.cxx (symbol_table::~symbol_table): Use it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This avoids repeated DIE traversal by caching all parents on the first
call, so future calls are just a simple walk up parent links.
* dwflpp.cxx (dwflpp::getscopes_die): New cached function that mimics
libdw's dwarf_getscopes_die using cached parent links.
(dwflpp::cache_die_parents): New function to build the parent cache.
(dwflpp::~dwflpp): Clean up the parent caches.
(dwflpp::iterate_over_labels): Use the cached getscopes_die.
(dwflpp::find_variable_and_frame_base): Ditto.
* tapsets.cxx (dwarf_derived_probe::saveargs): Ditto.
(uprobe_derived_probe::saveargs): Ditto.
(dwarf_var_expanding_visitor::visit_target_symbol_context): Ditto.
|
|
|
|
| |
* dwflpp.cxx (dwflpp::build_blacklist): Escape '.'s in filenames.
|
|
|
|
|
|
|
|
| |
We already use regexp for function/file blacklisting, so this just makes
the section blacklisting consistent with the rest.
* dwflpp.cxx (dwflpp::blacklisted_p): Use regexec instead of section==.
(dwflpp::build_blacklist): Build blacklist_section too.
|
|
|
|
|
|
|
|
|
|
| |
We only check blacklisting on kernel probes, so it's a waste to dig up
the section name otherwise.
* dwflpp.cxx (dwflpp::blacklisted_p): Lookup the section directly.
(relocate_address::relocate_address): Don't do blacklisting here.
* tapsets.cxx (dwarf_query::add_probe_point): Don't carry the blacklist
section directly anymore.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We can't assume that a given function name will only appear once in a
CU. In C++, two functions may have the same name in different classes
or namespaces, or even in the same scope with overloaded parameters.
Even in C, the compiler may generate multiple copies of a single
function with different optimizations.
We now use a multimap for function names, so we shouldn't miss any.
* dwflpp.h (cu_type_cache_t, mod_cu_type_cache_t): New typedef to keep a
normal map for the global_alias_cache.
(cu_function_cache_t): Use a multimap for function names.
* dwflpp.cxx (dwflpp::iterate_over_functions): Walk over the range of
exactly-matching functions.
* tapsets.cxx (query_dwarf_func): Don't abort after seeing an exact
match -- there could be more to come.
|
|
|
|
| |
* dwflpp.cxx (dwflpp::~dwflpp): Delete all of the caches.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We always use lex_cast either to string or from string, so I made that
explicit, and got rid of some string copies in the process. There was
also stringify(), which was redundant to lex_cast<string>.
We also always used lex_cast_hex to string, so that's now hard-coded and
again eliminated a string copy.
For lex_cast_qstring<string>, there's no need to write the streamify the
input, so a specialization now operates directly on the input.
Hopefully this is a bit cleaner, and I do measure it to be a little
faster on scripts with many probes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We used to call dwarf_func_inline_instances to get the locations where
inlines are used. This function has to iterate through nearly all DIEs
to find instances, which is a lot of redundant work when we're probing
multiple inline functions.
Now we have our own dwarf iterator to cache all inline instances back to
their origin. This only needs to be called once for each CU, and all
further inlines are just a map lookup. Some quick benchmarks:
stap -l Before After
kernel.function("*") 25010ms 2110ms
module("*").function("*") 86550ms 16920ms
process("stap").function("*") 41330ms 580ms
* dwflpp.cxx (dwflpp::cu_inl_function_caching_callback): Removed.
(dwflpp::cache_inline_instances): New caching iterator.
(dwflpp::iterate_over_inline_instances): Cache each CU once.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I noticed that iterate_over_labels was using a static variable as a
recursion variable, which isn't a safe thing to do since it will only be
initialized once. While fixing that, I also reorganized the function
quite a bit.
* dwflpp.cxx (dwflpp::iterate_over_labels): Take the current function as
a parameter instead of using a static local. Rewrite some of the code
as well to try to make it more obvious.
* tapsets.cxx (add_label_name): Remove in favor of query_label.
(query_label): New, to check decl_file and fix probe listing.
(query_srcfile_label, query_cu): Adjust to iterate_over_labels change
and start using query_label as the callback.
|
|
|
|
|
|
|
|
|
|
|
|
| |
We only need cu_name for errors and verbose messages, so it's a waste to
always construct it in focus_on_cu. It's now built only as-needed.
* dwflpp.cxx (dwflpp::cu_name): Now a method instead of a data member.
(dwflpp::focus_on_module): No cu_name to clear now.
(dwflpp::focus_on_cu): No cu_name to set now.
(dwflpp::declaration_resolve): Adjust to call cu_name() now.
(dwflpp::iterate_over_functions): Ditto.
* tapsets.cxx (query_cu): Ditto.
|
|
|
|
|
|
|
| |
* dwflpp.cxx (dwflpp::iterate_over_cus): Use the Dwarf_Die as a
pointer directly into the vector.
(dwflpp::iterate_over_inline_instances): Ditto.
(dwflpp::iterate_over_functions): Ditto in a map.
|
|
|
|
|
|
|
|
| |
Again, avoid needless string construction for map indexing.
* dwflpp.h (cu_inl_function_cache_t): Index by the void* function->addr.
* dwflpp.cxx (dwflpp::iterate_over_inline_instances): Index
cu_inl_function_cache by function->addr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rather than constructing a "module:cu" string all the time, we can just
index the cache by the cu die's addr field. The addr will never change
as long as the Dwarf object is still alive.
This has a quite noticeable performance impact for scripts that iterate
over lots of cus (like for syscall.*).
* dwflpp.h (stap_map): Allow void* keys too.
(mod_cu_function_cache_t): Index by the void* cu->addr.
* dwflpp.cxx (dwflpp::iterate_over_functions): Index cu_function_cache
by addr, and build the verbose strings manually when needed.
(dwflpp::declaration_resolve): Index global_alias_cache by addr.
|
|
|
|
|
|
|
|
|
|
|
|
| |
We used to only check that a CU contains at least one srcfile matching
the user's file spec. This patch ensures that the selected function was
actually defined in one of the matching srcfiles.
* tapsets.cxx (struct dwarf_query): Make filtered_srcfiles carry
strings, so we can easily lookup matches later.
(query_dwarf_func): Check that the decl_file is in filtered_srcfiles.
(query_cu): Adjust to using set<string>.
* dwflpp.cxx (dwflpp::collect_srcfiles_matching): Take a set<string>.
|
|
|
|
|
|
|
|
|
|
| |
* dwarf_wrappers.cxx (dwarf_type_name): Name class and reference types.
* dwflpp.cxx (dwflpp::iterate_over_globals): Capture class names.
(dwflpp::print_members): Permit classes, and dig into inheritance.
(dwflpp::find_struct_member): Ditto.
(dwflpp::translate_components): Handle classes and references.
(dwflpp::translate_final_fetch_or_store): Ditto.
* loc2c.c (c_translate_pointer): Treat references as simple pointers.
|