Mark Wielaard [Mon, 24 Aug 2009 15:09:29 +0000 (17:09 +0200)]
Fix failing uprobes.exp -p5 failures by removing trailing spaces in $$ vars.
* tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol_context):
Don't add extra space at end of list, only add space between symbols.
* testsuite/systemtap.base/uprobes.exp: Use more specific expect regex.
* testsuite/systemtap.base/vars.exp: Don't just chop off last char of printf
output string.
Frank Ch. Eigler [Mon, 24 Aug 2009 14:34:45 +0000 (10:34 -0400)]
PR4186: cross-architecture probe building
* main.cxx (main): Add 'a:' and 'B:' options.
* session.h (kbuildflags): New place to store -B args.
* testsuite/systemtap.base/cmd_parse.exp: Test them lightly.
* buildrun.cxx (run_make_cmd): Use "--no-print-directory"
rather than ">/dev/null" in kbuild invocations. Pass
'-a' and '-B' flags along.
* hash.cxx (find_script_hash): Add them.
* NEWS, stap.1.in: Mention this.
Mark Wielaard [Mon, 24 Aug 2009 13:07:19 +0000 (15:07 +0200)]
Initialize sdt_types testcase arr_char so that it is always null terminated.
* testsuite/systemtap.base/sdt_types.c: Initialize char arr_char [], not
with (too small) constant length, to make sure the string is always
null terminated.
Josh Stone [Sat, 22 Aug 2009 02:16:18 +0000 (19:16 -0700)]
PR10461: Add support for C++ classes and references
* 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.
Frank Ch. Eigler [Fri, 21 Aug 2009 21:16:13 +0000 (17:16 -0400)]
PR10507: tweak MAXUPROBES calculation to shrink table for small static number of probes
* tapsets.cxx (uprobe_derived_probe_group::emit_module_decls): Use
geometric mean rather than arithmetic mean. Add a comment to explain
relative harmlessness of exceeding the "minimum" or "maximum" values.
Mark Wielaard [Thu, 20 Aug 2009 14:31:55 +0000 (16:31 +0200)]
PR10537 process().function().label() should select multiple inlined instances.
This is less useful than one would hope. gcc will often emit a label with
a DW_AT_low_pc that is not really in the neighbourhood of where one would
expect it when the label is inlined and gcc can proof the label isn't really
used in the optimized code. dwflpp::iterate_over_labels will now really
iterate recursively through the die, even for dies without a name (like
lexical blocks). This means we should now always find the concrete inlined
label instances that have a real DW_AT_low_pc and so we don't need the trick
to use the line table to get at the actual address.
* dwflpp.cxx (iterate_over_labels): Accept dies without a name. Don't handle
labels without a name or without a lowpc attribute.
* testsuite/systemtap.base/inlinedvars.c (m): Trick gcc into thinking label
is always used.
(call, call2): Activate.
(main): Call call and call2.
* testsuite/systemtap.base/inlinedvars.exp: New result_string.
Test both unoptimized and optimized (inlined) builds.
Josh Stone [Thu, 20 Aug 2009 01:19:53 +0000 (18:19 -0700)]
PR10538: Give a file:line hint for anonymous types
When we list the possible members for an anonymous struct/union, the
user may want to go look at the source for the type. That's hard
without a type name, so we now list the decl file:line for them.
* dwflpp.cxx (dwflpp::translate_components): List file:line for anon.
Josh Stone [Thu, 20 Aug 2009 00:27:18 +0000 (17:27 -0700)]
Create a dwarf_attr_die idiom
We commonly do a dwarf_attr_integrate followed by dwarf_formref_die,
with no care for the Dwarf_Attribute, so I captured that idiom in an
inline function.
Josh Stone [Thu, 20 Aug 2009 00:07:30 +0000 (17:07 -0700)]
Use dwarf_diename instead of a DW_AT_name lookup
We should always use the canonical dwarf_diename. The code being
replaced here wasn't even using dwarf_attr_integrate, so it may have
been missing the accessibility of some names.
* dwflpp.cxx (dwflpp::iterate_over_labels): Use dwarf_diename.
Josh Stone [Wed, 19 Aug 2009 23:48:53 +0000 (16:48 -0700)]
Use dwarf_type_name in more places
* dwarf_wrappers.cxx (dwarf_type_name): Moved here from tapsets.cxx, and
added a variant that returns a string for easier ostreaming.
* dwflpp.cxx (dwflpp::print_members): Use dwarf_type_name for errors.
(dwflpp::find_struct_member): Ditto.
(dwflpp::translate_components): Ditto.
(dwflpp::translate_final_fetch_or_store): Ditto.
(dwflpp::literal_stmt_for_pointer): Ditto.
* tapsets.cxx (dwarf_derived_probe::saveargs): Pass die to
dwarf_type_name by pointer instead of reference.
(uprobe_derived_probe::saveargs): Ditto.
(resolve_tracepoint_arg_type): Ditto.
David Smith [Wed, 19 Aug 2009 21:01:45 +0000 (16:01 -0500)]
Updated with latest code.
* runtime/transport/ring_buffer.c (_stp_ring_buffer_disable_cpu): New
function.
(_stp_ring_buffer_enable_cpu): Ditto.
(_stp_ring_buffer_cpu_disabled): Ditto.
(_stp_ring_buffer_empty_cpu): Only checks online cpus (instead of all
possible cpus).
(_stp_find_next_event): Ditto.
(_stp_ring_buffer_iterator_increment): Calls
_stp_ring_buffer_disable_cpu()/_stp_ring_buffer_enable_cpu() around
ring_buffer_* calls.
(_stp_ring_buffer_consume): Ditto.
(_stp_peek_next_event): Ditto.
(_stp_buffer_iter_finish): New function.
(_stp_buffer_iter_start): Ditto.
(_stp_data_read_trace): Uses
_stp_buffer_iter_start()/_stp_buffer_iter_finish().
(_stp_data_write_reserve): Checks to see if the cpu is disabled (with
_stp_ring_buffer_cpu_disabled() before reserving memory. Uses
_stp_buffer_iter_start()/_stp_buffer_iter_finish().
(_stp_transport_data_fs_init): Initializes buffer iterators.
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.