This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[Bug tapsets/6580] revamp backtrace-related tapset functions
- From: "mjw at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: systemtap at sources dot redhat dot com
- Date: 1 Sep 2008 12:32:37 -0000
- Subject: [Bug tapsets/6580] revamp backtrace-related tapset functions
- References: <20080529170209.6580.fche@redhat.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From mjw at redhat dot com 2008-09-01 12:32 -------
caller()/ucaller() can probably be implemented more efficiently than as full
wrappers around the caller(1)/ucaller(1). For example the following currently
works to get a quick user space symbol, without need to do a full unwind (a full
unwind is necessary for getting anything more). If you just want to get the user
address and symbol (for static binaries included with -d only for now):
# Returns the address in userspace that the current task was at when the
# probe occurred.
function uaddr:long () %{ /* pure */
#include <asm/processor.h>
struct pt_regs *uregs;
uregs = task_pt_regs(current);
THIS->__retvalue = (int64_t) REG_IP(uregs);
%}
# Translates an address to a function symbol. Might be expensive
# so use sparingly in probes, try translating only in end probes.
function uaddr_symbol:string (uaddr: long) %{ /* pure */
_stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, THIS->uaddr);
%}
Can be used with something like the following for a quick and dirty "profiler":
stap -d /path/to/my-static-binary -e 'probe timer.ms(100) {t = tid(); if (t !=
0) { printf("%s:.%d 0x%xd:%s\n", execname(), tid(), uaddr(),
uaddr_symbol(uaddr())); } }'
--
http://sourceware.org/bugzilla/show_bug.cgi?id=6580
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.