ref: 6f30420136d8f2a87790dbe826bc6800de74770a
parent: e93a85710edab0e55ba792955da235083c8a0150
author: aiju <devnull@localhost>
date: Tue Dec 11 02:44:34 EST 2018
add dtracy support to mkdevc and enable dtracy with plan9.ini
--- a/sys/src/9/pc/mkfile
+++ b/sys/src/9/pc/mkfile
@@ -67,6 +67,7 @@
/$objtype/lib/libmp.a\
/$objtype/lib/libfis.a\
/$objtype/lib/libaml.a\
+ /$objtype/lib/libdtracy.a\
ETHER=`{echo devether.c ether*.c | sed 's/\.c/.'$O'/g'}
AUDIO=`{echo devaudio.c audio*.c | sed 's/\.c/.'$O'/g'}
--- a/sys/src/9/pc/pc
+++ b/sys/src/9/pc/pc
@@ -18,6 +18,7 @@
cap
kprof
fs
+ dtracy
ether netif
bridge netif log
@@ -137,6 +138,9 @@
vgatvp3026 =cur
vgavesa
vgavmware +cur
+
+ dtracysys
+ dtracytimer
ip
tcp
--- a/sys/src/9/pc64/mkfile
+++ b/sys/src/9/pc64/mkfile
@@ -65,6 +65,7 @@
/$objtype/lib/libc.a\
/$objtype/lib/libfis.a\
/$objtype/lib/libaml.a\
+ /$objtype/lib/libdtracy.a\
ETHER=`{cd ../pc; echo devether.c ether*.c | sed 's/\.c/.'$O'/g'}
AUDIO=`{cd ../pc; echo devaudio.c audio*.c | sed 's/\.c/.'$O'/g'}
--- a/sys/src/9/pc64/pc64
+++ b/sys/src/9/pc64/pc64
@@ -41,6 +41,7 @@
segment
vmx
+ dtracy
link
# devpccard
@@ -135,6 +136,9 @@
# vgatvp3026 =cur
vgavesa
# vgavmware +cur
+
+ dtracysys
+ dtracytimer
ip
tcp
--- a/sys/src/9/port/devdtracy.c
+++ b/sys/src/9/port/devdtracy.c
@@ -125,9 +125,13 @@
dtktab[idx] = nil;
}
+static int dtracyen;
+
static void
dtracyinit(void)
{
+ dtracyen = getconf("*dtracy") != nil;
+ if(!dtracyen) return;
machlocks = smalloc(sizeof(Lock) * conf.nmach);
dtinit(conf.nmach);
}
@@ -135,6 +139,8 @@
static Chan*
dtracyattach(char *spec)
{
+ if(!dtracyen)
+ error("*dtracy= not set");
return devattach(L'Δ', spec);
}
@@ -519,60 +525,3 @@
memmove(buf, (void *) addr, len);
return 0;
}
-
-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, &info);
- }
-}
-
-static void
-timerprovide(DTProvider *prov, DTName)
-{
- static int provided;
-
- if(provided) return;
- provided = 1;
- timerprobe = dtpnew((DTName){"timer", "", "1s"}, prov, nil);
-}
-
-static int
-timerenable(DTProbe *)
-{
- static int gotkproc;
-
- if(!gotkproc){
- kproc("dtracytimer", dtracytimer, nil);
- gotkproc=1;
- }
- return 0;
-}
-
-static void
-timerdisable(DTProbe *)
-{
-}
-
-DTProvider dtracyprov_timer = {
- .name = "timer",
- .provide = timerprovide,
- .enable = timerenable,
- .disable = timerdisable,
-};
-
-extern DTProvider dtracyprov_sys;
-
-DTProvider *dtproviders[] = {
- &dtracyprov_timer,
- &dtracyprov_sys,
- nil,
-};
-
--- a/sys/src/9/port/dtracysys.c
+++ b/sys/src/9/port/dtracysys.c
@@ -260,7 +260,7 @@
z = systab[i], systab[i] = wraptab[i], wraptab[i] = z;
}
-DTProvider dtracyprov_sys = {
+DTProvider dtracysysprov = {
.name = "sys",
.provide = sysprovide,
.enable = sysenable,
--- /dev/null
+++ b/sys/src/9/port/dtracytimer.c
@@ -1,0 +1,56 @@
+#include "u.h"
+#include "../port/lib.h"
+#include "mem.h"
+#include "dat.h"
+#include "fns.h"
+#include "../port/error.h"
+
+#include <dtracy.h>
+
+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, &info);
+ }
+}
+
+static void
+timerprovide(DTProvider *prov, DTName)
+{
+ static int provided;
+
+ if(provided) return;
+ provided = 1;
+ timerprobe = dtpnew((DTName){"timer", "", "1s"}, prov, nil);
+}
+
+static int
+timerenable(DTProbe *)
+{
+ static int gotkproc;
+
+ if(!gotkproc){
+ kproc("dtracytimer", dtracytimer, nil);
+ gotkproc=1;
+ }
+ return 0;
+}
+
+static void
+timerdisable(DTProbe *)
+{
+}
+
+DTProvider dtracytimerprov = {
+ .name = "timer",
+ .provide = timerprovide,
+ .enable = timerenable,
+ .disable = timerdisable,
+};
--- a/sys/src/9/port/mkdevc
+++ b/sys/src/9/port/mkdevc
@@ -58,7 +58,8 @@
if($i ~ "[+=]cur")
vgacur[nvgacur++] = $1;
}
- }
+ }else if($1 ~ "^dtracy.*")
+ dtracyprov[ndtracyprov++] = $1;
}
collect && section == "port"{
@@ -189,6 +190,16 @@
for(i = 0; i < nport; i++)
printf "%s\n", port[i];
printf "\n";
+ }
+
+ if(ndtracyprov){
+ printf "#include <dtracy.h>\n";
+ for(i = 0; i < ndtracyprov; i++)
+ printf "extern DTProvider %sprov;\n", dtracyprov[i]
+ printf "DTProvider *dtproviders[] = {\n"
+ for(i = 0; i < ndtracyprov; i++)
+ printf "\t&%sprov,\n", dtracyprov[i]
+ printf "\tnil,\n};\n\n"
}
printf "char* conffile = \"%s/%s\";\n", pwd, ARGV[1];