>
> translator student_t <student_t *P> {
> age = *(int *)copyin((uintptr_t)&P->age, sizeof (int));
> name = (char *)copyin((uintptr_t)*P->name, sizeof (char *));
> class = *(char *)copyin((uintptr_t)&P->class, sizeof (char));
> };
>
> pid$target::setdata:return
> {
> xlate<struct student_t *>(arg2);
> printf("\nit is %i ", arg2->age);
> }
>
> =====================================
>
> When run it returns :
> dtrace: failed to compile script ./structs.d: line 18: cannot translate from
> "int64_t" to "struct student_t *"
>
> There's probably something obvious that I'm missing here. Any ideas ?
Two problems:
1. Your translator's input type is student_t *. The arg2 (and all argN)
variables for PID provier have no types associated (they are just integers)
So you have to cast arg2 to struct student *, or alternatively declare
the translator input type as integer and cast inside of the translator.
2. Your clause consists of an xlate statement and a printf statement.
xlate is not a function, it's an operator -- think of it like a type cast.
By making it a separate statement that statement has no effect.
You need to printf("it is %i", (xlate<struct student_t *>(arg2))->age);
or alternatively you can assign to a local variable etc.
-Mike
--
Mike Shapiro, Sun Microsystems Fishworks. blogs.sun.com/mws/
_______________________________________________
dtrace-discuss mailing list
[email protected]