Josh Stone [Wed, 19 Aug 2009 20:30:31 +0000 (13:30 -0700)]
PR10538: Improve location lookup for unions
We had a bug that the starting call to find_struct_member used the same
memory for the parentdie and the resulting member. If parentdie is a
union, then the first member probably won't have a location, and we
actually assert that it must be a union. Since we wrote the result in
the same memory, we lost the real info about the parent, and so the
assertion failed.
* dwflpp.cxx (dwflpp::translate_components): Use distinct memory for the
parent and resulting member in the call to find_struct_member.
(dwflpp::find_struct_member): Remove the needless parentdie copy.
Stan Cox [Wed, 19 Aug 2009 20:11:09 +0000 (16:11 -0400)]
* testsuite/systemtap.base/postgres.exp: New test for checking sdt
marker support as used by postgres. Currently assumes, and
verifies, that postgres is installed in /usr/local
Frank Ch. Eigler [Wed, 19 Aug 2009 16:18:48 +0000 (12:18 -0400)]
PR10228: fix non-utrace building regression
* translate.cxx (dump_unwindsyms): Decide based on modname[] not
mainfile[] to emit a vmcb.
* runtime/task_finder.c (non-UTRACE): Include dummy stap_{start,stop}_*
functions.
Mark Wielaard [Tue, 18 Aug 2009 20:01:53 +0000 (22:01 +0200)]
Add testcase for PR10533 (inlined vars) and 10537 (inlined labels - disabled)
Partial testcase for PR10533 (inlined vars) and 10537 (inlined labels)
currently we cannot use the full testcase since stap doesn't support
probing multiple instances of inlined labels.
* testsuite/systemtap.base/inlinedvars.exp: New file.
* testsuite/systemtap.base/inlinedvars.stp: Likewise.
* testsuite/systemtap.base/inlinedvars.c: Likewise.
Mark Wielaard [Tue, 18 Aug 2009 19:54:54 +0000 (21:54 +0200)]
PR10533 inlined vars are not always found (dwflpp).
dwflpp::find_variable_and_frame_base switched too early to "pyshical view"
of die tree. We need to lookup the var in the "syntactical view" of the die
tree first. Then when we see a DW_TAG_inlined_subroutine while walking the
syntactical die tree as returned by dwarf_getscopes for a given variable
to retrieve the frame base, then we need to switch to walking the physical
die tree where the subroutine is inlined.
* dwflpp.cxx (find_variable_and_frame_base): Don't immediately go to
die_scopes, but lookup var first based on pc. Then switch "die branches"
when searching for frame base and a DW_TAG_inlined_subroutine is
encountered.
Frank Ch. Eigler [Tue, 18 Aug 2009 19:52:02 +0000 (15:52 -0400)]
PR10518: context shrinkage with function recursion analysis feeding MAXNESTING
* translate.cxx (emit_common_header, translate_pass): Use new
recursion_info visitor to calculate appropriate MAXNESTING value for
scripts with or without recursion.
* tapsets.cxx (common_probe_entryfn_prologue): Initialize c->nesting = -1.
* stap.1.in: Clarify MAXNESTING value.
Josh Stone [Tue, 18 Aug 2009 17:54:11 +0000 (10:54 -0700)]
Adapt tracepoints to the new probe_locals union
* tapsets.cxx (tracepoint_derived_probe_group::emit_module_decls): Use
probe_locals to set the tracepoint arguments for the probe.
* testsuite/systemtap.base/tracepoints.exp: Include the arguments in the
pass-4 tracepoint test.
Mark Wielaard [Tue, 18 Aug 2009 13:50:40 +0000 (15:50 +0200)]
PR10533 loc2c doesn't resolve frame base correctly for inlined vars.
When we see a DW_TAG_inlined_subroutine while walking the syntactical
die tree as returned by dwarf_getscopes for a given variable to retrieve
the frame base, then we need to switch to walking the physical die tree
where the subroutine is inlined.
* loc2c-test.c (handle_variable): Switch "die branches" when searching
for frame base and a DW_TAG_inlined_subroutine is encountered.
David Smith [Mon, 17 Aug 2009 17:27:15 +0000 (12:27 -0500)]
Unlocks global variables, then calls _stp_print_flush().
* translate.cxx (c_unparser::emit_probe): Unlocks global variables, then
calls _stp_print_flush() (instead of the other way around).
Josh Stone [Sat, 15 Aug 2009 00:56:46 +0000 (17:56 -0700)]
Cache failed tracepoint headers too
Rather than re-attempting a tracepoint header that fails to compile, we
now save an empty file into the cache to indicate "nothing to see here."
See also PR10424.
* tapsets.cxx (tracepoint_builder::get_tracequery_module): Use /dev/null
as the empty result file if make_tracequery fails.
(tracepoint_builder::init_dw): Ignore empty tracequery modules.
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