blob: 44e63bd52a565b19d2bcca8696031c46799b55b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "../port/error.h"
#include "ureg.h"
#include <dtracy.h>
static DTProbe *timerprobe;
static int running;
void
dtracytick(Ureg *ur)
{
DTTrigInfo info;
if(!running)
return;
memset(&info, 0, sizeof(info));
info.arg[0] = ur->pc;
info.arg[1] = userureg(ur);
dtptrigger(timerprobe, &info);
}
static void
timerprovide(DTProvider *prov)
{
if(timerprobe == nil)
timerprobe = dtpnew("timer::1tk", prov, nil);
}
static int
timerenable(DTProbe *)
{
running = 1;
return 0;
}
static void
timerdisable(DTProbe *)
{
running = 0;
}
DTProvider dtracytimerprov = {
.name = "timer",
.provide = timerprovide,
.enable = timerenable,
.disable = timerdisable,
};
|