Josh Stone [Sat, 12 Jun 2010 00:44:51 +0000 (17:44 -0700)]
PR10327: Fix and test alias matching
The optimization in commit 4df79aa broke alias matching for functions
without wildcards, but we didn't have any testing. :(
* dwflpp.cxx (dwflpp::iterate_single_function): Call update_symtab after
building the module function cache, to enable alias matching.
* testsuite/systemtap.base/func_alias.{exp,c}: New test.
William Cohen [Mon, 14 Jun 2010 14:30:06 +0000 (10:30 -0400)]
Make sure that the tapset documentation title descriptions are on a single line
The docproc program that extracts information information from the tapset
comments needs the title line to be a single line. Otherwise the second
line get counted as a description line and conflicts with the later
"Description:" section.
David Smith [Fri, 11 Jun 2010 20:26:46 +0000 (15:26 -0500)]
Got tty.stp working everywhere.
* tapset/tty.stp: Large update to get working on RHEL4, RHEL5,
RHEL6(beta), f12, f13, and rawhide.
* testsuite/buildok/tty-detailed.stp: Renamed from
testsuite/buildok/tty.stp and added more functions.
* testsuite/buildok/tty-resize.stp: Separate probe testcase since it can
fail because of PR 1155 (can't find inline function arguments).
* testsuite/buildok/tty-embedded.stp: New testcase.
* testsuite/systemtap.pass1-4/buildok.exp: Kfail the tty-resize.stp.
Tony Jones [Fri, 11 Jun 2010 17:15:50 +0000 (13:15 -0400)]
use probe_kernel_read for build-id verification if available
Post 1.1 I've been seeing the following on i686 (x86_64 is ok):
ERROR: Build-id mismatch: "kernel" vs. "vmlinux-2.6.34-8-default.debug" byte 0 (0x00 vs 0x00) rc -14 -14
Pass 5: run failed. Try again with another '--vp 00001' option.
as per irc discussion, following test diff fixed the problem on i686, I've not
tested on any other archs.
After the task_finder is started, no new targets can reliably be added.
So make sure that all registration/enabling of the task_finder and/or
the vma tracker is done in one place (task_finder_derived_probe_group).
* task_finder.h: Defined enable_vma_tracker and vma_tracker_enabled.
* task_finder.cxx: Implement enable_vma_tracker and vma_tracker_enabled.
(task_finder_derived_probe_group::emit_module_init): Also handle
vma_tracker.
* elaborate.cxx (visit_embeddedcode): Use enable_vma_tracker and
vma_tracker_enabled.
* session.h (systemtap_session): Remove need_vma_tracker.
* session.cxx (initialize): Remove need_vma_tracker initialization.
(parse_cmdline): Enable vma tracking early when -d user mode module found.
* translate.cxx (c_unparser::emit_module_init): Don't try to start
task finder and vma tracker here.
(c_unparser::emit_module_exit): Don't try to stop task finder here.
(emit_symbol_data_done): Don't emit static _stp_need_vma_tracker.
* runtime/sym.h: Remove static _stp_need_vma_tracker.
* runtime/sym.c (_stp_sym_init): Return error when registration failed.
* runtime/task_finder.c (stap_register_task_finder_target): Add sanity
checks to detect double registration or registration after task finder
was already started.
(stap_start_task_finder): Sanity check that task finder wasn't already
started.
Mark Wielaard [Fri, 11 Jun 2010 12:20:08 +0000 (14:20 +0200)]
Don't double print error message on bad stap command line option.
Bug introduced in commit db1354. getopt_long will already have printed
an appropriate error message in case of an invalid/unrecognized option
or an option missing an required argument. So don't print another error
message in that case.
Stan Cox [Thu, 10 Jun 2010 21:40:29 +0000 (17:40 -0400)]
Fix tests for -DSTAP_SDT_V2.
dtrace -G -s foo.d builds foo.o so it must pass -DSTAP_SDT_V2 to gcc. Add a -D
flag (sun dtrace also has a -D flag) and pass that to the gcc invocation.
* dtrace.in (semaphore_def_append): Make -DSTAP_SDT_V1 the default.
(generate): Likewise.
(main): Add -D and pass to cpp and gcc.
* sdt_misc.exp: Run dtrace every iteration and pass it -DSTAP_SDT_V2.
Tony Jones [Thu, 10 Jun 2010 13:38:14 +0000 (09:38 -0400)]
fix !CONFIG_FRAME_POINTER, !CONFIG_UTRACE case
In a kernel without FRAME_POINTERS (using the DWARF UNWINDER) and without
UTRACE I see the following in latest git master:
[...]
In file included from /tmp/stap/share/systemtap/runtime/stack.c:56:0,
from /tmp/stapPHqTen/stap_12068.c:52:
/tmp/stap/share/systemtap/runtime/stack-i386.c: In function "__stp_stack_print":
/tmp/stap/share/systemtap/runtime/stack-i386.c:69:25: error: implicit declaration of function "uprobe_get_pc".
AFAICT the autoconf test should result in STAPCONF_UPROBE_GET_PC=0 for the
case where CONFIG_UTRACE is unset since UPROBES requires UTRACE.
Josh Stone [Thu, 10 Jun 2010 01:48:51 +0000 (21:48 -0400)]
Give non-x86 a chance at uprobes SDT
* tapsets.cxx (sdt_uprobe_var_expanding_visitor): No need to assert that
we know dwarf_regs unless we actually encountered STAP_SDT_V2 with
arg_count > 0. V1 should continue to work on other architectures.
Josh Stone [Thu, 10 Jun 2010 01:44:42 +0000 (21:44 -0400)]
Let probe_bench work on archs besides x86_64
The cycles code is too x86_64-centric, but for now at least it's been
neutered to let other archs report basic timing numbers.
* scripts/probe_bench/bench.stp: Use get_cycles() instead of rdtsc().
* scripts/probe_bench/bench.c (rdtsc): Return 0 unless on x86_64. This
needs more work and inline assembly to fit more architectures.
Previously, the STAP_SDT_V2 -> V1 downgrade logic was half way down in the
header file, by which time some STAP_SDT_V2 definitions had already taken
effect.
Mark Wielaard [Wed, 9 Jun 2010 09:50:48 +0000 (11:50 +0200)]
Loop on utrace_barrier if utrace_control UTRACE_DETACH returns -EINPROGRESS.
When utrace_control(tsk, eng, UTRACE_DETACH) returns -EINPROGRESS that
means there are still handlers running. So loop on utrace_barrier(tsk, eng)
in that case, till it no longer returns -ERESTARTSYS. That makes sure that
no engine handler will be called afterwards, so we can safely unload the
stap module. Not doing this might have caused PR11672
(utrace_report_syscall_exit crash), although we don't yet have a simple
reproducer for that issue.
* runtime/itrace.c (remove_usr_itrace_info): Loop on utrace_barrier if
utrace_control returned -EINPROGRESS.
* runtime/task_finder.c (stap_utrace_detach): Likewise.
(stap_utrace_detach_ops): Likewise. And warn if stap_utrace_detach
didn't return successfully.
(__stp_utrace_attach): Loop on -ERESTARTSYS after utrace_barrier.
(__stp_utrace_task_finder_target_quiesce): Likewise.
Josh Stone [Fri, 4 Jun 2010 23:01:32 +0000 (16:01 -0700)]
uprobes_ppc: define MSR_MASK and clean up error cases
- The emulate_step code was copied from the kernel, but needs to have
the #define MSR_MASK too.
- A case in emulate_step could fall through with an illegal instruction,
just break and return 0 instead.
- A few privileged instructions can't be emulated and so return -1, but
we don't want uprobe_emulate_insn to see that as non-zero -> TRUE.
At a minimum, this restores whatever SSOL-faulty behavior would have
existed before emulate_step was added. We should also add checks in
arch_validate_probed_insn to avoid such instructions in the first place.
Signed-off-by: Josh Stone <jistone@redhat.com> Acked-by: Jim Keniston <jkenisto@us.ibm.com>
Mark Wielaard [Tue, 8 Jun 2010 11:32:21 +0000 (13:32 +0200)]
PR11678 Pick up ld.so (and other absolute shlibs) through stap --ldd.
* translate.cxx (add_unwindsym_ldd): Make scan slightly stricter, require
shlib to start as absolute path and address to be hex. Also allow direct
absolute shlib paths without soname.
Josh Stone [Mon, 7 Jun 2010 20:28:58 +0000 (13:28 -0700)]
Guard embeddedcode_info_pass from failures
We should not run this pass if there were previous errors, as
functioncall_traversing_visitor require referents on all calls. Fixes
a segfault in semko/five.stp after an arg-count mismatch, as well as the
new semko/nofunc.stp with a completely missing function.
* elaborate.cxx (semantic_pass): Only do embeddedcode_info_pass if !rc.
* testsuite/semko/nofunc.stp: New, as I couldn't find such a test.
Josh Stone [Mon, 7 Jun 2010 20:14:37 +0000 (13:14 -0700)]
Improve identification of arity-mismatch errors
Instead of pointing at the declaration site, we now finger the use which
is trying to set a bad arity, and also mention who originally set the
arity if possible. For example, semok/six.stp now says:
semantic error: inconsistent arity (1 vs. 2): identifier 'bar' at ../testsuite/semko/six.stp:6:3
source: bar[1, 2] = 3; # inconsistent array dimensions
^
semantic error: arity 1 first inferred here: identifier 'bar' at :5:3
source: bar[1] = 2;
^
* staptree.cxx (vardecl::set_arity): Require a token from the caller,
and report the original caller's token as well.
* elaborate.cxx (symresolution_info::visit_symbol): Pass the token.
(symresolution_info::find_var): Ditto.
* parse.cxx (parser::parse_global): Ditto.
* tapset-mark.cxx (mark_derived_probe::mark_derived_probe): Ditto.
* tapset-utrace.cxx
(utrace_var_expanding_visitor::visit_target_symbol_cached): Ditto.
* tapsets.cxx (tracepoint_derived_probe::tracepoint_derived_probe):
Ditto.
Josh Stone [Mon, 7 Jun 2010 19:58:00 +0000 (12:58 -0700)]
Never permit homonymous vars with different arity
It was previously possible to generate a global array and local scalar
having the same name, because find_var was glossing over globals that
didn't have compatible_arity.
Fixes semko/nine, and improves semko/six to an arity-mismatch error
rather than a local-array error.
* elaborate.cxx (symresolution_info::find_var): Use set_arity without
checking compatibile_arity, so that compatibility gets asserted.
(symresolution_info::visit_foreach_loop): Add "missing global" hint.
(symresolution_info::visit_arrayindex): Don't create local arrays.
Mark Wielaard [Mon, 7 Jun 2010 14:20:56 +0000 (16:20 +0200)]
PR11665 Add umodname(addr) tapset function.
* runtime/sym.c (_stp_tf_mmap_cb): Always register module name in vma_map.
(_stp_module_name): New function.
* tapset/ucontext.stp: New tapset.
* testsuite/buildok/ucontext.stp: New pass 4 test.
* testsuite/systemtap.context/usymbols.exp: Extend pass 5 test to include
umodname(handler).
Mark Wielaard [Mon, 7 Jun 2010 13:09:07 +0000 (15:09 +0200)]
Increase TASK_FINDER_VMA_ENTRY_ITEMS default.
Somewhat arbitrary default, this is often way too much for tracking
single process, but often too little when tracking whole system.
FIXME Would be nice to make this dynamic. PR11671
* runtime/task_finder_vma.c: Clean up some (bad) comments.
#define TASK_FINDER_VMA_ENTRY_ITEMS 1536.
Mark Wielaard [Mon, 7 Jun 2010 11:16:09 +0000 (13:16 +0200)]
Activate task finder vma tracker through tapset embedded-c /* pragma:vma */
The task finder vma tracker, _stp_sym_init(), was supposed to be activated
through defining STP_NEED_VMA_TRACKER in an included tapset. This didn't
actually work, since the define came too late. The _stp_sym_init() call
was however often triggered by the fact that any of these vma tracking
using tapset functions were used through task_finder_derived_probe_groups.
This patch makes it so that the vma tracker always gets activated when
they are used with any kind of probe.
* session.h (systemtap_session): New need_vma_tracker boolean.
* session.cxx (initialize): Initialize need_vma_tracker to false.
* elaborate.cxx (embeddedcode_info): New functioncall_traversing_visitor.
(embeddedcode_info_pass): New semantic pass.
(semantic_pass): Call embeddedcode_info_pass.
* translate.cxx (c_unparser::emit_module_init): Check whether
session->need_vma_tracker is set to decide emitting _stp_sym_init.
(c_unparser::emit_module_exit): Likewise for teardown.
* tapset/ucontext-symbols.stp: Remove STP_NEED_VMA_TRACKER define. Tag all
embedded-c functions with /* pragma:vma */.
* tapset/ucontext-unwind.stp: Likewise.
* runtime/task_finder.c (__stp_task_finder_started): New static int.
(stap_start_task_finder): Check and set __stp_task_finder_started.
(stap_stop_task_finder): Likewise.
Mark Wielaard [Fri, 4 Jun 2010 18:16:50 +0000 (20:16 +0200)]
Don't try to be clever with dentry lifetime.
Make caller of task_finder_vma responsible for dentry lifetime.
Must call stap_remove_vma_map_info when dentry goes away. Which
is what always happens because that is when the vma is unmapped.
* runtime/task_finder.c (__stp_call_mmap_callbacks_with_addr): Don't dget
and don't dput.
(__stp_call_mmap_callbacks_for_task): Only dget/dput for non-d_path case.
* runtime/task_finder_vma.c (stap_add_vma_map_info): Don't dget dentry.
(stap_remove_vma_map_info): Don't dput dentry.
(stap_drop_vma_maps): Likewise.
PR11095: support process(). **provider()** .mark()
For STAP_SDT_V2 only for now.
* NEWS, stapprobes.3stap.in: Mention it.
* Makefile.am (stap_CPPFLAGS): Use -DSTAP_SDT_V2.
* dtrace.in: Preserve provider name, though squash it for STAP_SDT_V1.
* includes/sys/sdt.h: Likewise.
* tapsets.cxx (register_patterns): Accept .provider() probe point piece.
(sdt_*_var_expanding_visotor): Store it.
(sdt_query::*): Extend for provider matching, new magic codes.
* testsuite/systemtap.base/sdt_misc.exp: Use more formal interfaces
to semaphores.
Mark Wielaard [Fri, 4 Jun 2010 09:34:23 +0000 (11:34 +0200)]
Add configure check for xmlto pdf with chapters titles starting with L...
There is a strange bug in older versions of xmlto when generating pdf.
https://bugzilla.redhat.com/show_bug.cgi?id=526273
So make sure to have a chapter title starting with L plus an refentry.
This will make sure the xmlto pdf support test fails on buggy versions.
Mark Wielaard [Thu, 3 Jun 2010 09:26:17 +0000 (11:26 +0200)]
Replace walk_stack field version guard with autoconf test.
The test for whether or not to assign print_context_stack to the
walk_stack stacktrace_ops field depended on the kernel version.
Replace with a proper runtime/autoconf test to make sure the field
always gets assigned when available.
* buildrun.cxx (compile_pass): Add output for STAP_CONF_WALK_STACK.
* runtime/autoconf-walk-stack.c: New test.
* runtime/stack.c (print_stack_ops): Assign walk_stack field
print_context_stack depending on STAP_CONF_WALK_STACK.
Josh Stone [Thu, 3 Jun 2010 00:18:33 +0000 (17:18 -0700)]
PR3672 cont'd: Change pretty-print "depth" to mean substructures
We don't follow pointers anymore within a structure. Now a single '$'
suffix means we print a shallow view of the structure, with {...} and
[...] in place of nested arrays/structs. A double suffix '$$' means we
print everything contained in the struct. Longer suffixes no longer
have meaning, and for now act the same as '$$'.
* tapsets.cxx (dwarf_pretty_print): Lose the "print_depth" field, and
instead just check if this is a "full" print job. Pass a bool
indicating whether we're currently traversing the top-level, so we
know which structs to expand. Also wrap it all in try/catch so bad
pointers don't kill us.
Josh Stone [Thu, 3 Jun 2010 01:37:55 +0000 (18:37 -0700)]
PR11664: Let return/next break out of try/catch
Try-catch works by faking a local "out" label and running the catch
block. In the case of return and next, we have a "goto out" without any
error, so it should be allowed to progress to the real out label.
* translate.cxx (c_unparser::visit_try_block): Reorganize the nested
labels to allow normal-fallthrough, normal-out, and error-out.
* testsuite/systemtap.base/overcatcher.stp: New test.
Josh Stone [Tue, 1 Jun 2010 22:23:48 +0000 (15:23 -0700)]
PR11599: Support the new tracepoints API in 2.6.35
* buildrun.cxx (make_tracequery): Support DECLARE_TRACE_NOARGS.
* tapsets.cxx (tracepoint_derived_probe_group::emit_module_decls): Add
an unused void* parameter for the tracepoint callbacks on 2.6.35+.
Mark Wielaard [Tue, 1 Jun 2010 09:37:59 +0000 (11:37 +0200)]
rhbz #596083 Account for dot and dotless kernel variant in stap-prep.
uname -r can produce different kinds of output:
2.6.32-30.el6.x86_64 (no variant, but including ".arch")
2.6.18-194.3.1.el5debug ("variant", without dot, no arch)
2.6.33.4-95.fc13.i686.PAE (".arch.variant", two dots)
We didn't handle the dot before the variant used in newer distros.
* stap-prep: Remove either ".variant" or "variant" from the end of release
uname string.
Mark Wielaard [Fri, 28 May 2010 21:49:26 +0000 (23:49 +0200)]
PR10665 Make unwinder recognized synthesized debug_frame_hdr.
* runtime/unwind.c (_stp_search_unwind_hdr): Take is_ehframe argument.
Recognize and use debug_hdr for binary searching the FDE.
(unwind_frame): Always try binary hdr search.
Mark Wielaard [Fri, 28 May 2010 21:32:05 +0000 (23:32 +0200)]
PR10665 Create a synthetic binary search table for a debug_frame section.
* runtime/sym.h (_stp_module): Add fields debug_hdr and debug_hdr_len.
* translate.cxx (create_debug_frame_hdr): New function.
(get_unwind_data): Call new function when there is a debug_frame.
(dump_unwindsyms): Output new debug_frame_hdr.
Stan Cox [Fri, 28 May 2010 20:11:24 +0000 (16:11 -0400)]
Implicit *_ENABLED() is no longer the default for sdt.h probes.
Cast V2 probe args.
sdt.h (STAP_SDT_IMPLICIT_ENABLED): New.
(STAP_TYPE): New.
(STAP_CAST): New.
(STAP_PROBE*_): Use STAP_TYPE and STAP_CASE.
sdt_misc.exp: Use -DSTAP_SDT_IMPLICIT_ENABLED
Here is a patch implements a way for uprobes to skip single step
when a probe in on a nop instruction.
Currently its implemented for nop on x86/x86_64 and s390.
For powerpc, its implemented on all instructions that can be emulated.
(For this emulation code is borrowed from arch/powerpc/lib/sstep.c)
I havent tested it on s390. Updated with comments from Jim.
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Reported-by: Josh Stone <jistone@redhat.com>
This is still a work in progress, but I deemed it now useful enough to
share. See PR3672 for discussion of work remaining.
* parse.cxx (parser::parse_target_symbol_components): Parse the trailing
$s as a new comp_pretty_print entry in the target_symbol.
* staptree.cxx (target_symbol::assert_no_components): Add a flag to
assert whether pretty-printing is supported.
(target_symbol::component::print): Support comp_pretty_print.
* dwflpp.cxx (dwflpp::translate_components): Skip the actual translation
if the obstack "pool" is NULL.
(dwflpp::type_die_for_local): Dig through a local and its components
to get the type DIE that the pretty printing can start from.
(dwflpp::type_die_for_return): Ditto for return values.
(dwflpp::type_die_for_pointer): Ditto for pointers.
* tapsets.cxx (dwarf_pretty_print): New struct for recursing over a type
DIE and producing a string representation. (The real meat lies here!)
(dwarf_var_expanding_visitor::visit_target_symbol): Determine when to
use dwarf_pretty_print instead of the normal path.
(dwarf_var_expanding_visitor::visit_target_symbol_context): Ditto.
(tracepoint_var_expanding_visitor::visit_target_symbol_arg): Ditto.
(tracepoint_var_expanding_visitor::visit_target_symbol_context): Ditto.
(dwarf_cast_query, dwarf_cast_expanding_visitor): Move the function
generation from the visitor to the query, and also support using
dwarf_pretty_print as needed.
Josh Stone [Wed, 26 May 2010 19:39:31 +0000 (12:39 -0700)]
tracequery build fix
Similar to commit 392e08b7 -- we need to #undef TRACE_INCLUDE_FILE
before each header in the tracepoint query module, so they can be
queried all at once.
The side effect was that the all-inclusive tracequery build would fail,
so we'd fall back to building a separate tracequery for each header.
It's much faster when we can build them together.
* buildrun.cxx (make_tracequery): #undef TRACE_INCLUDE_FILE before each
tracepoint header to prevent macro redefinition.
Mark Wielaard [Wed, 26 May 2010 10:24:21 +0000 (12:24 +0200)]
rhbz #596083 Make stap-prep resolve kernel-debuginfo-common package name.
The kernel-debuginfo-common package name is slightly different on different
distros. But the correct name is always required by the kernel-debuginfo
package. So don't add it to the CANDIDATES list, but let the yumdowloader
--resolve it. Tested on f13, rhel5 and rhel6 beta.
* stap-prep: Remove kernel-debuginfo-common from CANDIDATES, add --resolve
to yumdownloader.
Adrien Kunysz [Tue, 25 May 2010 15:03:41 +0000 (11:03 -0400)]
PR11609: --all-options stap option to -d ALL_LOADED_MODULES
* session.cxx (insert_loaded_modules): Parse /proc/modules
to populate unwindsym_modules ...
(parse_cmdline): ... if --all-options was given.
* stap.1.in: Document it.
Stan Cox [Tue, 25 May 2010 02:13:30 +0000 (22:13 -0400)]
Add debuginfoless static uprobe handling.
The .probes section now contains the assembler asm equivalent of each
probe argument. stap parses this and generates the equivalent stap code
to access each argument.
Josh Stone [Sat, 22 May 2010 01:32:46 +0000 (18:32 -0700)]
PR11617: Move string literal gluing from lexer to parser
* parse.cxx (lexer::ate_comment): New flag if we just passed a comment.
(lexer::scan): Set ate_comment, remove string gluing.
(parser::parse_literal): Glue strings if not comment-separated.
* testsuite/semok/thirtyfive.stp: Extend test.
Josh Stone [Fri, 21 May 2010 22:32:10 +0000 (15:32 -0700)]
Quiet the "checking uprobes" pass-4 messages
For session.verbose=1, we mostly only print the result of the pass. We
had a uprobes "preamble" though in pass 4, which IMO was a misleading
break in convention. It gave the impression that all the building time
for the actual script was part of the uprobes work.
* buildrun.cxx (verify_uprobes_uptodate, make_uprobes): Only print the
preamble message for verbose > 1.
Josh Stone [Thu, 20 May 2010 01:02:04 +0000 (18:02 -0700)]
PR10025: Don't read ahead tokens within preprocessor blocks
Since some aspects of the lexer are contextual, like wildcards in
probepoint identifiers, we need to wait for the right context in the
preprocessor rather than reading a bunch of tokens at once.
* parse.h (parser): Replace enqueued_pp with a pp_state stack.
* parse.cxx (parser::scan_pp): Use pp_state to decide if the current
token should be kept or skipped, and transition states as the various
%( %? %: %) are encountered.
(parser::skip_pp): Helper to leap over skipped tokens.