diff --git a/sys/src/9/pc/mkfile b/sys/src/9/pc/mkfile index ee05c3a29..6b43feddc 100644 --- a/sys/src/9/pc/mkfile +++ b/sys/src/9/pc/mkfile @@ -67,6 +67,7 @@ LIB=\ /$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'} diff --git a/sys/src/9/pc/pc b/sys/src/9/pc/pc index ffdb41a4a..86c5c8b1e 100644 --- a/sys/src/9/pc/pc +++ b/sys/src/9/pc/pc @@ -18,6 +18,7 @@ dev cap kprof fs + dtracy ether netif bridge netif log @@ -137,6 +138,9 @@ misc vgatvp3026 =cur vgavesa vgavmware +cur + + dtracysys + dtracytimer ip tcp diff --git a/sys/src/9/pc64/mkfile b/sys/src/9/pc64/mkfile index 51204dcee..fc0b5af09 100644 --- a/sys/src/9/pc64/mkfile +++ b/sys/src/9/pc64/mkfile @@ -65,6 +65,7 @@ LIB=\ /$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'} diff --git a/sys/src/9/pc64/pc64 b/sys/src/9/pc64/pc64 index ca464f96b..e3ce365d9 100644 --- a/sys/src/9/pc64/pc64 +++ b/sys/src/9/pc64/pc64 @@ -41,6 +41,7 @@ dev segment vmx + dtracy link # devpccard @@ -136,6 +137,9 @@ misc vgavesa # vgavmware +cur + dtracysys + dtracytimer + ip tcp udp diff --git a/sys/src/9/port/devdtracy.c b/sys/src/9/port/devdtracy.c index 82d2d0a27..53da2c46b 100644 --- a/sys/src/9/port/devdtracy.c +++ b/sys/src/9/port/devdtracy.c @@ -125,9 +125,13 @@ dtkfree(DTKChan *p) 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 @@ dtracyinit(void) static Chan* dtracyattach(char *spec) { + if(!dtracyen) + error("*dtracy= not set"); return devattach(L'Δ', spec); } @@ -519,60 +525,3 @@ dtpeek(uvlong addr, void *buf, int len) 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, -}; - diff --git a/sys/src/9/port/dtracysys.c b/sys/src/9/port/dtracysys.c index c9e0f4e5a..859dd9f84 100644 --- a/sys/src/9/port/dtracysys.c +++ b/sys/src/9/port/dtracysys.c @@ -260,7 +260,7 @@ sysdisable(DTProbe *p) z = systab[i], systab[i] = wraptab[i], wraptab[i] = z; } -DTProvider dtracyprov_sys = { +DTProvider dtracysysprov = { .name = "sys", .provide = sysprovide, .enable = sysenable, diff --git a/sys/src/9/port/dtracytimer.c b/sys/src/9/port/dtracytimer.c new file mode 100644 index 000000000..cb3b636f6 --- /dev/null +++ b/sys/src/9/port/dtracytimer.c @@ -0,0 +1,56 @@ +#include "u.h" +#include "../port/lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "../port/error.h" + +#include + +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, +}; diff --git a/sys/src/9/port/mkdevc b/sys/src/9/port/mkdevc index 283c69a27..8e87636d8 100755 --- a/sys/src/9/port/mkdevc +++ b/sys/src/9/port/mkdevc @@ -58,7 +58,8 @@ collect && section == "misc"{ if($i ~ "[+=]cur") vgacur[nvgacur++] = $1; } - } + }else if($1 ~ "^dtracy.*") + dtracyprov[ndtracyprov++] = $1; } collect && section == "port"{ @@ -190,6 +191,16 @@ END{ printf "%s\n", port[i]; printf "\n"; } + + if(ndtracyprov){ + printf "#include \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]; printf "ulong kerndate = KERNDATE;\n";