This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: accessing target globals with systemtap


Jeff Haran <Jeff.Haran@citrix.com> writes:

> [...]
> probe begin
> {
>         printf("arp_tbl %p\n", @var("arp_tbl@net/ipv4/arp.c"))
> }

This won't work for a few more reasons.

@var() resolves within the context of the probe point.  probe begin
does not offer a useful context -- it doesn't say e.g. whether this
is a kernel or userspace program whose "arp_tbl" you're looking for.
Try instead printing this value from a kernel.function type probe.

Second, @var("arp_tbl") will result in a struct neigh_table, something
that cannot be printed with a %p.  Systemtap will give you a type
mismatch error, unless e.g. you print  & @var(...)  to print the address.
(You can hex-dump the structure via printf("%*m") etc.)

> [...]
> I am guessing that's because of my older version of stap:

That's correct.

> [root@s01b06 jharan]# stap --version
> Systemtap translator/driver (version 1.6/0.152 non-git sources)
> [...]

> Is there a way for me to get access to a kernel global in my version of stap?
> Or do I need to upgrade in order to do this?

Another way would be to use embedded-C:

%{ 
#include <net/arp.h>
%}
function the_table_address:long () %{ /* unmangled */
  /* rely on EXPORT_SYMBOL ... to let this resolve */
  THIS->__retvalue = & arp_tbl;
%}
probe begin {
  // to find the base address
  printf("%p\n", the_table_address())
  // to fetch fields:
  printf("%d\n", @cast(the_table_address(),"neigh_table","kernel")->family);
}


> Or am I missing something more basic?

Nope.

- FChE


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]