public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Bug and question
@ 2005-10-12  9:41 Sebastien Decugis
  2005-10-12 10:09 ` Daniel P. Berrange
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastien Decugis @ 2005-10-12  9:41 UTC (permalink / raw)
  To: SystemTAP

Hi all,

--- bug ---
Running the latest snapshot posted on this mailing-list (on saturday),
I've run into a bug: when using the "substr" function, 'man stapfuncs'
tells that the third argument is an offset, but it appears to be an
absolute position.

As an example we have:

str = "abcdef"
sstr = substr(str, 2, 3)   

here, sstr is "c" whereas it should be "cde" according to man.

--- question ---
I want to access a structure field of a parameter which is a char table,
and I want to display it as a string. Is it possible? Here is what I
want to do:

* kernel code:

struct net_device {
    char name[LEN];
    ...
}

int dev_put(struct net_device *dev)
{
   ...
}

* stap code:
probe kernel.function("dev_put") {
    print("device name: " . $dev->name . "\n")
}


This doesn't work yet, stap complains that $dev->name is of type
'long'... Is there a workaround? I think I only get the 'name' address
yet (can be displayed if casted to a string). How can I get the string?

Thanks in advance, and SystemTap is a great tool :)
Seb.

-- 
Sebastien Decugis
Bull S.A.

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

* Re: Bug and question
  2005-10-12  9:41 Bug and question Sebastien Decugis
@ 2005-10-12 10:09 ` Daniel P. Berrange
  2005-10-12 11:06   ` Sebastien Decugis
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel P. Berrange @ 2005-10-12 10:09 UTC (permalink / raw)
  To: Sebastien Decugis; +Cc: SystemTAP

On Wed, Oct 12, 2005 at 11:42:33AM +0200, Sebastien Decugis wrote:
> I want to access a structure field of a parameter which is a char table,
> and I want to display it as a string. Is it possible? Here is what I
> want to do:

Yes, but you need to use either 'user_string' or 'kernel_string' functions
to convert into the systemtap runtime string object. If you don't do this
you'll just get back the pointer as a long.
 
> probe kernel.function("dev_put") {
>     print("device name: " . $dev->name . "\n")
> }

Try changing it to look like:

  probe kernel.function("dev_put") {
      print("device name: " . kernel_string($dev->name) . "\n")
  }

Regards,
Dan.
-- 
|=- Red Hat, Global Professional Services, London.  +44 (0)7977 267 243 -=|
|=-         Perl modules: http://search.cpan.org/~danberr/              -=|
|=-             Projects: http://freshmeat.net/~danielpb/               -=|
|=- GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=| 

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

* Re: Bug and question
  2005-10-12 10:09 ` Daniel P. Berrange
@ 2005-10-12 11:06   ` Sebastien Decugis
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastien Decugis @ 2005-10-12 11:06 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: SystemTAP

Great, thank you! :)


On Wed, 2005-10-12 at 11:09 +0100, Daniel P. Berrange wrote:
> On Wed, Oct 12, 2005 at 11:42:33AM +0200, Sebastien Decugis wrote:
> > I want to access a structure field of a parameter which is a char table,
> > and I want to display it as a string. Is it possible? Here is what I
> > want to do:
> 
> Yes, but you need to use either 'user_string' or 'kernel_string' functions
> to convert into the systemtap runtime string object. If you don't do this
> you'll just get back the pointer as a long.
>  
> > probe kernel.function("dev_put") {
> >     print("device name: " . $dev->name . "\n")
> > }
> 
> Try changing it to look like:
> 
>   probe kernel.function("dev_put") {
>       print("device name: " . kernel_string($dev->name) . "\n")
>   }
> 
> Regards,
> Dan.
-- 
Sebastien Decugis
Bull S.A.

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

end of thread, other threads:[~2005-10-12 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-12  9:41 Bug and question Sebastien Decugis
2005-10-12 10:09 ` Daniel P. Berrange
2005-10-12 11:06   ` Sebastien Decugis

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).