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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#ifndef LOAD_H
#define LOAD_H
#include "sched_trace.h"
int map_trace(const char *name, void **start, void **end, size_t *size);
struct heap* load(char **files, int no_files, unsigned int *count);
struct evlink {
struct evlink *next;
struct st_event_record* rec;
};
struct task {
int pid;
unsigned int no_events;
struct st_event_record* name;
struct st_event_record* param;
struct evlink* events;
struct evlink** next;
};
#define MAX_TASKS 512
extern struct task tasks[MAX_TASKS];
extern struct evlink* sys_events;
extern u64 time0;
extern u32 g_min_task;
extern u32 g_max_task;
static inline double ns2ms(u64 ns)
{
return ns / 1000000.0;
}
static inline double ns2ms_adj(u64 ns)
{
return ns2ms(ns - time0);
}
static inline double evtime(struct st_event_record* rec)
{
return ns2ms_adj(event_time(rec));
}
void crop_events(struct task* t, double min, double max);
void crop_events_all(double min, double max);
struct task* by_pid(int pid);
void init_tasks(void);
void split(struct heap* h, unsigned int count, int find_time0);
const char* tsk_name(struct task* t);
int tsk_cpu(struct task *t);
u32 per(struct task* t);
u32 exe(struct task* t);
u32 idx(struct task* t);
u32 count_tasks(void);
#define CHECK(_e, test) if (test) fprintf(stderr, "'%s' failed.\n", #test);
#define for_each_task(t) \
for (t = tasks + g_min_task; t < tasks + g_max_task && t->pid; t++)
#define for_each_event(t, e) \
for (e = t->events; e; e = e->next)
#define for_each_event_t(t, e, evtype) \
for_each_event(t, e) if (e->rec->hdr.type == evtype)
#define find_evtype(e, evtype) \
while (e && e->rec->hdr.type != evtype) e = e->next;
#define find(e, evtype) \
while (e && e->rec->hdr.type != evtype) e = e->next; if (!e) break;
static inline struct st_event_record *find_sys_event(u8 type)
{
struct evlink* pos = sys_events;
find_evtype(pos, type);
if (pos)
return pos->rec;
else
return NULL;
}
#endif
|