public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Forw: [ahoole@islandnet.com: Accessing a va_list element from a probe]
@ 2014-01-05 20:18 Frank Ch. Eigler
  2014-01-09 16:17 ` Frank Ch. Eigler
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Ch. Eigler @ 2014-01-05 20:18 UTC (permalink / raw)
  To: systemtap

From: "Alexander M. Hoole" <ahoole@islandnet.com>
Subject: Accessing a va_list element from a probe
Date: Sun, 5 Jan 2014 11:50:39 -0800

[...]

I was wondering if you have ever attempted to access a va_list from a probe
in user-space.  I can access the arguments; however, I'm presently puzzled
as to how to elegantly access the individual items of the va_list.  For
example, if we setup a probe as follows:

.

probe process("/lib64/libc-2.17.so").function("printf")

{

printf("\tPID=%d, CMD=%s\n",pid(),execname())

            printf("\tArgs: %s\n", $$parms) 

            printf("\tArg[1]: %s\n", user_string($format))

            printf("\tArg[2]: %p\n", $arg)

}

.

 

According to stap -L we have the following arguments available:

.

# stap -L 'process("/lib64/libc-2.17.so").function("printf")'

process("/usr/lib64/libc-2.17.so").function("__printf@/usr/src/debug/glibc-2
.17-c758a686/stdio-common/printf.c:28") $format:char const* $arg:va_list
$done:int

.

 

If a program were to call something like the following:

.

printf("Person %s is %d years old\n", name, age);

.

 

Do you have any ideas how I could access name and age?

 

Any assistance would be appreciated.

 

Thanks,

Alex

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

* Re: Forw: [ahoole@islandnet.com: Accessing a va_list element from a probe]
  2014-01-05 20:18 Forw: [ahoole@islandnet.com: Accessing a va_list element from a probe] Frank Ch. Eigler
@ 2014-01-09 16:17 ` Frank Ch. Eigler
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Ch. Eigler @ 2014-01-09 16:17 UTC (permalink / raw)
  To: systemtap, ahoole


Hi -

> I was wondering if you have ever attempted to access a va_list from a probe
> in user-space.  I can access the arguments; however, I'm presently puzzled
> as to how to elegantly access the individual items of the va_list.  [...]
>
> According to stap -L we have the following arguments available:
> # stap -L 'process("/lib64/libc-2.17.so").function("printf")'
> process("/usr/lib64/libc-2.17.so").function("__printf@/usr/src/debug/glibc-2
> .17-c758a686/stdio-common/printf.c:28") $format:char const* $arg:va_list
> $done:int

My guess is that one way to do this would be a tapset function kind of
like tokenize(), where some internal state is kept from call to call
(the va_list pointer), and consecutive varargs are fetched off of the
stack, based upon types & sizes, with user_long() etc.  It'd have to
reimplement gcc __builtin_va_arg, which is not THAT bad, but a bit of
work.

- FChE

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

end of thread, other threads:[~2014-01-09 16:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-05 20:18 Forw: [ahoole@islandnet.com: Accessing a va_list element from a probe] Frank Ch. Eigler
2014-01-09 16:17 ` Frank Ch. Eigler

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