Stan Cox [Tue, 12 Jan 2010 20:09:55 +0000 (15:09 -0500)]
Add attach to live process tests.
* sdt_misc.exp (sdt_misc.c): New funcs loop_check, int_handler, alrm_handler.
(sdt_misc.sdt): Add timer.ms
(test attach to a running process): New.
(test attach to a running process with .so markers): New.
Stan Cox [Mon, 11 Jan 2010 02:43:17 +0000 (21:43 -0500)]
Pull set of semaphore into its own function.
* tapsets.cxx (uprobe_derived_probe_group::emit_module_decls): Move
sdt_sem_address from standalone to stap_uprobes. Remove sdt_sem_tid.
In emitted function stap_uprobe_change_plus distinguish VM_EXEC/VM_WRITE
cases, use sdt_sem_address member, move setting of semaphores to new
emitted function stap_uprobe_change_semaphore_plus.
(stap_uprobe_process_found): Call stap_uprobe_change_semaphore_plus.
(stap_uprobe_mmap_found): Likewise.
* stap-postgres.stp (postgresrelease): New. Sync to current upstream version.
* stap-tcl.sh: Check if wget failed.
* stap-tcl.stp: Check for skipped probes.
* xulrunner.exp: Check if wget failed.
* tapsets.cxx (emit_module_decls): #undef TRACE_INCLUDE_FILE
in front of each #include'd trace/event header, to prevent
macro redefinition.
(init_dw): Respect pending_interrupts in traceprobe module
compilation loop.
David Smith [Fri, 8 Jan 2010 19:26:47 +0000 (13:26 -0600)]
Fixed PR 11148 by reworking transport directory locks.
* runtime/transport/transport.c (_stp_get_root_dir): No longer
locks/unlocks the transport directory.
(_stp_remove_root_dir): Ditto.
(_stp_transport_fs_init): Locks and unlocks the transport directory.
Ensures that the root directory can't be deleted between calling
_stp_get_root_dir() and creating the module dir.
(_stp_transport_fs_close): Locks and unlocks the transport directory.
Mark Wielaard [Thu, 7 Jan 2010 16:54:28 +0000 (17:54 +0100)]
Fix multi-piece constant failure in vta-test.exp on 32bit systems.
Commit 73b5e9 "Make sure loc2c declare_noncontig_union for different locs
don't overlap", wasn't complete. It only took into account having a piece
becuase of a noncontiguous loc and a constant loc together. But pieces can
be nested deeper (newer gcc outputs multiple constant locations for one
piece on 32bit systems). This patch keeps track of the piece declaration
depth. Another approach could have been to have each sub-piece in its own
local scope, but keeping track of the depth and naming the temporary unions
distinct fitted the current code better. It currently only supports a depth
of 10. An error will be emitted if a location construct needs more than 10
pieces to be assembled.
* loc2c.c (declare_noncontig_union): Take depth argument. Always use the
same name for the union (u_pieces<depth>).
(translate_base_fetch): Take depth argument. Use it to calculate union
names.
(translate_base_store): Likewise.
(c_translate_fetch): Pass in depth zero.
(c_translate_store): Likewise.
(c_translate_pointer): Likewise.
(c_translate_pointer_store): Likewise.
Mark Wielaard [Wed, 6 Jan 2010 15:24:56 +0000 (16:24 +0100)]
Fix get_cfa_ops failure on shared libraries.
The fix for PR10923 (fafeaf) wasn't completely correct. All cfa lookups
need to be done through the relative pc (without bias) of the module we
are looking in.
* dwflpp.cxx (translate_location): Call get_cfa_ops with relative pc.
Tim Moore [Tue, 5 Jan 2010 14:18:57 +0000 (15:18 +0100)]
bz6436 backtraces from uprobes
This implements proper unwinding from uprobes in the presence of
uretprobe trampolines.
* runtime/stack.c (_stp_stack_print): Rework for uprobe context case
and refactor a bit.
* runtime/uprobes2/uprobes.h (GET_PC_URETPROBE_NONE): new constant
* runtime/uprobes2/uprobes.c (uprobe_get_pc): Support translating the
trampoline function from uprobe context in addition to uretprobe
context.
* runtime/uprobes/uprobes.h (GET_PC_URETPROBE_NONE): ditto
* runtime/uprobes/uprobes.c (uprobe_get_pc): ditto
* tapsets.cxx (uprobe_derived_probe_group::emit_module_decls):
Initialize ri in context to GET_PC_URETPROBE_NONE in generated
enter_uprobe_probe.
* testsuite/systemtap.context/fib.stp: Add an option to do a backtrace
on function entry.
* testsuite/systemtap.context/fib.exp: Test backtrace in function
entry (uprobe) probes.
Mark Wielaard [Tue, 5 Jan 2010 09:29:27 +0000 (10:29 +0100)]
Make publican invocation make -j safe.
publican isn't make -j safe. So cheat a little, always create pdf and html
at the same time, then make html depend on pdf build for copying.
* doc/beginners/Makefile.am ($(SBG).pdf): Also generate html version.
($(SBG).html): Depend on pdf version, then copy.
* doc/beginners/Makefile.in: Regenerated.
Tim Moore [Thu, 31 Dec 2009 09:15:15 +0000 (10:15 +0100)]
grapher: workaround for bz 11118
* grapher/CairoWidget.cxx (CairoTextBox::draw): Use
boost::is_from_range instead of is_any_of. Reports on the net
suggest that is_any_of triggers a compiler bug.
Mark Wielaard [Tue, 29 Dec 2009 20:05:55 +0000 (21:05 +0100)]
Fixup some memory tapset vm kernel function probe fallbacks.
Older kernels don't have all GFP constants defined, and the fallback
kernel function probe fallbacks don't have the same dwarf variable
names as the kernel trace point probes. So replace them with variables
that are available. bytes_alloc was sometimes a long and sometimes a
string, this caused scripts to fail depending on which alternative was
chosen for a particular kernel. So make it a long always.
This isn't a full solution since kmalloc is always inlined which makes
the kernel.function("kmalloc").return probe fail.
* tapset/memory.stp: Define __GFP_THISNODE, __GFP_RECLAIMABLE,
GFP_TEMPORARY, GFP_HIGHUSER_MOVABLE and GFP_THISNODE when not yet
defined.
(__vm.kmalloc.kp): Use $flags, not $gfp_flags. Set bytes_alloc equal
to bytes_req.
(__vm.kmem_cache_alloc.kp): Likewise. And use $cachep->buffer_size
for bytes_req.
(__vm.kmalloc_node.kp): Likewise.
(__vm.kmem_cache_alloc_node.kp): Likewise.
(__vm.kfree.kp): Use $ibjp for ptr, not $return.
(__vm.kmem_cache_free.kp): Likewise.
* testsuite/buildok/vm.tracepoints.stp: Move vm.kmalloc test to...
* testsuite/buildok/vm.tracepoints.kmalloc.stp: ... here.
Mark Wielaard [Tue, 29 Dec 2009 19:04:19 +0000 (20:04 +0100)]
Remove all caching from _stp_module_relocate.
This function now also does user space address relocation. The connection
with module loading/unloading was removed in commit 1b94bf which made all
symbol tables emitted at compile time. _stp_module_relocate is called from
the dwarf unwinder, and when doing some of the symbol lookup through
dwflpp::emit_adress now.
* runtime/sym.c (_stp_module_relocate): Remove last, last_sec and last_tsk
caching and invalidation code.
Tim Moore [Tue, 22 Dec 2009 22:30:56 +0000 (23:30 +0100)]
grapher: remove _zoomFactor from horizontal scaling calculation
This makes zooming more consistent and less buggy.
* grapher/Graph.cxx (Graph::draw): Set graph time spread using
_zoomFactor.
* grapher/Graph.hxx (Graph::getHorizontalScale): no _zoomFactor
* grapher/GraphWidget.cxx (on_motion_notify_event): Dragging increment
uses _zoomFactor.
(on_scroll_event): Set extents after changing the zoom factor with
the scroll wheel.
Tim Moore [Tue, 22 Dec 2009 18:48:20 +0000 (19:48 +0100)]
grapher: scale from right end of graph
The right side of the graph represents the most recent time. Since
there is never anything interesting to the right of that, it makes
sense to have the origin of the scaling be there.
* grapher/Graph.hxx (getHorizontalScale): new function
* grapher/GraphStyle.cxx (GraphStyleBar::draw, GraphStyleDot::draw,
GraphStyleEvent::draw): Use cairo transform functions to set up
scaling.
(GraphStyleBar::dataIndexAtPoint, GraphStyleEvent::dataIndexAtPoint):
Base calculations on scaling from right.
Tim Moore [Tue, 22 Dec 2009 10:35:38 +0000 (11:35 +0100)]
grapher: scroll continuously with time
Don't scale graph based on how much data will fit. This didn't work
very well and resulted in distracting, weird scale changes. We now
assume that scripts output their time (x axis) in milliseconds.
* grapher/Graph.hxx (setCurrentTime): New function.
* grapher/Graph.cxx (Graph::draw): Assume a fixed default scale of 1
pixel = 5 milliseconds and don't do any autoscaling.
* grapher/GraphWidget.cxx (GraphWidget constructor): Set global time
base on startup.
(on_expose_event): Don't search graphs for earliest time.
* grapher/GraphWidget.hxx (_timeBaseInitialized): delete
* grapher/Time.hxx: new file; interface to timeval.
Mark Wielaard [Mon, 21 Dec 2009 12:02:19 +0000 (13:02 +0100)]
PR11015 Support shared library reloading (in different processes)
* runtime/task_finder_vma.c (stap_remove_vma_map_info): Return negative
status on failure.
(stap_find_vma_map_info): Likewise.
(stap_find_vma_map_info_user): New function.
(stap_drop_vma_maps): New function.
* runtime/sym.h (addr): Renamed to static_addr, to store addresses for
sections which are always mapped at the same address.
(_stp_module_relocate): Add extra struct task_struct *tsk argument.
* runtime/sym.c (_stp_tf_exec_cb): New callback, calls stap_drop_vma_maps.
(_stp_tf_mmap_cb): Don't store address in module.section, but call
stap_add_vma_map_info() per tsk->group_leader for matched module.
Don't register empty/null modules.
(_stp_module_relocate): Take extra struct task_struct *tsk argument,
cache last tsk used. Only use section->static_addr for none dynamic
modules. Use stap_find_vma_map_info_user() to locate dynamic modules.
(_stp_mod_sec_lookup): Add extra argument unsigned long *rel_addr to
optionally store relative address when module/section found.
(_stp_kallsyms_lookup): Use _stp_mod_sec_lookup to find relative address.
(_stp_sym_init): Register _stp_tf_exec_cb in stap_task_finder_target.
Add error check to see if task finder could be initialized.
* dwflpp.cxx (emit_address): Pass NULL for kernel/modules and current for
user tasks to _stp_module_relocate.
* runtime/transport/symbols.c (_stp_do_relocation): Set new static_addr
_stp_section field.
* runtime/unwind.c (adjustStartLoc): Take new struct task_struct *tsk
argument and pass to stap_find_vma_map_info_user and _stp_module_relocate
to find adjusted addr.
(_stp_search_unwind_hdr): Pass through struct task_struct *tsk.
(unwind_frame): Likewise.
* tapset/context-symbols.stp (probemod): Add NULL to _stp_mod_sec_lookup
call to indicate we aren't interested in relative address.
* tapsets.cxx (dwarf_derived_probe_group::emit_module_init): Pass NULL to
_stp_module_relocate to indicate kernel/module address.
Josh Stone [Tue, 22 Dec 2009 02:26:47 +0000 (18:26 -0800)]
PR11112: Check the full %m/M buffer, and limit the length
We already had code in place to try a deref on the requested memory
buffer, but it was missing the static-precision case. Thus, it was
possible to craft an address that would pass the check on the first byte
but would pagefault at the end of the buffer.
While we're at it, we should also be limiting the number of bytes in
such a read, so even legitimately-huge buffers won't chew up kernel
time. I've arbitrarily chosen 1024 as the limit, but we can revisit
that later. (see also PR10490)
TODO: we need a reliable testcase where a starting address is valid but
the end address is bogus. In PR11112, the reproducer was using a huge
precision to run off the heap, but we need something that will
consistently work even with <1024 length.
Mark Wielaard [Mon, 21 Dec 2009 12:02:19 +0000 (13:02 +0100)]
PR11015 Support shared library reloading (in different processes)
* runtime/task_finder_vma.c (stap_remove_vma_map_info): Return negative
status on failure.
(stap_find_vma_map_info): Likewise.
(stap_find_vma_map_info_user): New function.
(stap_drop_vma_maps): New function.
* runtime/sym.h (addr): Renamed to static_addr, to store addresses for
sections which are always mapped at the same address.
(_stp_module_relocate): Add extra struct task_struct *tsk argument.
* runtime/sym.c (_stp_tf_exec_cb): New callback, calls stap_drop_vma_maps.
(_stp_tf_mmap_cb): Don't store address in module.section, but call
stap_add_vma_map_info() per tsk->group_leader for matched module.
Don't register empty/null modules.
(_stp_module_relocate): Take extra struct task_struct *tsk argument,
cache last tsk used. Only use section->static_addr for none dynamic
modules. Use stap_find_vma_map_info_user() to locate dynamic modules.
(_stp_mod_sec_lookup): Add extra argument unsigned long *rel_addr to
optionally store relative address when module/section found.
(_stp_kallsyms_lookup): Use _stp_mod_sec_lookup to find relative address.
(_stp_sym_init): Register _stp_tf_exec_cb in stap_task_finder_target.
Add error check to see if task finder could be initialized.
* dwflpp.cxx (emit_address): Pass NULL for kernel/modules and current for
user tasks to _stp_module_relocate.
* runtime/transport/symbols.c (_stp_do_relocation): Set new static_addr
_stp_section field.
* runtime/unwind.c (adjustStartLoc): Take new struct task_struct *tsk
argument and pass to stap_find_vma_map_info_user and _stp_module_relocate
to find adjusted addr.
(_stp_search_unwind_hdr): Pass through struct task_struct *tsk.
(unwind_frame): Likewise.
* tapset/context-symbols.stp (probemod): Add NULL to _stp_mod_sec_lookup
call to indicate we aren't interested in relative address.
* tapsets.cxx (dwarf_derived_probe_group::emit_module_init): Pass NULL to
_stp_module_relocate to indicate kernel/module address.