I'm new to dtrace and trying to figure out how I can use it as a tool for
debugging.
I have a few lines for testing :
=====================================
#include<stdio.h>
#include<string.h>
typedef struct {
int age;
char name[24];
char class;
} student_t;
int setdata(int count,student_t *first) {
first->age = 24;
strcpy(first->name,"Nigel S");
first->class = 'I';
return 100;
}
int main() {
student_t first;
int count=12;
setdata(count,&first);
printf("name is %s\n",first.name);
return 1;
}
=====================================
Compiled with "-g", I would like to use dtrace to examine the structure. Using
compiled in probes is not an option.
I've tried something like this :
=====================================
#!/usr/sbin/dtrace -s
typedef struct {
int age;
char name[24];
char class;
} student_t;
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 ?
If anyone had any example of examining a structure in thier own code using
dtrace that would be great to see as well.
TIA
--
This message posted from opensolaris.org
_______________________________________________
dtrace-discuss mailing list
[email protected]