aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parse-events.c453
-rw-r--r--parse-events.h196
-rw-r--r--plugin_hrtimer.c9
-rw-r--r--plugin_mac80211.c6
-rw-r--r--trace-cmd.h9
-rw-r--r--trace-ftrace.c24
-rw-r--r--trace-input.c127
-rw-r--r--trace-read.c22
-rw-r--r--trace-util.c19
9 files changed, 543 insertions, 322 deletions
diff --git a/parse-events.c b/parse-events.c
index 8a59433..fe683c9 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -30,27 +30,10 @@
30 30
31#include "parse-events.h" 31#include "parse-events.h"
32 32
33int header_page_ts_offset;
34int header_page_ts_size;
35int header_page_size_offset;
36int header_page_size_size;
37int header_page_data_offset;
38int header_page_data_size;
39
40int file_bigendian;
41int host_bigendian;
42
43int latency_format;
44
45int old_format;
46
47static char *input_buf; 33static char *input_buf;
48static unsigned long long input_buf_ptr; 34static unsigned long long input_buf_ptr;
49static unsigned long long input_buf_siz; 35static unsigned long long input_buf_siz;
50 36
51static int cpus;
52static int long_size;
53
54static void init_input_buf(char *buf, unsigned long long size) 37static void init_input_buf(char *buf, unsigned long long size)
55{ 38{
56 input_buf = buf; 39 input_buf = buf;
@@ -69,9 +52,6 @@ struct cmdline {
69 int pid; 52 int pid;
70}; 53};
71 54
72static struct cmdline *cmdlines;
73static int cmdline_count;
74
75static int cmdline_cmp(const void *a, const void *b) 55static int cmdline_cmp(const void *a, const void *b)
76{ 56{
77 const struct cmdline *ca = a; 57 const struct cmdline *ca = a;
@@ -85,18 +65,20 @@ static int cmdline_cmp(const void *a, const void *b)
85 return 0; 65 return 0;
86} 66}
87 67
88static struct cmdline_list { 68struct cmdline_list {
89 struct cmdline_list *next; 69 struct cmdline_list *next;
90 char *comm; 70 char *comm;
91 int pid; 71 int pid;
92} *cmdlist; 72};
93 73
94static int cmdline_init(void) 74static int cmdline_init(struct pevent *pevent)
95{ 75{
76 struct cmdline_list *cmdlist = pevent->cmdlist;
96 struct cmdline_list *item; 77 struct cmdline_list *item;
78 struct cmdline *cmdlines;
97 int i; 79 int i;
98 80
99 cmdlines = malloc_or_die(sizeof(*cmdlines) * cmdline_count); 81 cmdlines = malloc_or_die(sizeof(*cmdlines) * pevent->cmdline_count);
100 82
101 i = 0; 83 i = 0;
102 while (cmdlist) { 84 while (cmdlist) {
@@ -108,12 +90,15 @@ static int cmdline_init(void)
108 free(item); 90 free(item);
109 } 91 }
110 92
111 qsort(cmdlines, cmdline_count, sizeof(*cmdlines), cmdline_cmp); 93 qsort(cmdlines, pevent->cmdline_count, sizeof(*cmdlines), cmdline_cmp);
94
95 pevent->cmdlines = cmdlines;
96 pevent->cmdlist = NULL;
112 97
113 return 0; 98 return 0;
114} 99}
115 100
116static char *find_cmdline(int pid) 101static char *find_cmdline(struct pevent *pevent, int pid)
117{ 102{
118 const struct cmdline *comm; 103 const struct cmdline *comm;
119 struct cmdline key; 104 struct cmdline key;
@@ -121,47 +106,46 @@ static char *find_cmdline(int pid)
121 if (!pid) 106 if (!pid)
122 return "<idle>"; 107 return "<idle>";
123 108
124 if (!cmdlines) 109 if (!pevent->cmdlines)
125 cmdline_init(); 110 cmdline_init(pevent);
126 111
127 key.pid = pid; 112 key.pid = pid;
128 113
129 comm = bsearch(&key, cmdlines, cmdline_count, sizeof(*cmdlines), 114 comm = bsearch(&key, pevent->cmdlines, pevent->cmdline_count,
130 cmdline_cmp); 115 sizeof(*pevent->cmdlines), cmdline_cmp);
131 116
132 if (comm) 117 if (comm)
133 return comm->comm; 118 return comm->comm;
134 return "<...>"; 119 return "<...>";
135} 120}
136 121
137int pevent_register_comm(char *comm, int pid) 122int pevent_register_comm(struct pevent *pevent, char *comm, int pid)
138{ 123{
139 struct cmdline_list *item; 124 struct cmdline_list *item;
140 125
141 item = malloc_or_die(sizeof(*item)); 126 item = malloc_or_die(sizeof(*item));
142 item->comm = comm; 127 item->comm = comm;
143 item->pid = pid; 128 item->pid = pid;
144 item->next = cmdlist; 129 item->next = pevent->cmdlist;
145 130
146 cmdlist = item; 131 pevent->cmdlist = item;
147 cmdline_count++; 132 pevent->cmdline_count++;
148 133
149 return 0; 134 return 0;
150} 135}
151 136
152static struct func_map { 137struct func_map {
153 unsigned long long addr; 138 unsigned long long addr;
154 char *func; 139 char *func;
155 char *mod; 140 char *mod;
156} *func_map; 141};
157static unsigned int func_count;
158 142
159static struct func_list { 143struct func_list {
160 struct func_list *next; 144 struct func_list *next;
161 unsigned long long addr; 145 unsigned long long addr;
162 char *func; 146 char *func;
163 char *mod; 147 char *mod;
164} *funclist; 148};
165 149
166static int func_cmp(const void *a, const void *b) 150static int func_cmp(const void *a, const void *b)
167{ 151{
@@ -197,12 +181,15 @@ static int func_bcmp(const void *a, const void *b)
197 return 1; 181 return 1;
198} 182}
199 183
200static int func_map_init(void) 184static int func_map_init(struct pevent *pevent)
201{ 185{
186 struct func_list *funclist;
202 struct func_list *item; 187 struct func_list *item;
188 struct func_map *func_map;
203 int i; 189 int i;
204 190
205 func_map = malloc_or_die(sizeof(*func_map) * func_count + 1); 191 func_map = malloc_or_die(sizeof(*func_map) * pevent->func_count + 1);
192 funclist = pevent->funclist;
206 193
207 i = 0; 194 i = 0;
208 while (funclist) { 195 while (funclist) {
@@ -215,90 +202,96 @@ static int func_map_init(void)
215 free(item); 202 free(item);
216 } 203 }
217 204
218 qsort(func_map, func_count, sizeof(*func_map), func_cmp); 205 qsort(func_map, pevent->func_count, sizeof(*func_map), func_cmp);
219 206
220 /* 207 /*
221 * Add a special record at the end. 208 * Add a special record at the end.
222 */ 209 */
223 func_map[func_count].func = NULL; 210 func_map[pevent->func_count].func = NULL;
224 func_map[func_count].addr = 0; 211 func_map[pevent->func_count].addr = 0;
225 func_map[func_count].mod = NULL; 212 func_map[pevent->func_count].mod = NULL;
213
214 pevent->func_map = func_map;
215 pevent->funclist = NULL;
226 216
227 return 0; 217 return 0;
228} 218}
229 219
230static struct func_map *find_func(unsigned long long addr) 220static struct func_map *
221find_func(struct pevent *pevent, unsigned long long addr)
231{ 222{
232 struct func_map *func; 223 struct func_map *func;
233 struct func_map key; 224 struct func_map key;
234 225
235 if (!func_map) 226 if (!pevent->func_map)
236 func_map_init(); 227 func_map_init(pevent);
237 228