Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 1 | #include "../perf.h" |
| 2 | #include <stdlib.h> |
| 3 | #include <stdio.h> |
| 4 | #include <string.h> |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 5 | #include "session.h" |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 6 | #include "thread.h" |
| 7 | #include "util.h" |
Frederic Weisbecker | 6e08643 | 2009-08-18 17:04:03 +0200 | [diff] [blame] | 8 | #include "debug.h" |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 9 | |
Zhang, Yanmin | d6d901c | 2010-03-18 11:36:05 -0300 | [diff] [blame^] | 10 | int find_all_tid(int pid, pid_t ** all_tid) |
| 11 | { |
| 12 | char name[256]; |
| 13 | int items; |
| 14 | struct dirent **namelist = NULL; |
| 15 | int ret = 0; |
| 16 | int i; |
| 17 | |
| 18 | sprintf(name, "/proc/%d/task", pid); |
| 19 | items = scandir(name, &namelist, NULL, NULL); |
| 20 | if (items <= 0) |
| 21 | return -ENOENT; |
| 22 | *all_tid = malloc(sizeof(pid_t) * items); |
| 23 | if (!*all_tid) { |
| 24 | ret = -ENOMEM; |
| 25 | goto failure; |
| 26 | } |
| 27 | |
| 28 | for (i = 0; i < items; i++) |
| 29 | (*all_tid)[i] = atoi(namelist[i]->d_name); |
| 30 | |
| 31 | ret = items; |
| 32 | |
| 33 | failure: |
| 34 | for (i=0; i<items; i++) |
| 35 | free(namelist[i]); |
| 36 | free(namelist); |
| 37 | |
| 38 | return ret; |
| 39 | } |
| 40 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 41 | void map_groups__init(struct map_groups *self) |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 42 | { |
| 43 | int i; |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 44 | for (i = 0; i < MAP__NR_TYPES; ++i) { |
| 45 | self->maps[i] = RB_ROOT; |
| 46 | INIT_LIST_HEAD(&self->removed_maps[i]); |
| 47 | } |
| 48 | } |
| 49 | |
Frederic Weisbecker | 97ea1a7 | 2009-10-08 21:04:17 +0200 | [diff] [blame] | 50 | static struct thread *thread__new(pid_t pid) |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 51 | { |
Arnaldo Carvalho de Melo | 3647948 | 2009-11-24 12:05:16 -0200 | [diff] [blame] | 52 | struct thread *self = zalloc(sizeof(*self)); |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 53 | |
| 54 | if (self != NULL) { |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 55 | map_groups__init(&self->mg); |
| 56 | self->pid = pid; |
Frederic Weisbecker | 97ea1a7 | 2009-10-08 21:04:17 +0200 | [diff] [blame] | 57 | self->comm = malloc(32); |
| 58 | if (self->comm) |
| 59 | snprintf(self->comm, 32, ":%d", self->pid); |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | return self; |
| 63 | } |
| 64 | |
David S. Miller | 4385d58 | 2010-02-26 12:08:34 -0300 | [diff] [blame] | 65 | static void map_groups__flush(struct map_groups *self) |
| 66 | { |
| 67 | int type; |
| 68 | |
| 69 | for (type = 0; type < MAP__NR_TYPES; type++) { |
| 70 | struct rb_root *root = &self->maps[type]; |
| 71 | struct rb_node *next = rb_first(root); |
| 72 | |
| 73 | while (next) { |
| 74 | struct map *pos = rb_entry(next, struct map, rb_node); |
| 75 | next = rb_next(&pos->rb_node); |
| 76 | rb_erase(&pos->rb_node, root); |
| 77 | /* |
| 78 | * We may have references to this map, for |
| 79 | * instance in some hist_entry instances, so |
| 80 | * just move them to a separate list. |
| 81 | */ |
| 82 | list_add_tail(&pos->node, &self->removed_maps[pos->type]); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 87 | int thread__set_comm(struct thread *self, const char *comm) |
| 88 | { |
David S. Miller | 4385d58 | 2010-02-26 12:08:34 -0300 | [diff] [blame] | 89 | int err; |
| 90 | |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 91 | if (self->comm) |
| 92 | free(self->comm); |
| 93 | self->comm = strdup(comm); |
David S. Miller | 4385d58 | 2010-02-26 12:08:34 -0300 | [diff] [blame] | 94 | err = self->comm == NULL ? -ENOMEM : 0; |
| 95 | if (!err) { |
| 96 | self->comm_set = true; |
| 97 | map_groups__flush(&self->mg); |
| 98 | } |
| 99 | return err; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 100 | } |
| 101 | |
Frederic Weisbecker | a4fb581 | 2009-10-22 23:23:23 +0200 | [diff] [blame] | 102 | int thread__comm_len(struct thread *self) |
| 103 | { |
| 104 | if (!self->comm_len) { |
| 105 | if (!self->comm) |
| 106 | return 0; |
| 107 | self->comm_len = strlen(self->comm); |
| 108 | } |
| 109 | |
| 110 | return self->comm_len; |
| 111 | } |
| 112 | |
Arnaldo Carvalho de Melo | 65f2ed2 | 2010-03-09 15:58:17 -0300 | [diff] [blame] | 113 | size_t __map_groups__fprintf_maps(struct map_groups *self, |
| 114 | enum map_type type, FILE *fp) |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 115 | { |
| 116 | size_t printed = fprintf(fp, "%s:\n", map_type__name[type]); |
| 117 | struct rb_node *nd; |
| 118 | |
| 119 | for (nd = rb_first(&self->maps[type]); nd; nd = rb_next(nd)) { |
| 120 | struct map *pos = rb_entry(nd, struct map, rb_node); |
| 121 | printed += fprintf(fp, "Map:"); |
| 122 | printed += map__fprintf(pos, fp); |
Arnaldo Carvalho de Melo | 65f2ed2 | 2010-03-09 15:58:17 -0300 | [diff] [blame] | 123 | if (verbose > 2) { |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 124 | printed += dso__fprintf(pos->dso, type, fp); |
| 125 | printed += fprintf(fp, "--\n"); |
| 126 | } |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 127 | } |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 128 | |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 129 | return printed; |
| 130 | } |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 131 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 132 | size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp) |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 133 | { |
| 134 | size_t printed = 0, i; |
| 135 | for (i = 0; i < MAP__NR_TYPES; ++i) |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 136 | printed += __map_groups__fprintf_maps(self, i, fp); |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 137 | return printed; |
| 138 | } |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 139 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 140 | static size_t __map_groups__fprintf_removed_maps(struct map_groups *self, |
| 141 | enum map_type type, FILE *fp) |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 142 | { |
| 143 | struct map *pos; |
| 144 | size_t printed = 0; |
| 145 | |
| 146 | list_for_each_entry(pos, &self->removed_maps[type], node) { |
| 147 | printed += fprintf(fp, "Map:"); |
| 148 | printed += map__fprintf(pos, fp); |
| 149 | if (verbose > 1) { |
| 150 | printed += dso__fprintf(pos->dso, type, fp); |
| 151 | printed += fprintf(fp, "--\n"); |
| 152 | } |
| 153 | } |
| 154 | return printed; |
| 155 | } |
| 156 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 157 | static size_t map_groups__fprintf_removed_maps(struct map_groups *self, FILE *fp) |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 158 | { |
| 159 | size_t printed = 0, i; |
| 160 | for (i = 0; i < MAP__NR_TYPES; ++i) |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 161 | printed += __map_groups__fprintf_removed_maps(self, i, fp); |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 162 | return printed; |
| 163 | } |
| 164 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 165 | static size_t map_groups__fprintf(struct map_groups *self, FILE *fp) |
| 166 | { |
| 167 | size_t printed = map_groups__fprintf_maps(self, fp); |
| 168 | printed += fprintf(fp, "Removed maps:\n"); |
| 169 | return printed + map_groups__fprintf_removed_maps(self, fp); |
| 170 | } |
| 171 | |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 172 | static size_t thread__fprintf(struct thread *self, FILE *fp) |
| 173 | { |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 174 | return fprintf(fp, "Thread %d %s\n", self->pid, self->comm) + |
| 175 | map_groups__fprintf(&self->mg, fp); |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 176 | } |
| 177 | |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 178 | struct thread *perf_session__findnew(struct perf_session *self, pid_t pid) |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 179 | { |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 180 | struct rb_node **p = &self->threads.rb_node; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 181 | struct rb_node *parent = NULL; |
| 182 | struct thread *th; |
| 183 | |
| 184 | /* |
| 185 | * Font-end cache - PID lookups come in blocks, |
| 186 | * so most of the time we dont have to look up |
| 187 | * the full rbtree: |
| 188 | */ |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 189 | if (self->last_match && self->last_match->pid == pid) |
| 190 | return self->last_match; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 191 | |
| 192 | while (*p != NULL) { |
| 193 | parent = *p; |
| 194 | th = rb_entry(parent, struct thread, rb_node); |
| 195 | |
| 196 | if (th->pid == pid) { |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 197 | self->last_match = th; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 198 | return th; |
| 199 | } |
| 200 | |
| 201 | if (pid < th->pid) |
| 202 | p = &(*p)->rb_left; |
| 203 | else |
| 204 | p = &(*p)->rb_right; |
| 205 | } |
| 206 | |
Frederic Weisbecker | 97ea1a7 | 2009-10-08 21:04:17 +0200 | [diff] [blame] | 207 | th = thread__new(pid); |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 208 | if (th != NULL) { |
| 209 | rb_link_node(&th->rb_node, parent, p); |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 210 | rb_insert_color(&th->rb_node, &self->threads); |
| 211 | self->last_match = th; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | return th; |
| 215 | } |
| 216 | |
Arnaldo Carvalho de Melo | 1224550 | 2010-03-05 11:54:02 -0300 | [diff] [blame] | 217 | static int map_groups__fixup_overlappings(struct map_groups *self, |
| 218 | struct map *map) |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 219 | { |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 220 | struct rb_root *root = &self->maps[map->type]; |
| 221 | struct rb_node *next = rb_first(root); |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 222 | |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 223 | while (next) { |
| 224 | struct map *pos = rb_entry(next, struct map, rb_node); |
| 225 | next = rb_next(&pos->rb_node); |
Frederic Weisbecker | 6e08643 | 2009-08-18 17:04:03 +0200 | [diff] [blame] | 226 | |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 227 | if (!map__overlap(pos, map)) |
| 228 | continue; |
Frederic Weisbecker | 6e08643 | 2009-08-18 17:04:03 +0200 | [diff] [blame] | 229 | |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 230 | if (verbose >= 2) { |
Arnaldo Carvalho de Melo | 6beba7a | 2009-10-21 17:34:06 -0200 | [diff] [blame] | 231 | fputs("overlapping maps:\n", stderr); |
| 232 | map__fprintf(map, stderr); |
| 233 | map__fprintf(pos, stderr); |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 234 | } |
Frederic Weisbecker | 6e08643 | 2009-08-18 17:04:03 +0200 | [diff] [blame] | 235 | |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 236 | rb_erase(&pos->rb_node, root); |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 237 | /* |
| 238 | * We may have references to this map, for instance in some |
| 239 | * hist_entry instances, so just move them to a separate |
| 240 | * list. |
| 241 | */ |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 242 | list_add_tail(&pos->node, &self->removed_maps[map->type]); |
Arnaldo Carvalho de Melo | 1224550 | 2010-03-05 11:54:02 -0300 | [diff] [blame] | 243 | /* |
| 244 | * Now check if we need to create new maps for areas not |
| 245 | * overlapped by the new map: |
| 246 | */ |
| 247 | if (map->start > pos->start) { |
| 248 | struct map *before = map__clone(pos); |
| 249 | |
| 250 | if (before == NULL) |
| 251 | return -ENOMEM; |
| 252 | |
| 253 | before->end = map->start - 1; |
| 254 | map_groups__insert(self, before); |
| 255 | if (verbose >= 2) |
| 256 | map__fprintf(before, stderr); |
| 257 | } |
| 258 | |
| 259 | if (map->end < pos->end) { |
| 260 | struct map *after = map__clone(pos); |
| 261 | |
| 262 | if (after == NULL) |
| 263 | return -ENOMEM; |
| 264 | |
| 265 | after->start = map->end + 1; |
| 266 | map_groups__insert(self, after); |
| 267 | if (verbose >= 2) |
| 268 | map__fprintf(after, stderr); |
| 269 | } |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 270 | } |
Arnaldo Carvalho de Melo | 1224550 | 2010-03-05 11:54:02 -0300 | [diff] [blame] | 271 | |
| 272 | return 0; |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 273 | } |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 274 | |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 275 | void maps__insert(struct rb_root *maps, struct map *map) |
| 276 | { |
| 277 | struct rb_node **p = &maps->rb_node; |
| 278 | struct rb_node *parent = NULL; |
| 279 | const u64 ip = map->start; |
| 280 | struct map *m; |
| 281 | |
| 282 | while (*p != NULL) { |
| 283 | parent = *p; |
| 284 | m = rb_entry(parent, struct map, rb_node); |
| 285 | if (ip < m->start) |
| 286 | p = &(*p)->rb_left; |
| 287 | else |
| 288 | p = &(*p)->rb_right; |
| 289 | } |
| 290 | |
| 291 | rb_link_node(&map->rb_node, parent, p); |
| 292 | rb_insert_color(&map->rb_node, maps); |
| 293 | } |
| 294 | |
| 295 | struct map *maps__find(struct rb_root *maps, u64 ip) |
| 296 | { |
| 297 | struct rb_node **p = &maps->rb_node; |
| 298 | struct rb_node *parent = NULL; |
| 299 | struct map *m; |
| 300 | |
| 301 | while (*p != NULL) { |
| 302 | parent = *p; |
| 303 | m = rb_entry(parent, struct map, rb_node); |
| 304 | if (ip < m->start) |
| 305 | p = &(*p)->rb_left; |
| 306 | else if (ip > m->end) |
| 307 | p = &(*p)->rb_right; |
| 308 | else |
| 309 | return m; |
| 310 | } |
| 311 | |
| 312 | return NULL; |
| 313 | } |
| 314 | |
| 315 | void thread__insert_map(struct thread *self, struct map *map) |
| 316 | { |
Arnaldo Carvalho de Melo | 1224550 | 2010-03-05 11:54:02 -0300 | [diff] [blame] | 317 | map_groups__fixup_overlappings(&self->mg, map); |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 318 | map_groups__insert(&self->mg, map); |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 319 | } |
| 320 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 321 | /* |
| 322 | * XXX This should not really _copy_ te maps, but refcount them. |
| 323 | */ |
| 324 | static int map_groups__clone(struct map_groups *self, |
| 325 | struct map_groups *parent, enum map_type type) |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 326 | { |
| 327 | struct rb_node *nd; |
| 328 | for (nd = rb_first(&parent->maps[type]); nd; nd = rb_next(nd)) { |
| 329 | struct map *map = rb_entry(nd, struct map, rb_node); |
| 330 | struct map *new = map__clone(map); |
| 331 | if (new == NULL) |
| 332 | return -ENOMEM; |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 333 | map_groups__insert(self, new); |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 334 | } |
| 335 | return 0; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | int thread__fork(struct thread *self, struct thread *parent) |
| 339 | { |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 340 | int i; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 341 | |
Arnaldo Carvalho de Melo | faa5c5c | 2010-02-19 23:02:07 -0200 | [diff] [blame] | 342 | if (parent->comm_set) { |
| 343 | if (self->comm) |
| 344 | free(self->comm); |
| 345 | self->comm = strdup(parent->comm); |
| 346 | if (!self->comm) |
| 347 | return -ENOMEM; |
| 348 | self->comm_set = true; |
| 349 | } |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 350 | |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 351 | for (i = 0; i < MAP__NR_TYPES; ++i) |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 352 | if (map_groups__clone(&self->mg, &parent->mg, i) < 0) |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 353 | return -ENOMEM; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 354 | return 0; |
| 355 | } |
| 356 | |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 357 | size_t perf_session__fprintf(struct perf_session *self, FILE *fp) |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 358 | { |
| 359 | size_t ret = 0; |
| 360 | struct rb_node *nd; |
| 361 | |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 362 | for (nd = rb_first(&self->threads); nd; nd = rb_next(nd)) { |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 363 | struct thread *pos = rb_entry(nd, struct thread, rb_node); |
| 364 | |
| 365 | ret += thread__fprintf(pos, fp); |
| 366 | } |
| 367 | |
| 368 | return ret; |
| 369 | } |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 370 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 371 | struct symbol *map_groups__find_symbol(struct map_groups *self, |
| 372 | enum map_type type, u64 addr, |
| 373 | symbol_filter_t filter) |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 374 | { |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 375 | struct map *map = map_groups__find(self, type, addr); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 376 | |
| 377 | if (map != NULL) |
Arnaldo Carvalho de Melo | 9de89fe | 2010-02-03 16:52:00 -0200 | [diff] [blame] | 378 | return map__find_symbol(map, map->map_ip(map, addr), filter); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 379 | |
| 380 | return NULL; |
| 381 | } |
Zhang, Yanmin | d6d901c | 2010-03-18 11:36:05 -0300 | [diff] [blame^] | 382 | |