David Smith [Wed, 7 Jul 2010 16:43:16 +0000 (11:43 -0500)]
Fixed semok/entry03.stp on RHEL5 and added more rpc embedded function tests.
* testsuite/semok/entry03.stp: Fixed for RHEL5 systems.
* testsuite/buildok/rpc-embedded.stp: Added the rest of the rpc.stp
embedded functions to the test.
David Smith [Wed, 7 Jul 2010 15:08:41 +0000 (10:08 -0500)]
Fixed PR11663 by using an embedded-C expression to get the marker name/format.
* tapset-mark.cxx (mark_var_expanding_visitor::visit_target_symbol_context):
Instead of calling a tapset function to get the marker name/format, use
an embedded-C expression.
* tapsets.cxx (tracepoint_var_expanding_visitor::visit_target_symbol_context):
Ditto.
* tapset/marker.stp: Removed, since no longer needed.
Mark Wielaard [Wed, 7 Jul 2010 14:51:25 +0000 (16:51 +0200)]
Sanitize before usage in unwinder if they come from task_pt_regs.
Introduce _stp_task_pt_regs_valid() that checks whether a full set
of user registers was saved. Currently assumes yes for i386 and no otherwise.
If not all registers were saved create a copy for the unwinder with
everything zeroed out except the (arch specific, x86_64 only for now)
known to be valid registers (would be nicer to do this as initial
unwinder state, so we could mark them undefined, but the current
form at least prevents leaking any data that might still be saved
in the pt_regs that task_pt_regs() points to).
* runtime/compatdefs.h (_stp_task_pt_regs_valid): New function.
* runtime/stack.c (_stp_stack_print): Take and pass uregs_valid argument.
(_stp_stack_sprint): Likewise.
* runtime/stack-arm.c (__stp_stack_print): Likewise.
* runtime/stack-i386.c (__stp_stack_print): Likewise.
* runtime/stack-ia64.c (__stp_stack_print): Likewise.
* runtime/stack-ppc.c (__stp_stack_print): Likewise.
* runtime/stack-s390.c (__stp_stack_print): Likewise.
* runtime/stack-x86_64.c (__stp_stack_print): Likewise.
* tapset/context-unwind.stp (print_backtrace): Pass zero for valid.
(sprint_backtrace): Likewise.
(backtrace): Likewise.
* tapset/ucontext-unwind.stp (print_ubacktrace): Check and pass uregs_valid.
(sprint_ubacktrace): Likewise.
(print_ubacktrace_brief): Likewise.
(ubacktrace): Likewise.
* runtime/unwind/i386.h (arch_unw_init_frame_info): Accept sanitize argument.
* runtime/stack-x86_64.c (arch_unw_init_frame_info): Likewise and actually
sanitize the pt_regs copy.
Mark Wielaard [Wed, 7 Jul 2010 11:25:47 +0000 (13:25 +0200)]
Keep track of context pt_regs state to distinquish between user/kernel regs.
Although user_mode(regs) can give us a hint as to where the regs are
coming from, it is more reliably to let the probe handler keep track.
All utrace/uprobes based handlers now explicitly set CONTEXT->regflags
_STP_REGS_USER_FLAG. As do the timer probes (based on user_mode).
The perf based handlers don't yet try to determine the regs origin
(but might just use the timer based heuristic). Relevant symbol/unwind
tapset functions now take advantage of this new context flag. The register
tapsets might also benefit from the extra info, but have not been adjusted.
* translate.cxx (c_unparser::emit_common_header): Define _STP_REGS_USER_FLAG
and add regflags field to struct context.
* tapset-itrace.cxx (itrace_derived_probe_group::emit_module_decls):
Set _STP_REGS_USER_FLAG for regflags.
* tapset-perfmon.cxx (perf_derived_probe_group::emit_module_decls):
Add XXX note to investigate.
* tapset-timers.cxx (profile_derived_probe_group::emit_module_decls):
Set _STP_REGS_USER_FLAG for regflags based on user_mode.
* tapset-utrace.cxx (utrace_derived_probe_group::emit_module_decls):
Set _STP_REGS_USER_FLAG for regflags.
* tapsets.cxx (common_probe_entryfn_prologue): Initialize regflags to zero.
(uprobe_derived_probe_group::emit_module_decls):
Set _STP_REGS_USER_FLAG for regflags.
* tapset/context-symbols.stp (probefunc): Check CONTEXT->regflags and use
current task lookup if set.
(probemod): Check CONTEXT->regflags _STP_REGS_USER_FLAG isn't set.
* tapset/context-unwind.stp (print_backtrace): Likewise.
(sprint_backtrace): Likewise.
(backtrace): Likewise.
* tapset/context.stp (user_mode): Just check CONTEXT->regflags.
* tapset/ucontext-unwind.stp (print_ubacktrace): Check CONTEXT->regflags
_STP_REGS_USER_FLAG is set.
(sprint_ubacktrace): Likewise.
(print_ubacktrace_brief): Likewise.
(ubacktrace): Likewise.
* tapset/utrace.stp (_utrace_syscall_nr): Likewise.
(_utrace_syscall_arg): Likewise.
(_utrace_syscall_return): Likewise.
Mark Wielaard [Wed, 7 Jul 2010 09:01:43 +0000 (11:01 +0200)]
Only include unwaddr in context for ia64. Not used on any other arch.
* translate.cxx (c_unparser::emit_common_header): Don't add unwaddr field
to context struct except for ia64.
* tapsets.cxx (common_probe_entryfn_prologue): Only initialized unwaddr
on ia64.
(dwarf_derived_probe::emit_probe_local_init): Only call bspcache on ia64.
* runtime/regs-ia64.c: Don't define (empty) bspcache for other arches.
David Smith [Tue, 6 Jul 2010 19:32:14 +0000 (14:32 -0500)]
Small changes to several buildok testcases.
* testsuite/buildok/logging-embedded.stp: Renamed from logging.stp.
* testsuite/buildok/nfs_proc-embedded.stp: Added the rest of the
nfs_proc.stp embedded functions to the test.
* testsuite/buildok/memory-embedded.stp: Added GFP_KERNEL test.
* testsuite/buildok/irq-all-probes.stp: Added '-w' to avoid empty probe
warnings.
* testsuite/buildok/utrace.stp: Ditto.
Stan Cox [Tue, 6 Jul 2010 13:06:38 +0000 (09:06 -0400)]
Remove implicit static user probe semaphores.
dtrace.in (class provider): Define foo_ENABLED using builtin_expect
sdt.h (STAP_SEMAPHORE): Remove. Explicit foo_ENABLED can be used instead.
(STAP_PROBE): Likewise.
Mark Wielaard [Tue, 6 Jul 2010 10:24:19 +0000 (12:24 +0200)]
Extend context.exp backtrace.tcl test for "perfect" DWARF backtraces.
* testsuite/systemtap.context/backtrace.stp (yyy_func4): Exit at end to not
stall expect.
* testsuite/systemtap.context/backtrace.tcl: Add -d systemtap_test_module1
and -d kernel for "perfect" backtraces. Keep track of module1 and kernel
frames. Do not accept (inexact) anymore - the dwarf unwinder is "perfect"
now. Check stap script did exit (eof).
Mark Wielaard [Mon, 5 Jul 2010 19:14:42 +0000 (21:14 +0200)]
Put generated debug_hdr in _stp_section, add sec_load_offset for adjustment.
Make sure to adjust .debug_frame addresses to section load address.
Which means keeping track of the (synthetic) .debug_frame_hdr index
per section. For now keep track of "magic sections". Will need to
be extended to track all loadable code sections as we do for symbol
tables. See http://sourceware.org/ml/systemtap/2010-q3/msg00012.html
* runtime/sym.h (_stp_module): Remove dwarf_module_base. Move debug_hdr
and debug_hdr_len from here to ...
(_stp_section): ... here. And add sec_load_offset.
* runtime/unwind.c (adjustStartLoc): Don't use m->dwarf_module_base,
use s->sec_load_offset.
(_stp_search_unwind_hdr): Use s->debug_hdr and s->debug_hdr_len.
* translate.cxx (create_debug_frame_hdr): Accept and set debug_frame_off.
(get_unwind_data): Likewise.
(dump_unwindsyms): Keep track of debug_frame_off. Output debug_frame_hdr
per _stp_section if section is ".dynamic", ".absolute", ".text", or
"_stext".
* translate.cxx (emit_symbol_data): Tolerate mystery modules being
listed in -d or via --all-modules. This kind of situation does
not call for freaking out. Wubba wubba.
Mark Wielaard [Mon, 5 Jul 2010 09:48:35 +0000 (11:48 +0200)]
PR11778 Add sprint_stack and sprint_ustack tapset functions.
New tapset functions that take a hexstring and produce a (simplified) stack
as string. Simplified because otherwise it would quickly run over max string
length.
* runtime/sym.h (_STP_SYM_SIMPLE): New format that gives only symbol,
module, offset (and newline).
* tapset/context-symbols.stp (sprint_stack): New tapset function.
* tapset/ucontext-symbols.stp (sprint_ustack): Likewise.
* testsuite/buildok/context-symbols-embedded.stp: New sprint_stack test.
* testsuite/buildok/ucontext-symbols-embedded.stp: New sprint_ustack test.
Mark Wielaard [Sun, 4 Jul 2010 21:16:21 +0000 (23:16 +0200)]
Replace _stp_symbol_snprint usage with _stp_snprint_addr.
_stp_snprint_addr is a more generic version of _stp_symbol_snprint.
[u]symdata is now also slightly more exact is offset/sizes returned.
* runtime/sym.c (_stp_symbol_snprint): Removed.
* runtime/sym.h (_STP_SYM_DATA): New define for sym/mod/off/size.
* tapset/context-symbols.stp (probefunc): Use _stp_snprint_addr with
_STP_SYM_SYMBOL.
(symname): Likewise.
(symdata): Use _stp_snprint_addr with _STP_SYM_DATA.
* tapset/ucontext-symbols.stp (usymname): Use _stp_snprint_addr with
_STP_SYM_SYMBOL.
(usymdata): Use _stp_snprint_addr with _STP_SYM_DATA.
* testsuite/systemtap.context/uprobe_uaddr.exp: Tweak result_funcs match.
Josh Stone [Sat, 3 Jul 2010 05:19:11 +0000 (22:19 -0700)]
PR11785 (partial): Better detection of kretprobe data types
It's a bit less of a kludge now, letting the one who expanded the $var
determine the type to be saved.
* tapsets.cxx (dwarf_var_expanding_visitor::gen_kretprobe_saved_return):
Determine the kretprobe data type from the expression itself.
(dwarf_var_expanding_visitor::visit_target_symbol_context): Dwarf
context vars become an sprintf, and thus are pe_string.
(dwarf_var_expanding_visitor::visit_target_symbol): Regular dwarf vars
get their type from the functiondecl (practically it's always pe_long).
(dwarf_pretty_print::expand): Pretty-printing is always a string.
* testsuite/semok/kretprobe-data.stp: Test the various type resolution.
Josh Stone [Sat, 3 Jul 2010 04:40:53 +0000 (21:40 -0700)]
PR11785 (partial): add grace to tracepoint $$parms$
Tracepoint args with base types should not be dereferenced at all, but
the pretty-printing is not wise enough to know that. Thankfully we were
already blocking the pretty-printing from such vars, but the error was
turning into an assertion failure in $$parms$.
So rather than asserting, for now just turn them into "=?" like dwarf
probes do with such failure. Later we can try to make pretty printing
work with such base-typed tracepoint $vars.
* tapsets.cxx
(tracepoint_var_expanding_visitor::visit_target_symbol_context):
Don't assert that there aren't errors, just squash them.
* testsuite/semok/pretty2.stp: Exercise lots of tracepoints.
Stan Cox [Thu, 1 Jul 2010 20:32:07 +0000 (16:32 -0400)]
Restructuring of .probes section (SW11667)
sdt.h (sdt_probe_entry_v2): Add semaphore.
(STAP_SDT_IMPLICIT_ENABLED): Remove.
(STAP_PROBE_DATA_): Allocate probe associated strings after the probe
tapsets.cxx (sdt_query): Add semaphore.
(sdt_query::get_next_probe): Initialize it. For *2_type case skip over strings
following probe.
(sdt_query::record_semaphore): Use it.
Mark Wielaard [Thu, 1 Jul 2010 13:27:32 +0000 (15:27 +0200)]
Move compatibility defines for task_pt_regs from context.stp to compatdefs.h.
So task_pt_regs can be used in other tapset functions also.
* tapset/context.stp: Move backwards compatible task_pt_regs defines to ...
* runtime/compatdefs.h: ... here, and include an asm/ptrace.h include as
the tracehooks documentation says might contain another definition.
Reference counting is important to avoid removing the module while the
file exposing relay channel is being used. SystemTap alone does not need
it, but malicious user may block reloading the module by opening such
file and stap user won't notice it during unloading.
relay_file_operations defined and exported in kernel/relay.c is const
and .owner is obviously not set there, hence it shouldn't be used
directly by any kernel module.
Add relay_file_operations_w_owner and use it instead of mentioned one to
fix 'trace' file handling w.r.t. module unloading.
* runtime/transport/relay_v2.c: Add owner to the trace file.
Josh Stone [Wed, 30 Jun 2010 23:39:11 +0000 (16:39 -0700)]
PR10943: support @entry saving in .return probes
* staptree.h (struct entry_op): New.
* parse.cxx (parse_entry_op): Parse @entry into an entry_op.
* elaborate.cxx, staptree.cxx, translate.cxx: Add entry_op boilerplate.
* tapsets.cxx (dwarf_var_expanding_visitor::visit_entry_op): New, save
operand value using gen_mapped_saved_return.
(dwarf_var_expanding_visitor::gen_mapped_saved_return): Use a new flag
to see if the tid is already saved, because the add_block may have
been created by gen_kretprobe_saved_return instead.
* NEWS, stapprobes.3stap: Document it.
* testsuite/sem*/entry*.stp: Test it.
Stan Cox [Wed, 30 Jun 2010 13:34:30 +0000 (09:34 -0400)]
Improve synchronization of sdt_misc.exp attach tests.
sdt_misc.exp (v_flags): New. Pass it to dtrace.
(sdt_misc.c): Use explicit SDT_MISC_TEST_PROBE_N_ENABLED ()
Wait after synchronization loop termination.
Mark Wielaard [Wed, 30 Jun 2010 12:27:05 +0000 (14:27 +0200)]
Fix .debug_frame dwarf unwinding through prelinked dynamic libraries.
This wasn't immediately visible since often we would pick up the .eh_frame
CFI. But when the would pick up the CFI from the .debug_frame and the
shared library was prelinked, we would not correctly adjust some addresses.
* runtime/sym.h (_stp_module): Better explain dwarf_module_base.
* runtime/unwind.c (adjustStartLoc): Only adjust against dwarf_module_base
when not eh_frame.
* translate.cxx (dump_unwindsyms): Adjust dwarf_module_base against dwbias.
Frank Ch. Eigler [Wed, 30 Jun 2010 01:37:20 +0000 (21:37 -0400)]
stap diagnostics: make stap -V list interesting enabled/detecteda autoconf features
* session.cxx (version): List a bunch of set HAVE_* flags.
* configure.ac: Removed -lpfm (historical perfmon) tests.
* other configury: Regenerated on f13.
Josh Stone [Wed, 30 Jun 2010 00:46:52 +0000 (17:46 -0700)]
Warn about SDT $vars that don't look like $argN
* tapsets.cxx (sdt_uprobe_var_expanding_visitor::visit_target_symbol):
When arg_count==0, just trickle down to uprobes, but otherwise warn
about improper naming if it doesn't parse as $argN.
(sdt_kprobe_var_expanding_visitor::visit_target_symbol): Warn about
improper naming if it doesn't parse as $argN.
Dave Brolley [Mon, 14 Jun 2010 19:19:43 +0000 (15:19 -0400)]
Reword compile server client merge into stap based on feedback received:
- Move server related utility methods out of systemtap_session
- Move other utility methods back out of systemtap_session and back
into the top level of main.cxx
- Move pending_interrupts out of systemtap_session and back to top level.
- Initialize systemtap_session in the constructor
- Move server argument collection out of main options switch.
Dave Brolley [Tue, 1 Jun 2010 18:51:53 +0000 (14:51 -0400)]
Merged compile server client: Basic implementation.
o client automatically detects compatible online servers
o request package created, zipped and sent to the server
o response unzipped and processed
o staprun called, if requsted
o command line options filtered and passed to the server in the request package
o --unprivileged is handled
Dave Brolley [Fri, 21 May 2010 19:52:32 +0000 (15:52 -0400)]
More compile server client merge infrastructure:
- Make phase management functions methods of systemtap_session
- Make phase management globals static members of systemtap_session
- Create skeletal compile_server_client class
Dave Brolley [Fri, 21 May 2010 18:09:26 +0000 (14:09 -0400)]
Begin compile server client merge into stap:
- Detect presence of avahi-client library and headers during configuration
- Use avahi-client API to detect online servers
- Implement --server-status=online,compatible
Mark Wielaard [Tue, 29 Jun 2010 10:02:48 +0000 (12:02 +0200)]
Merge _stp_vma_module_name functionality into _stp_umod_lookup.
This also includes the fix for 32bit signed values in 64bit longs issue
which was missing from _stp_umod_lookup. Better to have the lookup and
fix/workaround all in one place.
* runtime/vma.c (_stp_vma_module_name): Removed.
* runtime/sym.c (_stp_umod_lookup): Include module name lookup.
(_stp_kallsyms_lookup): Get name directly when available throug umodule.
* runtime/unwind.c (unwind): Adjust _stp_umod_lookup call.
* tapset/ucontext.stp (umodname): Use _stp_umod_lookup.
Mark Wielaard [Mon, 28 Jun 2010 20:21:23 +0000 (22:21 +0200)]
Match user space modules on actual path and set name to basename.
Matching on actual canonical path is more accurate. Having basename is
better for module in backtraces.
* translate.cxx (dump_unwindsyms): Grab basename from canonical path for
user space modules.
* dwflpp.cxx (dwflpp::emit_address): Call _stp_umodule_relocate with
canonical path.
* runtime/sym.c (_stp_umodule_relocate): Match on path, not name.
David Smith [Mon, 28 Jun 2010 19:30:33 +0000 (14:30 -0500)]
Fixed PR11762 by making the systemtap.base/flightrec*.exp tests more robust.
* testsuite/systemtap.base/flightrec1.exp: Make sure old test results are
removed when starting. Be sure to close spawned processes properly.
When sending stapio a signal, sleep 2 seconds to let everything settle
out.
* testsuite/systemtap.base/flightrec2.exp: Ditto.
* testsuite/systemtap.base/flightrec3.exp: Ditto.
* testsuite/systemtap.base/flightrec4.exp: Ditto.
* testsuite/systemtap.base/flightrec5.exp: Ditto.
Mark Wielaard [Mon, 28 Jun 2010 14:14:29 +0000 (16:14 +0200)]
Fold space/newline/brief/inexact logic into _stp_func_print flags.
Trying to get all the logic of how symbols/addresses in backtraces are
printed into one place. So that passing through the flags tell the whole
story, instead of decissions being spread out all over the place. This
does mean one hairy _stp_print_func() function unfortunately. But at least
there is now one place to tweak when adding stack/symbol output changes.
* runtime/runtime.h: Remove SYM_VERBOSE_NO, _FULL, _BRIEF.
* runtime/sym.h: Add _STP_SYM_ flags.
* runtime/sym.c (_stp_func_print): Base output on individual _STP_SYM_ flags.
* runtime/stack.c (print_stack_address): Use _STP_SYM_INEXACT.
(_stp_stack_print): Check and use _STP_SYM_ flags.
* runtime/stack-i386.c (_stp_stack_print_fallback): Use _STP_SYM_INEXACT.
* runtime/stack-x86_64.c (_stp_stack_print_fallback): Likewise.
* tapset/context-unwind.stp (print_backtrace): Pass _STP_SYM_FULL.
* tapset/ucontext-unwind.stp (print_ubacktrace): Likewise.
(print_ubacktrace_brief): Pass _STP_SYM_BRIEF.
Mark Wielaard [Sun, 27 Jun 2010 19:30:53 +0000 (21:30 +0200)]
Don't resolve symbols unnecessarily and don't suppress things from backtrace.
We were always doing symbol lookups of addresses in a backtrace, even when
the user only wanted the addresses. If we couldn't find an symbol associated
with an address in the backtrace we just tried again and reported the next
address/symbol we could find. It really is better to always report all
addresses we think are part of a backtrace. It is more efficient, and more
truthful.
* runtime/sym.c (_stp_func_print): Don't report whether name lookup
succeeded. Only lookup symbol names when requested.
* runtime/stack-x86_64.c (_stp_stack_print_fallback): Report all addresses
found.
* runtime/stack-i386.c (_stp_stack_print_fallback): Likewise.
(__stp_stack_print): Mark frame based addresses as inexact.
Mark Wielaard [Sun, 27 Jun 2010 12:18:33 +0000 (14:18 +0200)]
Split _stp_module_relocate into kernel and user space lookup functions.
Simplify relocation logic by splitting kernel and user space module lookups.
* runtime/sym.h (_stp_module_relocate): Split into ...
(_stp_kmodule_relocate): ... this for kernel module lookups and ...
(_stp_umodule_relocate): ... this for user space lookups.
* runtime/sym.c: Likewise.
(_stp_module_check): Use _stp_kmodule_relocate.
* dwflpp.cxx (dwflpp::emit_address): Use _stp_kmodule_relocate or
_stp_umodule_relocate as appropriate.
* tapsets.cxx (dwarf_derived_probe_group::emit_module_init): Use
_stp_kmodule_relocate for kprobes.
David Smith [Fri, 25 Jun 2010 16:32:02 +0000 (11:32 -0500)]
Added kprocess.stp testcases.
* testsuite/buildok/kprocess-all-probes.stp: Renamed from
process-all-probes.stp and uses wildcards.
* testsuite/buildok/kprocess-detailed.stp: New testcase.
* testsuite/buildok/kprocess-embedded.stp: Ditto.
Mark Wielaard [Fri, 25 Jun 2010 14:04:12 +0000 (16:04 +0200)]
Rename _stp_stack_snprint to _stp_stack_hexstring.
_stp_stack_snprint() was only used to get the hex string of a backtrace.
So rename it to make that clear and simplify it by not calling through
the full _stp_stack_print(). Simplify _stp_stack_print() a bit since it
now doesn't need to handle "hex string only" backtraces.
* runtime/stack.c (_stp_stack_print): Just handle the SYM_VERBOSE_FULL
and SYM_VERBOSE_BRIEF cases. SYM_VERBOSE_NONE isn't supported directly
anymore.
(_stp_stack_snprint): Rename to ...
(_stp_stack_hexstring): ... this. Remove now unused verbose argument.
Just handle hexstring backtrace only, call through to __stp_stack_print.
* tapset/context-unwind.stp (print_backtrace): Explicitly use
SYM_VERBOSE_FULL.
(backtrace): Use _stp_stack_hexstring().
* tapset/ucontext-unwind.stp (ubacktrace): Likewise.
Mark Wielaard [Fri, 25 Jun 2010 10:00:42 +0000 (12:00 +0200)]
Combine _stp_symbol_print and _stp_usymbol_print into _stp_print_symbol.
These functions did exactly the same, except the usymbol one took a
task_struct. Combine them and use task_struct being NULL as indicator
for wanting kernel/module symbols.
* runtime/sym.c (_stp_symbol_print): Combine with...
(_stp_usymbol_print): ... this into ...
(_stp_print_symbol): combined function.
* tapset/context-symbols.stp (print_stack): Call _stp_print_symbol with NULL.
* tapset/ucontext-symbols.stp (print_ustack): Call _stp_print_symbol with tsk.
* runtime/stack.c (_stp_stack_print): Use _stp_print_symbol.
(_stp_stack_print_tsk): Likewise.
* runtime/stack-arm.c (__stp_stack_print): Likewise.
* runtime/stack-ia64.c (__stp_show_stack_sym): Likewise.
* runtime/stack-ppc.c (__stp_stack_print): Likewise.
* runtime/stack-s390.c (__stp_show_stack): Likewise.
Mark Wielaard [Thu, 24 Jun 2010 16:19:35 +0000 (18:19 +0200)]
Split _stp_mod_sec_lookup into _stp_kmod_sec_lookup and _stp_umod_lookup.
* runtime/sym.c (_stp_mod_sec_lookup): Split into...
(_stp_kmod_sec_lookup): ... for kernel/module lookup and ...
(_stp_umod_lookup): For user space/vma lookup.
(_stp_kallsyms_lookup): Use either of the above and calculate rel_addr.
* runtime/unwind.c (unwind): Call either _stp_umod_lookup or
_stp_kmod_sec_lookup.
* tapset/context-symbols.stp (probemod): Use _stp_kmod_sec_lookup.
(modname): Likewise.