-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathround_trip-micro-glibc.bt
55 lines (49 loc) · 1.1 KB
/
round_trip-micro-glibc.bt
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
53
54
55
#!/usr/bin/env bpftrace
BEGIN
{
printf("Hit Ctrl-C to end.\n");
//@first = 1;
}
END
{
clear(@follow);
clear(@name);
}
uprobe:libc:read,
uprobe:libc:write,
uprobe:libc:open,
uprobe:libc:close
/pid == $1/
{
@follow[tid] = nsecs;
//printf("[%ld][%s]%s\n", pid, comm, func);
@name[tid] = func;
@event_count[tid, func] = count();
//if(@first){
// printf("read: %X\n", uaddr("read"));
// printf("write: %X\n", uaddr("write"));
// printf("open: %X\n", uaddr("open"));
// printf("close: %X\n", uaddr("close"));
// delete(@first);
//}
}
uretprobe:libc:read,
uretprobe:libc:write,
uretprobe:libc:open,
uretprobe:libc:close
/pid == $1 && @follow[tid]/
{
$total_us = nsecs - @follow[tid];
//@trip_us[@name[tid]] = lhist($total_us, 0, 1000, 1);
@total_ns[tid, func, @event_count[tid, @name[tid]]] = $total_us;
printf("%ld\n", @total_ns[tid, func, @event_count[tid, @name[tid]]]);
print(@total_ns);
delete(@follow[tid]);
delete(@name[tid]);
}
//interval:s:30
//{
// printf("\n");
// print(@trip_us);
// printf("\n");
//}