public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Getting userspace stack traces with userspace probes ?
@ 2011-01-26 16:18 Daniel P. Berrange
  2011-01-26 16:27 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel P. Berrange @ 2011-01-26 16:18 UTC (permalink / raw)
  To: systemtap

I'm doing some troubleshooting of the libvirt daemon
using userspace probes. My stap script looks like

  probe process("/usr/lib64/libvirt.so").function("virDomainObjUnref") {
      printf("Unref %p %d\n", $dom, $dom->refs);
  }

  probe process("/usr/lib64/libvirt.so").function("virDomainObjRef") {
      printf("Ref %p %d\n", $dom, $dom->refs);
  }

  probe process("/usr/lib64/libvirt.so").function("virDomainObjNew").return {
      printf("New %p %d\n", $return, $return->refs);
  }

This is printing what I expect. I now want to get associated
userspace stack traces, so I tried adding

      print_ustack(ubacktrace())

And / or

      print_ubacktrace()

To all the probe points, all it ever prints for a stack trace is

 0x3992a52e10 : virDomainObjUnref+0x0/0x100 [libvirt.so.0.8.4]
 0x45900f [libvirtd+0x5900f/0xe8000]

Which is far too small compared to what GDB says the stack
trace is, eg I'm expecting at least 6-8 levels deep

  (gdb) bt
  #0  virDomainObjUnref (dom=0x1b49390) at conf/domain_conf.c:828
  #1  0x0000000000470f33 in qemuMonitorFree (mon=0x1cb6640) at qemu/qemu_monitor.c:202
  #2  qemuMonitorUnref (mon=0x1cb6640) at qemu/qemu_monitor.c:221
  #3  0x0000000000416ebf in virEventCleanupHandles () at event.c:548
  #4  0x0000000000417c8e in virEventRunOnce () at event.c:612
  #5  0x0000000000418593 in qemudOneLoop () at libvirtd.c:2226
  #6  0x00000000004188b9 in qemudRunLoop (opaque=0x1b42850) at libvirtd.c:2335
  #7  0x0000003980e07761 in start_thread (arg=0x7f6e63423700) at pthread_create.c:301
  #8  0x00000039806e098d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

Am I using the wrong functions for getting stack traces,
or is it just not possible to get reliable stacks from
userspace probes ?

FYI, I'm using systemtap-1.3-3.fc13.x86_64 and
kernel 2.6.34.7-66.fc13.x86_64

Regards,
Daniel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Getting userspace stack traces with userspace probes ?
  2011-01-26 16:18 Getting userspace stack traces with userspace probes ? Daniel P. Berrange
@ 2011-01-26 16:27 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2011-01-26 16:27 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: systemtap

Hi Daniel,

On Wed, 2011-01-26 at 16:17 +0000, Daniel P. Berrange wrote:
> This is printing what I expect. I now want to get associated
> userspace stack traces, so I tried adding
> 
>       print_ustack(ubacktrace())
> 
> And / or
> 
>       print_ubacktrace()
> 
> To all the probe points, all it ever prints for a stack trace is
> 
>  0x3992a52e10 : virDomainObjUnref+0x0/0x100 [libvirt.so.0.8.4]
>  0x45900f [libvirtd+0x5900f/0xe8000]

   ^- this is a very poor hint from systemtap that it found an
      address in a module (libvirtd) but could find the symbol
      (and by extension the unwind table).

> Which is far too small compared to what GDB says the stack
> trace is, eg I'm expecting at least 6-8 levels deep
> 
>   (gdb) bt
>   #0  virDomainObjUnref (dom=0x1b49390) at conf/domain_conf.c:828
>   #1  0x0000000000470f33 in qemuMonitorFree (mon=0x1cb6640) at qemu/qemu_monitor.c:202
>   #2  qemuMonitorUnref (mon=0x1cb6640) at qemu/qemu_monitor.c:221
>   #3  0x0000000000416ebf in virEventCleanupHandles () at event.c:548
>   #4  0x0000000000417c8e in virEventRunOnce () at event.c:612
>   #5  0x0000000000418593 in qemudOneLoop () at libvirtd.c:2226
>   #6  0x00000000004188b9 in qemudRunLoop (opaque=0x1b42850) at libvirtd.c:2335
>   #7  0x0000003980e07761 in start_thread (arg=0x7f6e63423700) at pthread_create.c:301
>   #8  0x00000039806e098d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115
> 
> Am I using the wrong functions for getting stack traces,
> or is it just not possible to get reliable stacks from
> userspace probes ?

You are doing the right things, but stap isn't smart enough to figure it
all out on its own. The simplest way to tell stap you want all symbols
and unwind tables is to say something like:

$ stap -d /usr/sbin/libvirtd --ldd [...]

> FYI, I'm using systemtap-1.3-3.fc13.x86_64 and
> kernel 2.6.34.7-66.fc13.x86_64

systemtap 1.4 (just released) should at least give you a hint what to
add if it cannot unwind further.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-26 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-26 16:18 Getting userspace stack traces with userspace probes ? Daniel P. Berrange
2011-01-26 16:27 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).