On Mon, Oct 20, 2008 at 11:33 AM, P. Remek <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using pid provider and I have noticed that return probe is not fired when
> leaving function with variable number of arguments using va_start and va_stop.
> Having such code:
>
> log() {
> va_start(ap, fmt);
> log_vwrite(l, fmt, ap);
> va_end(ap);
> }
>
> I get such output from dtrace:
>
> -> log
> -> log_vwrite
> <- log
>
>
> Is this a dtrace problem or is there some general problem why it can't work
> when using variable argument lists?
I've tested this, and I'm not seeing the same problem you are. For
example, using this program (compiled using 'cc foo.c' using Sun
Studio 12):
------------------------------------------------------------------------
#include <stdio.h>
#include <stdarg.h>
void
bar(int n_args, va_list ap)
{
int argnum = 0;
int sum = 0;
while (argnum < n_args) {
sum += va_arg(ap, int);
argnum++;
}
printf("Sum = %d\n", sum);
}
void
foo(int n_args, ...)
{
va_list ap;
va_start(ap, n_args);
bar(n_args, ap);
va_end(ap);
}
int
main()
{
foo(5, 1, 2, 3, 4, 5);
}
------------------------------------------------------------------------
I get the following result:
------------------------------------------------------------------------
# dtrace -F -c ./a.out -n 'pid$target:a.out::entry,pid$target:a.out::return'
dtrace: description 'pid$target:a.out::entry,pid$target:a.out::return'
matched 8 probes
Sum = 15
CPU FUNCTION
0 -> _start
0 <- _start
0 <- _start
0 <- _start
0 <- _start
0 -> main
0 -> foo
0 -> bar
0 <- bar
0 <- foo
0 <- main
0 <- _start
dtrace: pid 866 has exited
#
------------------------------------------------------------------------
Do you have any more information? Are you using any interesting
compiler options? What architecture are you compiling on? (I tested
this on SPARC.)
Chad
_______________________________________________
dtrace-discuss mailing list
[email protected]