dtracy: call dtptrigger with a struct pointer rather than a list of arguments; put return value in arg9

This commit is contained in:
aiju 2018-12-09 21:43:22 +00:00
parent b96be17376
commit ca851bbb5e
4 changed files with 71 additions and 50 deletions

View file

@ -30,6 +30,7 @@ typedef struct DTExpr DTExpr;
typedef struct DTProvider DTProvider;
typedef struct DTAgg DTAgg;
typedef struct DTBuf DTBuf;
typedef struct DTTrigInfo DTTrigInfo;
struct DTName {
char *provider;
@ -223,13 +224,25 @@ struct DTChan {
DTEnab *enab;
};
/* this struct collects the state during the execution of a probe */
struct DTTrigInfo {
/* filled in by caller of dtptrigger */
u64int arg[10];
/* filled in by dtptrigger */
int machno;
int epid;
u64int ts;
DTChan *ch;
};
void dtinit(int);
void dtsync(void);
/* probe functions */
DTProbe *dtpnew(DTName, DTProvider *, void *aux);
int dtpmatch(DTName, DTProbe ***);
void dtptrigger(DTProbe *, int, uvlong, uvlong, uvlong, uvlong);
void dtptrigger(DTProbe *, int, DTTrigInfo *);
/* expression functions */
int dteverify(DTExpr *);

View file

@ -525,9 +525,12 @@ static DTProbe *timerprobe;
static void
dtracytimer(void *)
{
DTTrigInfo info;
memset(&info, 0, sizeof(info));
for(;;){
tsleep(&up->sleep, return0, nil, 1000);
dtptrigger(timerprobe, m->machno, 0, 0, 0, 0);
dtptrigger(timerprobe, m->machno, &info);
}
}

View file

@ -18,55 +18,70 @@ extern Syscall *systab[];
#define WRAP0(x,y,z)\
Syscall z; uintptr x(va_list va){\
uintptr rc;\
dtptrigger(dtpsysentry[y], m->machno, 0, 0, 0, 0);\
DTTrigInfo info;\
memset(&info, 0, sizeof(info));\
dtptrigger(dtpsysentry[y], m->machno, &info);\
rc = z(va);\
dtptrigger(dtpsysreturn[y], m->machno, 0, 0, 0, 0);\
info.arg[9] = (uvlong) rc;\
dtptrigger(dtpsysreturn[y], m->machno, &info);\
return rc;\
}
#define WRAP1(x,y,z,type0)\
Syscall z; uintptr x(va_list va){\
uintptr rc;\
va_list vb = va;\
type0 arg0 = va_arg(vb, type0);\
dtptrigger(dtpsysentry[y], m->machno, (uvlong)arg0, 0, 0, 0);\
DTTrigInfo info;\
memset(&info, 0, sizeof(info));\
info.arg[0] = (uvlong) va_arg(vb, type0);\
dtptrigger(dtpsysentry[y], m->machno, &info);\
rc = z(va);\
dtptrigger(dtpsysreturn[y], m->machno, (uvlong)arg0, 0, 0, 0);\
info.arg[9] = (uvlong) rc;\
dtptrigger(dtpsysreturn[y], m->machno, &info);\
return rc;\
}
#define WRAP2(x,y,z,type0,type1)\
Syscall z; uintptr x(va_list va){\
uintptr rc;\
va_list vb = va;\
type0 arg0 = va_arg(vb, type0);\
type1 arg1 = va_arg(vb, type1);\
dtptrigger(dtpsysentry[y], m->machno, (uvlong)arg0, (uvlong)arg1, 0, 0);\
DTTrigInfo info;\
memset(&info, 0, sizeof(info));\
info.arg[0] = (uvlong) va_arg(vb, type0);\
info.arg[1] = (uvlong) va_arg(vb, type1);\
dtptrigger(dtpsysentry[y], m->machno, &info);\
rc = z(va);\
dtptrigger(dtpsysreturn[y], m->machno, (uvlong)arg0, (uvlong)arg1, 0, 0);\
info.arg[9] = (uvlong) rc;\
dtptrigger(dtpsysreturn[y], m->machno, &info);\
return rc;\
}
#define WRAP3(x,y,z,type0,type1,type2)\
Syscall z; uintptr x(va_list va){\
uintptr rc;\
va_list vb = va;\
type0 arg0 = va_arg(vb, type0);\
type1 arg1 = va_arg(vb, type1);\
type2 arg2 = va_arg(vb, type2);\
dtptrigger(dtpsysentry[y], m->machno, (uvlong)arg0, (uvlong)arg1, (uvlong)arg2, 0);\
DTTrigInfo info;\
memset(&info, 0, sizeof(info));\
info.arg[0] = (uvlong) va_arg(vb, type0);\
info.arg[1] = (uvlong) va_arg(vb, type1);\
info.arg[2] = (uvlong) va_arg(vb, type2);\
dtptrigger(dtpsysentry[y], m->machno, &info);\
rc = z(va);\
dtptrigger(dtpsysreturn[y], m->machno, (uvlong)arg0, (uvlong)arg1, (uvlong)arg2, 0);\
info.arg[9] = (uvlong) rc;\
dtptrigger(dtpsysreturn[y], m->machno, &info);\
return rc;\
}
#define WRAP4(x,y,z,type0,type1,type2,type3)\
Syscall z; uintptr x(va_list va){\
uintptr rc;\
va_list vb = va;\
type0 arg0 = va_arg(vb, type0);\
type1 arg1 = va_arg(vb, type1);\
type2 arg2 = va_arg(vb, type2);\
type3 arg3 = va_arg(vb, type3);\
dtptrigger(dtpsysentry[y], m->machno, (uvlong)arg0, (uvlong)arg1, (uvlong)arg2, (uvlong)arg3);\
DTTrigInfo info;\
memset(&info, 0, sizeof(info));\
info.arg[0] = (uvlong) va_arg(vb, type0);\
info.arg[1] = (uvlong) va_arg(vb, type1);\
info.arg[2] = (uvlong) va_arg(vb, type2);\
info.arg[3] = (uvlong) va_arg(vb, type3);\
dtptrigger(dtpsysentry[y], m->machno, &info);\
rc = z(va);\
dtptrigger(dtpsysreturn[y], m->machno, (uvlong)arg0, (uvlong)arg1, (uvlong)arg2, (uvlong)arg3);\
info.arg[9] = (uvlong) rc;\
dtptrigger(dtpsysreturn[y], m->machno, &info);\
return rc;\
}
/*TODO*/
@ -74,13 +89,17 @@ extern Syscall *systab[];
Syscall z; uintptr x(va_list va){\
uintptr rc;\
va_list vb = va;\
type0 arg0 = va_arg(vb, type0);\
type1 arg1 = va_arg(vb, type1);\
type2 arg2 = va_arg(vb, type2);\
type3 arg3 = va_arg(vb, type3);\
dtptrigger(dtpsysentry[y], m->machno, (uvlong)arg0, (uvlong)arg1, (uvlong)arg2, (uvlong)arg3);\
DTTrigInfo info;\
memset(&info, 0, sizeof(info));\
info.arg[0] = (uvlong) va_arg(vb, type0);\
info.arg[1] = (uvlong) va_arg(vb, type1);\
info.arg[2] = (uvlong) va_arg(vb, type2);\
info.arg[3] = (uvlong) va_arg(vb, type3);\
info.arg[4] = (uvlong) va_arg(vb, type4);\
dtptrigger(dtpsysentry[y], m->machno, &info);\
rc = z(va);\
dtptrigger(dtpsysreturn[y], m->machno, (uvlong)arg0, (uvlong)arg1, (uvlong)arg2, (uvlong)arg3);\
info.arg[9] = (uvlong) rc;\
dtptrigger(dtpsysreturn[y], m->machno, &info);\
return rc;\
}

View file

@ -122,17 +122,8 @@ dtgverify(DTChan *, DTActGr *g)
return 0;
}
typedef struct ExecInfo ExecInfo;
struct ExecInfo {
int machno;
int epid;
u64int ts;
u64int arg[10];
DTChan *ch;
};
int
dteexec(DTExpr *p, ExecInfo *info, s64int *retv)
dteexec(DTExpr *p, DTTrigInfo *info, s64int *retv)
{
s64int R[16];
u32int ins;
@ -240,7 +231,7 @@ dtpeekstr(uvlong addr, u8int *v, int len)
#define PUT8(c) PUT4(c); PUT4(c>>32);
static int
dtgexec(DTActGr *g, ExecInfo *info)
dtgexec(DTActGr *g, DTTrigInfo *info)
{
DTBuf *b;
u8int *bp;
@ -296,23 +287,18 @@ dtgexec(DTActGr *g, ExecInfo *info)
}
void
dtptrigger(DTProbe *p, int machno, uvlong arg0, uvlong arg1, uvlong arg2, uvlong arg3)
dtptrigger(DTProbe *p, int machno, DTTrigInfo *info)
{
DTEnab *e;
ExecInfo info;
info.ts = dttime();
info->ts = dttime();
dtmachlock(machno);
info.machno = machno;
info.arg[0] = arg0;
info.arg[1] = arg1;
info.arg[2] = arg2;
info.arg[3] = arg3;
info->machno = machno;
for(e = p->enablist.probnext; e != &p->enablist; e = e->probnext)
if(e->gr->chan->state == DTCGO){
info.ch = e->gr->chan;
info.epid = e->epid;
if(dtgexec(e->gr, &info) < 0)
info->ch = e->gr->chan;
info->epid = e->epid;
if(dtgexec(e->gr, info) < 0)
e->gr->chan->state = DTCFAULT;
}
dtmachunlock(machno);