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.
Josh Stone [Wed, 23 Jun 2010 21:28:16 +0000 (14:28 -0700)]
PR10830 cont'd: Rename pp1() -> pn() and isolate it
The new name is "pn" to evoke "probe name". It is also now isolated in
its own tapset file, so it's less likely to be pulled into and conflict
with a user's script accidentally.
No real code changes here -- it's roughly just s/pp1/pn/ and
s/probe_point_listing/probe_name/.
Mark Wielaard [Wed, 23 Jun 2010 19:47:53 +0000 (21:47 +0200)]
Correct testing for compat task. Always use our own test.
is_compat_task(), when defined in the kernel, is really just for testing
whether or not we are in a 32-compat syscall. It does not definitely tell
us whether or not the current task is a 32bit compat task. So always use
our own test_thread_flag() with the arch specific TIF_flag.
* runtime/autoconf-is-compat-task.c: Removed.
* buildrun.cxx (compile_pass): Remove is-compat-task check.
* runtime/compatdefs.h: Detect s390 specific TIF flag. Always define
_stp_is_compat_task() when CONFIG_COMPAT defined.
* tapset/conversions.stp (user_long): Use _stp_is_compat_task().
(user_long_warn): Likewise.
Mark Wielaard [Wed, 23 Jun 2010 19:07:33 +0000 (21:07 +0200)]
Better split kernel/user space address symbol lookups.
* runtime/sym.c (_stp_mod_sec_lookup): Don't fall through to kernel module
address search when we know to be looking for a user space module/vma.
* tapset/context-symbols.stp (probefunc): Clarify documentation.
Use user_mode(CONTEXT->regs) check. Pass NULL for task to
_stp_symbol_snprint().
(probemod): Clarify documentation. Pass NULL for task to
_stp_mod_sec_lookup().
(modname): Likewise.
(symname): Clarify documentation.
(symdata): Likewise.
David Smith [Wed, 23 Jun 2010 16:39:05 +0000 (11:39 -0500)]
Fixed PR11725 by adding big-endian support to systemtap.printf/bin6.exp.
* testsuite/systemtap.printf/bin6.exp: Added a big-endian result string
and code to pick the correct result string bassed on the system running
the test.
Josh Stone [Wed, 23 Jun 2010 00:44:35 +0000 (17:44 -0700)]
PR10830: Add pp1() for the high-level probe name
This is a new function which should return the same high-level name that
"stap -l" gives. (e.g. syscall.open instead of kernel.function...)
* translate.cxx (c_unparser::emit_common_header): Add probe_point_listing.
(translate_pass): Add pp1 to stap_probe, predicated on
STP_NEED_PROBE_POINT_LISTING so we don't waste space.
* tapsets.cxx (common_probe_init): Set pp1 to script_location().
(common_probe_entryfn_prologue): Write pp1 to the CONTEXT.
* tapset-timers.cxx (profile_derived_probe_group::emit_module_decls):
Fixup CONTEXT->probe_point_listing, since it loops individual probes
manually.
* tapset/context.stp (pp1): New, expose the location to scripts.
* testsuite/buildok/context-embedded.stp: Build pp1().
* testsuite/systemtap.base/pp.{exp,stp}: Test the difference between
pp() and pp1().
Josh Stone [Wed, 23 Jun 2010 00:02:37 +0000 (17:02 -0700)]
Factor out common probe elements
The probes in every tapset type all have a handler (ph) and a
probe_point (pp), which are initialized and used in exactly the same
way. Let's bring that out into a common stap_probe struct.
This will also ease new fields, e.g. for PR10830.
* translate.cxx (translate_pass): Define struct stap_probe, also making
the decision of whether pp is better as char* or char[].
* tapsets.cxx (common_probe_init): Initialize a runtime stap_probe from
any translator derived_probe.
(common_probe_entryfn_prologue): Take a stap_probe instead of pp.
* tapset*.cxx: Adjust all tapsets to use the features above.
Josh Stone [Tue, 22 Jun 2010 20:01:10 +0000 (13:01 -0700)]
Add a function for getting a probe's script location
* elaborate.cxx (derived_probe::script_location): New, factor out the
code for grabbing the "friendly" location of a probe, as specified in
the script.
* main.cxx (printscript): Use it.
Josh Stone [Tue, 22 Jun 2010 18:42:30 +0000 (11:42 -0700)]
Make probe::almost_basest() work
* staptree.h (probe::almost_basest): Probes are the basest, not almost.
* elaborate.h (derived_probe::almost_basest): If base says 0, then the
almost_basest is this one.
* main.cxx (printscript): Use p->almost_basest() instead of collecting
the entire derivation chain.