add dtracy support to mkdevc and enable dtracy with plan9.ini

This commit is contained in:
aiju 2018-12-11 07:44:34 +00:00
parent e93a85710e
commit 6f30420136
8 changed files with 85 additions and 59 deletions

View file

@ -67,6 +67,7 @@ LIB=\
/$objtype/lib/libmp.a\ /$objtype/lib/libmp.a\
/$objtype/lib/libfis.a\ /$objtype/lib/libfis.a\
/$objtype/lib/libaml.a\ /$objtype/lib/libaml.a\
/$objtype/lib/libdtracy.a\
ETHER=`{echo devether.c ether*.c | sed 's/\.c/.'$O'/g'} ETHER=`{echo devether.c ether*.c | sed 's/\.c/.'$O'/g'}
AUDIO=`{echo devaudio.c audio*.c | sed 's/\.c/.'$O'/g'} AUDIO=`{echo devaudio.c audio*.c | sed 's/\.c/.'$O'/g'}

View file

@ -18,6 +18,7 @@ dev
cap cap
kprof kprof
fs fs
dtracy
ether netif ether netif
bridge netif log bridge netif log
@ -137,6 +138,9 @@ misc
vgatvp3026 =cur vgatvp3026 =cur
vgavesa vgavesa
vgavmware +cur vgavmware +cur
dtracysys
dtracytimer
ip ip
tcp tcp

View file

@ -65,6 +65,7 @@ LIB=\
/$objtype/lib/libc.a\ /$objtype/lib/libc.a\
/$objtype/lib/libfis.a\ /$objtype/lib/libfis.a\
/$objtype/lib/libaml.a\ /$objtype/lib/libaml.a\
/$objtype/lib/libdtracy.a\
ETHER=`{cd ../pc; echo devether.c ether*.c | sed 's/\.c/.'$O'/g'} 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'} AUDIO=`{cd ../pc; echo devaudio.c audio*.c | sed 's/\.c/.'$O'/g'}

View file

@ -41,6 +41,7 @@ dev
segment segment
vmx vmx
dtracy
link link
# devpccard # devpccard
@ -136,6 +137,9 @@ misc
vgavesa vgavesa
# vgavmware +cur # vgavmware +cur
dtracysys
dtracytimer
ip ip
tcp tcp
udp udp

View file

@ -125,9 +125,13 @@ dtkfree(DTKChan *p)
dtktab[idx] = nil; dtktab[idx] = nil;
} }
static int dtracyen;
static void static void
dtracyinit(void) dtracyinit(void)
{ {
dtracyen = getconf("*dtracy") != nil;
if(!dtracyen) return;
machlocks = smalloc(sizeof(Lock) * conf.nmach); machlocks = smalloc(sizeof(Lock) * conf.nmach);
dtinit(conf.nmach); dtinit(conf.nmach);
} }
@ -135,6 +139,8 @@ dtracyinit(void)
static Chan* static Chan*
dtracyattach(char *spec) dtracyattach(char *spec)
{ {
if(!dtracyen)
error("*dtracy= not set");
return devattach(L'Δ', spec); return devattach(L'Δ', spec);
} }
@ -519,60 +525,3 @@ dtpeek(uvlong addr, void *buf, int len)
memmove(buf, (void *) addr, len); memmove(buf, (void *) addr, len);
return 0; 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,
};

View file

@ -260,7 +260,7 @@ sysdisable(DTProbe *p)
z = systab[i], systab[i] = wraptab[i], wraptab[i] = z; z = systab[i], systab[i] = wraptab[i], wraptab[i] = z;
} }
DTProvider dtracyprov_sys = { DTProvider dtracysysprov = {
.name = "sys", .name = "sys",
.provide = sysprovide, .provide = sysprovide,
.enable = sysenable, .enable = sysenable,

View file

@ -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 <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,
};

View file

@ -58,7 +58,8 @@ collect && section == "misc"{
if($i ~ "[+=]cur") if($i ~ "[+=]cur")
vgacur[nvgacur++] = $1; vgacur[nvgacur++] = $1;
} }
} }else if($1 ~ "^dtracy.*")
dtracyprov[ndtracyprov++] = $1;
} }
collect && section == "port"{ collect && section == "port"{
@ -190,6 +191,16 @@ END{
printf "%s\n", port[i]; printf "%s\n", port[i];
printf "\n"; 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]; printf "char* conffile = \"%s/%s\";\n", pwd, ARGV[1];
printf "ulong kerndate = KERNDATE;\n"; printf "ulong kerndate = KERNDATE;\n";