You can certainly do this, but it's going to be kind of a pain.
Two tips: you'll want to copyin the format string, and then you'll want to
have an iterative step that you unroll that handles the cases of the various
format characters.
Adam
On Wed, Jul 16, 2008 at 10:01:38AM -0700, Fat Ted wrote:
> In a C program, if I have several calls to printf (say):
>
> printf("This is not a test");
> printf("How do you like them %s","apples");
> printf("%d is a magic %s",3,"number");
>
> and I then want to use Dtrace to fetch the args from all 3 printfs
>
> (This will pull out the basic string)
>
> pid$1::printf:entry
> {
> print_template = stringof(copyinstr(arg0));
> printf("%s",print_template);
> }
>
> Is it possible to fetch (or how can I?) the additional args to printf if you
> don't know how many args will be used and of what type they are?
> E.G
> the first printf above doesn't have an arg1,
> the second printf has arg1 of type string,
> the third printf has arg1 of type int (and an arg2 !)
>
> How can I write a probe or probes to handle these variable cases?
>
> Cheers!
>
>
> --
> This message posted from opensolaris.org
> _______________________________________________
> dtrace-discuss mailing list
> [email protected]
--
Adam Leventhal, Fishworks http://blogs.sun.com/ahl
_______________________________________________
dtrace-discuss mailing list
[email protected]