This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
dwarf unwinder branch
- From: Martin Hunt <hunt at redhat dot com>
- To: systemtap at sourceware dot org
- Date: Mon, 31 Mar 2008 12:11:00 -0400
- Subject: dwarf unwinder branch
- Organization: Red Hat Inc.
I have checked in some major work on a new branch. Please take a look
if you are interested.
Changes from main branch:
* new dwarf unwinder. Stack traces are now far more accurate than with
the previous best-guess unwinder.
* staprun no longer serves any symbols. kernel symbols are compiled in
by stap. The currently loaded modules, their locations and symbols are
read directly from the kernel.
* stapio now can send unwind data when requested. stapio is running as
a normal user and perhaps not secure, but I think the best a hacker
could do would be to fool systemtap into making inaccurate backtraces.
Implementation details:
The unwinder only does kernel and module unwinding at the moment. It is
intended to support userspace unwinding in the future.
The unwinder uses the call frame instruction parser from the 2.6.19.7
kernel. The unwinder was removed for the 2.6.20 kernel due to problems
getting it to work relaibly with a crashing system.
When a module is loaded, my code gets the unwind data and does a lot of
checking on it. Any problems and all the data is freed and not used.
For i386 and arm only, if kernel is built with CONFIG_STACK_POINTER,
frames are used for backtracing instead of the new code.
The dwarf unwinder is only tested for i386 and x86_64.
It would be nice to have a way for stap to detect when unwinding is
used in a script so it can disable it when not used. I'll submit a PR
for this.
All stack reads go through _stp_read_address(). I have seen zero
problems since I made this change.
/** Safely read from userspace or kernelspace.
* On success, returns 0. Returns -EFAULT on error.
*
* This uses __get_user() to read from userspace or
* kernelspace. Will not sleep or cause pagefaults when
* called from within a kprobe context.
*
* @param segment . KERNEL_DS for kernel access
* USER_DS for userspace.
*/
#define _stp_read_address(x, ptr, segment) \
({ \
long ret; \
mm_segment_t ofs = get_fs(); \
set_fs(segment); \
ret = __stp_get_user(x, ptr); \
set_fs(ofs); \
ret; \
})
---------------
How to get it:
> git clone ssh://sources.redhat.com/git/systemtap.git
> git branch -r unwind origin/unwind
> git checkout unwind