Josh Stone [Wed, 12 Aug 2009 00:01:35 +0000 (17:01 -0700)]
PR10461: Probe identical functions only once
In C++ especially, a function definition in a header may be compiled
into multiple CUs, but the linker will merge those into a single output
function. We don't want to place multiple probes on the same function.
The dupe-detection from the alias code (commit 1c6b77e5) already tracks
identical functions within a CU, so I've just lifted this to instead
track function entrypcs at the module level.
* dwflpp.cxx (dwflpp::iterate_over_functions): Remove dupe checks.
* tapsets.cxx (dwarf_query): Add alias_dupes set to the query.
(dwarf_query::handle_query_module): Reset the dupes for each module.
(query_dwarf_func): Check that we only probe each entrypc once.
David Smith [Tue, 11 Aug 2009 22:08:47 +0000 (17:08 -0500)]
Improved context.exp error handling.
* testsuite/systemtap.context/context.exp: Makes sure errors are output to
the log file. Also, a Makefile is copied with 'cp -p' to avoid make
erroring out if the Makefile's date is in the future (as can be the case
if running the test over nfs).
* testsuite/systemtap.context/args.tcl: Makes sure 'close' errors are
ignored.
* testsuite/systemtap.context/backtrace.tcl: Ditto.
David Smith [Tue, 11 Aug 2009 13:40:49 +0000 (08:40 -0500)]
exelib testcase now ensures uprobes.ko is up to date.
* testsuite/systemtap.exelib/cleanup.tcl: Makes sure uprobes.ko is up to
date.
* testsuite/systemtap.exelib/lib.tcl: Ditto.
* testsuite/systemtap.exelib/mark.tcl: Ditto.
* testsuite/systemtap.exelib/uname.tcl: Ditto.
* testsuite/systemtap.exelib/ustack.tcl: Ditto.
Josh Stone [Mon, 10 Aug 2009 21:48:39 +0000 (14:48 -0700)]
PR10499: Integrate attributes in dwarf_decl_file/line
Elfutils prior to 0.143 didn't use attr_integrate when looking up the
decl_file or decl_line, so the attributes would sometimes be missed.
For those old versions, we define custom implementations to do the
integration.
* dwarf_wrappers.cxx (dwarf_decl_file_integrate): New.
(dwarf_decl_line_integrate): New.
* dwarf_wrappers.h: Add macros to redirect calls to the above functions.
* dwflpp.cxx (dwflpp::iterate_over_labels): Replace a manual attribute
lookup that is the same as dwarf_decl_line.
Josh Stone [Mon, 10 Aug 2009 20:01:30 +0000 (13:01 -0700)]
Simplify _ELFUTILS_PREREQ checking
We were jumping through a few hoops to deal with elfutils < 0.138 that
did not have the _ELFUTILS_PREREQ macro. I've added an always-false
dummy macro to take its place when it doesn't exit. All of the other
"#ifdef _ELFUTILS_PREREQ" ugliness can now go away.
Dave Brolley [Mon, 10 Aug 2009 15:47:17 +0000 (11:47 -0400)]
It is not an error or warning if the local database of authorized signing
certificates does not exist. It just means that the signed module is untrusted.
Josh Stone [Sat, 8 Aug 2009 01:51:19 +0000 (18:51 -0700)]
Zap dwarf_diename_integrate
The dwarf_diename in elfutils learned a long time ago to use
dwarf_attr_integrate when looking up the name. Our minimum elfutils
0.126 has this, so we don't need to kludge it ourselves.
Mark Wielaard [Thu, 6 Aug 2009 22:01:04 +0000 (00:01 +0200)]
PR10486 Raise default MAXSTRINGLEN.
* translate.cxx (translate_pass): Raise MAXSTRINGLEN to 256 for 32bit arches
and to 512 for 64bit arches.
* testsuite/systemtap.context/backtrace.tcl: Don't set MAXSTRINGLEN.
* testsuite/systemtap.exelib/ustack.tcl: Likewise.
* testsuite/systemtap.string/str_replace.exp: Explicitly set MAXSTRINGLEN.
Stan Cox [Thu, 6 Aug 2009 20:20:39 +0000 (16:20 -0400)]
Fix a couple of sdt_query reorg problems.
* tapsets.cxx (sdt_query::handle_query_module): For uprobe probes:
1) find all same named probes to handle multiple probes per module
2) use new_base for uprobe probes to handle $$name
* sdt_misc.exp: Test $$name
David Smith [Thu, 6 Aug 2009 18:35:11 +0000 (13:35 -0500)]
Works with or without a ring_buffer_iter.
* runtime/transport/ring_buffer.c (_stp_find_next_event): Works with or
without a ring_buffer iterator.
(_stp_find_next_event): Ditto.
(_stp_data_read_trace): Ifdef'ed out using ring_buffer iterators.
(_stp_get_iterator): New function.
(_stp_data_write_reserve): Calls _stp_get_iterator().
Dave Brolley [Thu, 6 Aug 2009 16:25:50 +0000 (12:25 -0400)]
2009-08-06 Dave Brolley <brolley@redhat.com>
* modverify.c (staprun.h): #include it.
(verify_it): Now accepts module data and signature data as arguments.
Don't open and read the signature here. Don't read the module here.
(verify_module): Now accepts module data as argument. Read the signature
once here.
* modverify.h (verify_module): Now accepts module data as argument.
* staprun.c (main): Don't call check_permissions here.
* staprun.h (check_permissions): Prototype removed.
* staprun_funcs.c (check_permissions): Now static. Accepts module data
as argument. Pass module data to check_signature.
(insert_module): Canonicalize the module path early here. Call
check_permissions here, passing it the mapped module data.
(check_signature): Now accepts module data as argument. Pass the module
data to verify_module.
(check_path): Use the already-canonicalized module path.
Mark Wielaard [Thu, 6 Aug 2009 08:41:46 +0000 (10:41 +0200)]
PR10491 Don't assign to REG_IP if it isn't an lvalue (s390 and ia64).
To fixup REG_IP to show the correct value after a [ku]probe trap we
assigned the address of the actual instruction pointer of the probed
instruction. That doesn't work on architectures, s390 and ia64, where
REG_IP is not a simple lvalue. Just don't try to fixup the address in
those cases. If this isn't enough, the uprobe_stmt_num.exp testcase
will point this out.
* runtime/regs.h: Define REG_IP_LVALUE for x86_64, i386, powerpc64 and arm.
* tapsets.cxx (dwarf_derived_probe_group::emit_module_decls): Only fixup
REG_IP when REG_IP_LVALUE is defined.
(uprobe_derived_probe_group::emit_module_decls): Likewise.
(kprobe_derived_probe_group::emit_module_decls): Likewise.
Josh Stone [Thu, 6 Aug 2009 00:56:44 +0000 (17:56 -0700)]
Remove as_root calls from the printf testsuite
Once upon a time, we would use sudo staprun, and so output files from
"-o" were owned by root. For a while now we've used a setuid staprun
instead, and the output files are created by stapio as the user. Thus,
we don't need as_root to remove those files anymore.
* testsuite/systemtap.printf/end1b.exp: Clean up without as_root.
* testsuite/systemtap.printf/mixed_outb.exp: Ditto.
* testsuite/systemtap.printf/out1b.exp: Ditto.
* testsuite/systemtap.printf/out2b.exp: Ditto.
* testsuite/systemtap.printf/out3b.exp: Ditto.
Josh Stone [Wed, 5 Aug 2009 23:55:24 +0000 (16:55 -0700)]
Don't spawn uprobes tests with sudo
Using spawn with sudo doesn't work well, because the password prompt
won't go to the correct TTY. The only reason that the uprobes tests
needed to do this is so uprobes.ko could be built as root. Now instead,
I've added a pre-check that will directly call the uprobes make with
sudo (via the as_root proc).
* testsuite/lib/systemtap.exp (uprobes_p): Check and build uprobes.ko.
* testsuite/systemtap.base/uprobes.exp: Use uprobes_p; don't spawn sudo.
* testsuite/systemtap.base/bz6850.exp: Ditto.
* testsuite/systemtap.base/bz10078.exp: Ditto.
* testsuite/systemtap.base/bz6905.exp: sudo isn't needed for -p2.
Josh Stone [Wed, 5 Aug 2009 03:29:51 +0000 (20:29 -0700)]
Fix grapher compilation warnings from rpm build
* grapher/Graph.cxx (Graph::Graph): Initialize in declaration order.
* grapher/GraphWidget.cxx (GraphWidget::on_expose_event): Remove several
unused local variables.
Josh Stone [Mon, 3 Aug 2009 22:49:40 +0000 (15:49 -0700)]
Add update_visitor::replace
I noticed that most uses of update_visitor::require() were simply
writing the value back to the same place, i.e. foo = require(foo). The
new replace() method just encapsulates that paradigm, so we don't have
the duplication between the LHS and RHS.
* staptree.h (update_visitor::replace): New.
* elaborate.cxx, staptree.cxx, tapset-mark.cxx, tapset-perfmon.cxx,
tapset-procfs.cxx, tapset-utrace.cxx, tapsets.cxx: Update all require
calls that are simply updating the value in-place.
Josh Stone [Mon, 3 Aug 2009 21:45:21 +0000 (14:45 -0700)]
PR2049: support arbitrary $target-array indexing
Rather than just numeric literals, we can now support arbitrary
expressions for the index value. Note that loc2c won't allow this for
noncontiguous arrays, as the access methods need to be statically
computed, but for contiguous arrays and pointers-as-arrays it works
just fine.
* staptree.h (target_symbol::component): Add expression_array_index.
* staptree.cxx (target_symbol::visit_components): New helper.
(target_symbol::assert_no_components): Recognize new array type.
(target_symbol::component::print): Print subexpressions.
(traversing_visitor::visit_target_symbol, visit_cast_op): Visit the
indexing components too.
(varuse_collecting_visitor::visit_target_symbol): Ditto.
(update_visitor::visit_target_symbol, visit_cast_op): Ditto.
* elaborate.cxx (void_statement_reducer::visit_target_symbol): New.
(void_statement_reducer::visit_cast_op): Save indexes too.
* parse.cxx (parser::parse_target_symbol_components): Parse expressions.
* tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol): Pass
expression-indexes as parameters (indexN) to the dwarf function.
(dwarf_cast_expanding_visitor::visit_cast_op): Ditto.
(tracepoint_var_expanding_visitor::visit_target_symbol_arg): Ditto.
(sdt_var_expanding_visitor::visit_target_symbol): Visit the new @cast.
* dwflpp.cxx (dwflpp::translate_components): Use THIS->indexN.
* translate.cxx (c_unparser::visit_target_symbol): Correct error msg.
* testsuite/systemtap.base/pointer_array.stp: Use a simple index.
Josh Stone [Sat, 1 Aug 2009 00:24:13 +0000 (17:24 -0700)]
Unify no-component assertions on target variables
There are several tapsets that can't deal with component dereferences on
their target variables, and they all check-and-throw in the same way.
This refactors the checks into a target_symbol member.
* staptree.cxx (target_symbol::assert_no_components): New.
* tapsets.cxx (tracepoint_var_expanding_visitor::visit_target_symbol_arg,
tracepoint_var_expanding_visitor::visit_target_symbol_context): Use
the new assertion function to check for no components.
* tapset-mark.cxx (mark_var_expanding_visitor::visit_target_symbol_arg,
mark_var_expanding_visitor::visit_target_symbol_context): Ditto.
* tapset-perfmon.cxx (perfmon_var_expanding_visitor::visit_target_symbol): Ditto.
* tapset-procfs.cxx (procfs_var_expanding_visitor::visit_target_symbol): Ditto.
* tapset-utrace.cxx (utrace_var_expanding_visitor::visit_target_symbol_arg,
utrace_var_expanding_visitor::visit_target_symbol_context): Ditto.
Josh Stone [Sat, 1 Aug 2009 00:00:09 +0000 (17:00 -0700)]
Make a real type for target_symbol->components
Now the dereferences on target_symbol and cast_op are tracked with a
struct instead of just a generic pair. The first immediate benefit is
that we can track the token for more exact error reporting.
* staptree.h (target_symbol): Add a new component type.
* staptree.cxx (target_symbol::component::print): New.
(operator<<(ostream&, target_symbol::component&): New.
(target_symbol::print): Adapt component printing.
(cast_op::print): Ditto.
* parse.cxx (parser::parse_target_symbol_components): Adapt to the new
component construction.
* dwflpp.cxx (dwflpp::find_struct_member): take the component as a
parameter for a better token in error messages
(dwflpp::translate_components): Adapt to the new component type.
* tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol): Don't
overwrite the token in target_symbol saved errors.
(tracepoint_var_expanding_visitor::visit_target_symbol_arg): Ditto.
Mark Wielaard [Fri, 31 Jul 2009 16:46:47 +0000 (18:46 +0200)]
PR10458. User actual breakpoint address for [ku]probe[ret].
Setup the pt_regs REG_IP to the actual breakpoint address before
entering a probe handler for [ku]probe[ret] (and restore it after
returning). This helps getting symbol resolution and backtraces
more correct and makes it more conform with other probe handlers
like the iutrace and profile timers that also provide pt_regs
(which untill now exhibited off-by-one errors while unwinding).
* tapsets.cxx (dwarf_derived_probe_group::emit_module_decls):
Setup REG_IP correctly before calling enter_kprobe_probe
and enter_kretprobe_probe, and restore afterwards.
(uprobe_derived_probe_group::emit_module_decls): Likewise for
enter_uprobe_probe and enter_uretprobe_probe.
(kprobe_derived_probe_group::emit_module_decls): Likewise for
enter_kprobe2_probe and enter_kretprobe2_probe.
* runtime/unwind/i386.h (arch_unw_init_frame_info): Initialize
info->call_frame to zero.
* runtime/unwind/x86_64.h (arch_unw_init_frame_info): Likewise.
Mark Wielaard [Wed, 29 Jul 2009 22:06:59 +0000 (00:06 +0200)]
PR10459. Disable all warning messages on -w.
* stap.1.in: Document that -w disables all warning messages.
* dwflpp.cxx (get_module_dwarf): Only output warning when session
suppress_warnings is not set.
* translate.cxx (dump_unwindsyms): Likewise.
(emit_symbol_data_done): Likewise.
* tapsets.cxx (query_module_symtab): Likewise.
(read_from_elf_file): Take systemtap_session, check suppress_warnings
before emitting warning.
(read_from_text_file): Likewise.
(get_symtab): Call read_from_elf_file and read_from_text_file with session.
Josh Stone [Wed, 29 Jul 2009 21:34:32 +0000 (14:34 -0700)]
Enable variable listing (-L) for uprobes
All $target variables and their C-types are now printed in -L mode.
* tapsets.cxx (uprobe_derived_probe::uprobe_derived_probe): Save the local
arguments while we still have the dwflpp open.
(uprobe_derived_probe::saveargs): New
(uprobe_derived_probe::printargs): New
Josh Stone [Wed, 29 Jul 2009 21:07:37 +0000 (14:07 -0700)]
Enable variable listing (-L) for dwarf probes
All $target variables and their C-types are now printed in -L mode.
* tapsets.cxx (dwarf_derived_probe::dwarf_derived_probe): Save the local
arguments while we still have the dwflpp open.
(dwarf_derived_probe::saveargs): New
(dwarf_derived_probe::printargs): New
Josh Stone [Wed, 29 Jul 2009 19:35:29 +0000 (12:35 -0700)]
Use a real session flag for -L
Rather than relying on 'unoptimized' to tell us that the listing mode
should print the variables too, this adds an explicit listing_mode_vars.
* session.h (systemtap_session): Add listing_mode_vars
* main.cxx (main): Set s.listing_mode_vars appropriately.
(printscript): Use the new flag for deciding whether to print locals
Josh Stone [Wed, 29 Jul 2009 19:13:40 +0000 (12:13 -0700)]
Break up dwarf_var_expanding_visitor::visit_target_symbol
This just refactors large chunks of visit_target_symbol into a couple of
smaller functions.
* tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol_context): New
(dwarf_var_expanding_visitor::visit_target_symbol_saved_return): New
(dwarf_var_expanding_visitor::visit_target_symbol): Call the new ones
Tim Moore [Mon, 27 Jul 2009 10:46:30 +0000 (12:46 +0200)]
Support for presenting multiple graphs
* grapher/Graph.hxx: New file; class for single graph display.
* grapher/Graph.cxx: New file.
* grapher/GraphData.hxx: Associate title and axis labels with graph
data and not a graph display.
* grapher/GraphWidget.hxx: Move graph-related members to Graph class.
* grapher/GraphWidget.cxx (getExtents, setExtents): Move to Graph
class
(on_expose_event): Move graph rendering to Graph.
(on_button_press_event): Delegate to Graph.
(on_motion_notify_event, on_scroll_event): Modify "active" graph.
* grapher/StapParser.cxx (findTaggedValue): New parsing helper
function.
(io_callback): Support new syntax where properties are attached to
graph data and not the entire graph.
* grapher/grapher.cxx (GrapherWindow): Don't set graph values.
* grapher/Makefile.am: Add Graph.cxx.
* testsuite/systemtap.examples/general/grapher.stp: New property syntax.
Tim Moore [Wed, 27 May 2009 08:32:51 +0000 (10:32 +0200)]
Templatize GraphData
* grapher/GraphData.hxx (GraphDataBase): new superclass for
GraphData. Split time data out as a separate vector.
(GraphData): Rewrite as template.
* grapher/GraphWidget.cxx (on_expose_event): Reflect GraphData
templatization. Handle events with string values.
* grapher/GraphWidget.hxx (GraphWidget): Keep pointers to
GraphDataBase objects instead of GraphData.
* grapher/StapParser.cxx (parseData): new member function
(ioCallback): Handle new discreet event
* grapher/StapParser.hxx (StapParser): keep pointers to GraphDataBase
objects instead of GraphData
* testsuite/systemtap.examples/general/grapher.stp: Display actual key
pressed for keyboard event
PR6905: tweak WILDCARD and RANGE line type for process.statement
* dwflpp.cxx (iterate_over_srcfile_lines): Check the line range
and tolerate invalid line number for WILDCARD line type.
* testsuite/systemtap.base/bz6905.c: Test case.
* testsuite/systemtap.base/bz6905.exp: Ditto.
* testsuite/systemtap.base/bz6905.stp: Ditto.
David Smith [Wed, 22 Jul 2009 19:42:18 +0000 (14:42 -0500)]
Make ring_buffer transport work on new kernels.
* runtime/transport/ring_buffer.c (_stp_event_to_user): Added debug prints.
(_stp_ring_buffer_consume): New function.
(_stp_find_next_event): Avoid incrementing the buffer iterator here.
(_stp_data_write_commit): Added debug prints.
Josh Stone [Wed, 22 Jul 2009 02:21:56 +0000 (19:21 -0700)]
Use the query paradigm for resolving sdt probes
There was a bad assumption in the probe_table initialization that the
dwflpp->module would be immediately valid. We should not assume that
dwflpp only has one module, or that any module is necessarily in focus.
Instead, I've created an sdt_query class which will call an
iterate_over_modules like the other dwarf probe types. For now this
means just a single module, but it will also open the door to iterating
over all linked libraries too, for example.
* dwflpp.cxx (dwflpp::setup_user): don't "save mod!" anymore
* tapsets.cxx (probe_table -> sdt_query): convert to a query-style
class, and also take over the task of iterating over the probes.
(dwarf_builder::build): leave the iteration to sdt_query
Josh Stone [Tue, 21 Jul 2009 01:01:40 +0000 (18:01 -0700)]
PR10424: Consider each tracepoint header separately
With the current monolithic tracepoint query module, a failure in any of
the discovered tracepoint headers means that you can't use any of the
others either. This patch creates a separate query module for each
header so they can pass or fail independently.
* buildrun.cxx (make_tracequery): take a single header name instead of
globbing for everything we can find.
* hash.cxx (find_tracequery_hash): name the header file we're hashing.
* tapsets.cxx (tracepoint_query::handle_query_func): make sure we don't
duplicate tracepoints found through different headers.
(tracepoint_builder::get_tracequery_module): get a header's module
(tracepoint_builder::init_dw): glob for all tracepoint headers, and
feed all their modules into dwflpp.
Josh Stone [Mon, 20 Jul 2009 23:32:33 +0000 (16:32 -0700)]
Allow dwflpp to take a vector of module names
This will be used to load tracepoint modules as a bunch of little query
modules into a single dwflpp.
* dwflpp.cxx (setup_user): take a vector instead of a single module
(dwflpp::dwflpp): form a vector in the singular case, and add a
variant that takes and passes through a vector of modules.
Josh Stone [Mon, 20 Jul 2009 23:25:35 +0000 (16:25 -0700)]
Return hash module values directly as strings
* session.h (systemtap_session): remove tracequery_path
* hash.cxx (find_tracequery_hash, find_typequery_hash): return strings
* tapsets.cxx (dwarf_cast_expanding_visitor::filter_special_modules):
get the hashed path from the return value instead of a parameter
(tracepoint_builder::init_dw): ditto, and don't stuff it in session