ref: ca851bbb5e93d6f208d967edd898e7042833889b
parent: b96be173766c58ccfcc3abc84bd751ba000be838
author: aiju <devnull@localhost>
date: Sun Dec 9 16:43:22 EST 2018
dtracy: call dtptrigger with a struct pointer rather than a list of arguments; put return value in arg9
--- a/sys/include/dtracy.h
+++ b/sys/include/dtracy.h
@@ -30,6 +30,7 @@
typedef struct DTProvider DTProvider;
typedef struct DTAgg DTAgg;
typedef struct DTBuf DTBuf;
+typedef struct DTTrigInfo DTTrigInfo;
struct DTName {
char *provider;
@@ -223,6 +224,18 @@
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);
@@ -229,7 +242,7 @@
/* 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 *);
--- a/sys/src/9/port/devdtracy.c
+++ b/sys/src/9/port/devdtracy.c
@@ -525,9 +525,12 @@
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);
}
}
--- a/sys/src/9/port/dtracysys.c
+++ b/sys/src/9/port/dtracysys.c
@@ -18,9 +18,12 @@
#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)\
@@ -27,10 +30,13 @@
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)\
@@ -37,11 +43,14 @@
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)\
@@ -48,12 +57,15 @@
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)\
@@ -60,13 +72,16 @@
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 @@
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;\
}
--- a/sys/src/libdtracy/prog.c
+++ b/sys/src/libdtracy/prog.c
@@ -122,17 +122,8 @@
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 @@
#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 @@
}
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);