perf tools: Cache dso data file descriptor
[cascardo/linux.git] / tools / perf / util / dso.c
1 #include <asm/bug.h>
2 #include <sys/time.h>
3 #include <sys/resource.h>
4 #include "symbol.h"
5 #include "dso.h"
6 #include "machine.h"
7 #include "util.h"
8 #include "debug.h"
9
10 char dso__symtab_origin(const struct dso *dso)
11 {
12         static const char origin[] = {
13                 [DSO_BINARY_TYPE__KALLSYMS]                     = 'k',
14                 [DSO_BINARY_TYPE__VMLINUX]                      = 'v',
15                 [DSO_BINARY_TYPE__JAVA_JIT]                     = 'j',
16                 [DSO_BINARY_TYPE__DEBUGLINK]                    = 'l',
17                 [DSO_BINARY_TYPE__BUILD_ID_CACHE]               = 'B',
18                 [DSO_BINARY_TYPE__FEDORA_DEBUGINFO]             = 'f',
19                 [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO]             = 'u',
20                 [DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO]       = 'o',
21                 [DSO_BINARY_TYPE__BUILDID_DEBUGINFO]            = 'b',
22                 [DSO_BINARY_TYPE__SYSTEM_PATH_DSO]              = 'd',
23                 [DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE]          = 'K',
24                 [DSO_BINARY_TYPE__GUEST_KALLSYMS]               = 'g',
25                 [DSO_BINARY_TYPE__GUEST_KMODULE]                = 'G',
26                 [DSO_BINARY_TYPE__GUEST_VMLINUX]                = 'V',
27         };
28
29         if (dso == NULL || dso->symtab_type == DSO_BINARY_TYPE__NOT_FOUND)
30                 return '!';
31         return origin[dso->symtab_type];
32 }
33
34 int dso__read_binary_type_filename(const struct dso *dso,
35                                    enum dso_binary_type type,
36                                    char *root_dir, char *filename, size_t size)
37 {
38         char build_id_hex[BUILD_ID_SIZE * 2 + 1];
39         int ret = 0;
40
41         switch (type) {
42         case DSO_BINARY_TYPE__DEBUGLINK: {
43                 char *debuglink;
44
45                 strncpy(filename, dso->long_name, size);
46                 debuglink = filename + dso->long_name_len;
47                 while (debuglink != filename && *debuglink != '/')
48                         debuglink--;
49                 if (*debuglink == '/')
50                         debuglink++;
51                 ret = filename__read_debuglink(dso->long_name, debuglink,
52                                                size - (debuglink - filename));
53                 }
54                 break;
55         case DSO_BINARY_TYPE__BUILD_ID_CACHE:
56                 /* skip the locally configured cache if a symfs is given */
57                 if (symbol_conf.symfs[0] ||
58                     (dso__build_id_filename(dso, filename, size) == NULL))
59                         ret = -1;
60                 break;
61
62         case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
63                 snprintf(filename, size, "%s/usr/lib/debug%s.debug",
64                          symbol_conf.symfs, dso->long_name);
65                 break;
66
67         case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
68                 snprintf(filename, size, "%s/usr/lib/debug%s",
69                          symbol_conf.symfs, dso->long_name);
70                 break;
71
72         case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
73         {
74                 const char *last_slash;
75                 size_t len;
76                 size_t dir_size;
77
78                 last_slash = dso->long_name + dso->long_name_len;
79                 while (last_slash != dso->long_name && *last_slash != '/')
80                         last_slash--;
81
82                 len = scnprintf(filename, size, "%s", symbol_conf.symfs);
83                 dir_size = last_slash - dso->long_name + 2;
84                 if (dir_size > (size - len)) {
85                         ret = -1;
86                         break;
87                 }
88                 len += scnprintf(filename + len, dir_size, "%s",  dso->long_name);
89                 len += scnprintf(filename + len , size - len, ".debug%s",
90                                                                 last_slash);
91                 break;
92         }
93
94         case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
95                 if (!dso->has_build_id) {
96                         ret = -1;
97                         break;
98                 }
99
100                 build_id__sprintf(dso->build_id,
101                                   sizeof(dso->build_id),
102                                   build_id_hex);
103                 snprintf(filename, size,
104                          "%s/usr/lib/debug/.build-id/%.2s/%s.debug",
105                          symbol_conf.symfs, build_id_hex, build_id_hex + 2);
106                 break;
107
108         case DSO_BINARY_TYPE__VMLINUX:
109         case DSO_BINARY_TYPE__GUEST_VMLINUX:
110         case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
111                 snprintf(filename, size, "%s%s",
112                          symbol_conf.symfs, dso->long_name);
113                 break;
114
115         case DSO_BINARY_TYPE__GUEST_KMODULE:
116                 snprintf(filename, size, "%s%s%s", symbol_conf.symfs,
117                          root_dir, dso->long_name);
118                 break;
119
120         case DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE:
121                 snprintf(filename, size, "%s%s", symbol_conf.symfs,
122                          dso->long_name);
123                 break;
124
125         case DSO_BINARY_TYPE__KCORE:
126         case DSO_BINARY_TYPE__GUEST_KCORE:
127                 snprintf(filename, size, "%s", dso->long_name);
128                 break;
129
130         default:
131         case DSO_BINARY_TYPE__KALLSYMS:
132         case DSO_BINARY_TYPE__GUEST_KALLSYMS:
133         case DSO_BINARY_TYPE__JAVA_JIT:
134         case DSO_BINARY_TYPE__NOT_FOUND:
135                 ret = -1;
136                 break;
137         }
138
139         return ret;
140 }
141
142 /*
143  * Global list of open DSOs and the counter.
144  */
145 static LIST_HEAD(dso__data_open);
146 static long dso__data_open_cnt;
147
148 static void dso__list_add(struct dso *dso)
149 {
150         list_add_tail(&dso->data.open_entry, &dso__data_open);
151         dso__data_open_cnt++;
152 }
153
154 static void dso__list_del(struct dso *dso)
155 {
156         list_del(&dso->data.open_entry);
157         WARN_ONCE(dso__data_open_cnt <= 0,
158                   "DSO data fd counter out of bounds.");
159         dso__data_open_cnt--;
160 }
161
162 static int __open_dso(struct dso *dso, struct machine *machine)
163 {
164         int fd;
165         char *root_dir = (char *)"";
166         char *name = malloc(PATH_MAX);
167
168         if (!name)
169                 return -ENOMEM;
170
171         if (machine)
172                 root_dir = machine->root_dir;
173
174         if (dso__read_binary_type_filename(dso, dso->binary_type,
175                                             root_dir, name, PATH_MAX)) {
176                 free(name);
177                 return -EINVAL;
178         }
179
180         fd = open(name, O_RDONLY);
181         free(name);
182         return fd;
183 }
184
185 static void check_data_close(void);
186
187 static int open_dso(struct dso *dso, struct machine *machine)
188 {
189         int fd = __open_dso(dso, machine);
190
191         if (fd > 0) {
192                 dso__list_add(dso);
193                 /*
194                  * Check if we crossed the allowed number
195                  * of opened DSOs and close one if needed.
196                  */
197                 check_data_close();
198         }
199
200         return fd;
201 }
202
203 static void close_data_fd(struct dso *dso)
204 {
205         if (dso->data.fd >= 0) {
206                 close(dso->data.fd);
207                 dso->data.fd = -1;
208                 dso__list_del(dso);
209         }
210 }
211
212 static void close_dso(struct dso *dso)
213 {
214         close_data_fd(dso);
215 }
216
217 static void close_first_dso(void)
218 {
219         struct dso *dso;
220
221         dso = list_first_entry(&dso__data_open, struct dso, data.open_entry);
222         close_dso(dso);
223 }
224
225 static rlim_t get_fd_limit(void)
226 {
227         struct rlimit l;
228         rlim_t limit = 0;
229
230         /* Allow half of the current open fd limit. */
231         if (getrlimit(RLIMIT_NOFILE, &l) == 0) {
232                 if (l.rlim_cur == RLIM_INFINITY)
233                         limit = l.rlim_cur;
234                 else
235                         limit = l.rlim_cur / 2;
236         } else {
237                 pr_err("failed to get fd limit\n");
238                 limit = 1;
239         }
240
241         return limit;
242 }
243
244 static bool may_cache_fd(void)
245 {
246         static rlim_t limit;
247
248         if (!limit)
249                 limit = get_fd_limit();
250
251         if (limit == RLIM_INFINITY)
252                 return true;
253
254         return limit > (rlim_t) dso__data_open_cnt;
255 }
256
257 static void check_data_close(void)
258 {
259         bool cache_fd = may_cache_fd();
260
261         if (!cache_fd)
262                 close_first_dso();
263 }
264
265 void dso__data_close(struct dso *dso)
266 {
267         close_dso(dso);
268 }
269
270 int dso__data_fd(struct dso *dso, struct machine *machine)
271 {
272         enum dso_binary_type binary_type_data[] = {
273                 DSO_BINARY_TYPE__BUILD_ID_CACHE,
274                 DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
275                 DSO_BINARY_TYPE__NOT_FOUND,
276         };
277         int i = 0;
278
279         if (dso->data.fd >= 0)
280                 return dso->data.fd;
281
282         if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) {
283                 dso->data.fd = open_dso(dso, machine);
284                 return dso->data.fd;
285         }
286
287         do {
288                 int fd;
289
290                 dso->binary_type = binary_type_data[i++];
291
292                 fd = open_dso(dso, machine);
293                 if (fd >= 0)
294                         return dso->data.fd = fd;
295
296         } while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND);
297
298         return -EINVAL;
299 }
300
301 static void
302 dso_cache__free(struct rb_root *root)
303 {
304         struct rb_node *next = rb_first(root);
305
306         while (next) {
307                 struct dso_cache *cache;
308
309                 cache = rb_entry(next, struct dso_cache, rb_node);
310                 next = rb_next(&cache->rb_node);
311                 rb_erase(&cache->rb_node, root);
312                 free(cache);
313         }
314 }
315
316 static struct dso_cache *dso_cache__find(const struct rb_root *root, u64 offset)
317 {
318         struct rb_node * const *p = &root->rb_node;
319         const struct rb_node *parent = NULL;
320         struct dso_cache *cache;
321
322         while (*p != NULL) {
323                 u64 end;
324
325                 parent = *p;
326                 cache = rb_entry(parent, struct dso_cache, rb_node);
327                 end = cache->offset + DSO__DATA_CACHE_SIZE;
328
329                 if (offset < cache->offset)
330                         p = &(*p)->rb_left;
331                 else if (offset >= end)
332                         p = &(*p)->rb_right;
333                 else
334                         return cache;
335         }
336         return NULL;
337 }
338
339 static void
340 dso_cache__insert(struct rb_root *root, struct dso_cache *new)
341 {
342         struct rb_node **p = &root->rb_node;
343         struct rb_node *parent = NULL;
344         struct dso_cache *cache;
345         u64 offset = new->offset;
346
347         while (*p != NULL) {
348                 u64 end;
349
350                 parent = *p;
351                 cache = rb_entry(parent, struct dso_cache, rb_node);
352                 end = cache->offset + DSO__DATA_CACHE_SIZE;
353
354                 if (offset < cache->offset)
355                         p = &(*p)->rb_left;
356                 else if (offset >= end)
357                         p = &(*p)->rb_right;
358         }
359
360         rb_link_node(&new->rb_node, parent, p);
361         rb_insert_color(&new->rb_node, root);
362 }
363
364 static ssize_t
365 dso_cache__memcpy(struct dso_cache *cache, u64 offset,
366                   u8 *data, u64 size)
367 {
368         u64 cache_offset = offset - cache->offset;
369         u64 cache_size   = min(cache->size - cache_offset, size);
370
371         memcpy(data, cache->data + cache_offset, cache_size);
372         return cache_size;
373 }
374
375 static ssize_t
376 dso_cache__read(struct dso *dso, struct machine *machine,
377                  u64 offset, u8 *data, ssize_t size)
378 {
379         struct dso_cache *cache;
380         ssize_t ret;
381         int fd;
382
383         fd = dso__data_fd(dso, machine);
384         if (fd < 0)
385                 return -1;
386
387         do {
388                 u64 cache_offset;
389
390                 ret = -ENOMEM;
391
392                 cache = zalloc(sizeof(*cache) + DSO__DATA_CACHE_SIZE);
393                 if (!cache)
394                         break;
395
396                 cache_offset = offset & DSO__DATA_CACHE_MASK;
397                 ret = -EINVAL;
398
399                 if (-1 == lseek(fd, cache_offset, SEEK_SET))
400                         break;
401
402                 ret = read(fd, cache->data, DSO__DATA_CACHE_SIZE);
403                 if (ret <= 0)
404                         break;
405
406                 cache->offset = cache_offset;
407                 cache->size   = ret;
408                 dso_cache__insert(&dso->data.cache, cache);
409
410                 ret = dso_cache__memcpy(cache, offset, data, size);
411
412         } while (0);
413
414         if (ret <= 0)
415                 free(cache);
416
417         return ret;
418 }
419
420 static ssize_t dso_cache_read(struct dso *dso, struct machine *machine,
421                               u64 offset, u8 *data, ssize_t size)
422 {
423         struct dso_cache *cache;
424
425         cache = dso_cache__find(&dso->data.cache, offset);
426         if (cache)
427                 return dso_cache__memcpy(cache, offset, data, size);
428         else
429                 return dso_cache__read(dso, machine, offset, data, size);
430 }
431
432 ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
433                               u64 offset, u8 *data, ssize_t size)
434 {
435         ssize_t r = 0;
436         u8 *p = data;
437
438         do {
439                 ssize_t ret;
440
441                 ret = dso_cache_read(dso, machine, offset, p, size);
442                 if (ret < 0)
443                         return ret;
444
445                 /* Reached EOF, return what we have. */
446                 if (!ret)
447                         break;
448
449                 BUG_ON(ret > size);
450
451                 r      += ret;
452                 p      += ret;
453                 offset += ret;
454                 size   -= ret;
455
456         } while (size);
457
458         return r;
459 }
460
461 ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
462                             struct machine *machine, u64 addr,
463                             u8 *data, ssize_t size)
464 {
465         u64 offset = map->map_ip(map, addr);
466         return dso__data_read_offset(dso, machine, offset, data, size);
467 }
468
469 struct map *dso__new_map(const char *name)
470 {
471         struct map *map = NULL;
472         struct dso *dso = dso__new(name);
473
474         if (dso)
475                 map = map__new2(0, dso, MAP__FUNCTION);
476
477         return map;
478 }
479
480 struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
481                     const char *short_name, int dso_type)
482 {
483         /*
484          * The kernel dso could be created by build_id processing.
485          */
486         struct dso *dso = __dsos__findnew(&machine->kernel_dsos, name);
487
488         /*
489          * We need to run this in all cases, since during the build_id
490          * processing we had no idea this was the kernel dso.
491          */
492         if (dso != NULL) {
493                 dso__set_short_name(dso, short_name, false);
494                 dso->kernel = dso_type;
495         }
496
497         return dso;
498 }
499
500 void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated)
501 {
502         if (name == NULL)
503                 return;
504
505         if (dso->long_name_allocated)
506                 free((char *)dso->long_name);
507
508         dso->long_name           = name;
509         dso->long_name_len       = strlen(name);
510         dso->long_name_allocated = name_allocated;
511 }
512
513 void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated)
514 {
515         if (name == NULL)
516                 return;
517
518         if (dso->short_name_allocated)
519                 free((char *)dso->short_name);
520
521         dso->short_name           = name;
522         dso->short_name_len       = strlen(name);
523         dso->short_name_allocated = name_allocated;
524 }
525
526 static void dso__set_basename(struct dso *dso)
527 {
528        /*
529         * basename() may modify path buffer, so we must pass
530         * a copy.
531         */
532        char *base, *lname = strdup(dso->long_name);
533
534        if (!lname)
535                return;
536
537        /*
538         * basename() may return a pointer to internal
539         * storage which is reused in subsequent calls
540         * so copy the result.
541         */
542        base = strdup(basename(lname));
543
544        free(lname);
545
546        if (!base)
547                return;
548
549        dso__set_short_name(dso, base, true);
550 }
551
552 int dso__name_len(const struct dso *dso)
553 {
554         if (!dso)
555                 return strlen("[unknown]");
556         if (verbose)
557                 return dso->long_name_len;
558
559         return dso->short_name_len;
560 }
561
562 bool dso__loaded(const struct dso *dso, enum map_type type)
563 {
564         return dso->loaded & (1 << type);
565 }
566
567 bool dso__sorted_by_name(const struct dso *dso, enum map_type type)
568 {
569         return dso->sorted_by_name & (1 << type);
570 }
571
572 void dso__set_sorted_by_name(struct dso *dso, enum map_type type)
573 {
574         dso->sorted_by_name |= (1 << type);
575 }
576
577 struct dso *dso__new(const char *name)
578 {
579         struct dso *dso = calloc(1, sizeof(*dso) + strlen(name) + 1);
580
581         if (dso != NULL) {
582                 int i;
583                 strcpy(dso->name, name);
584                 dso__set_long_name(dso, dso->name, false);
585                 dso__set_short_name(dso, dso->name, false);
586                 for (i = 0; i < MAP__NR_TYPES; ++i)
587                         dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
588                 dso->data.cache = RB_ROOT;
589                 dso->data.fd = -1;
590                 dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND;
591                 dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND;
592                 dso->loaded = 0;
593                 dso->rel = 0;
594                 dso->sorted_by_name = 0;
595                 dso->has_build_id = 0;
596                 dso->has_srcline = 1;
597                 dso->a2l_fails = 1;
598                 dso->kernel = DSO_TYPE_USER;
599                 dso->needs_swap = DSO_SWAP__UNSET;
600                 INIT_LIST_HEAD(&dso->node);
601                 INIT_LIST_HEAD(&dso->data.open_entry);
602         }
603
604         return dso;
605 }
606
607 void dso__delete(struct dso *dso)
608 {
609         int i;
610         for (i = 0; i < MAP__NR_TYPES; ++i)
611                 symbols__delete(&dso->symbols[i]);
612
613         if (dso->short_name_allocated) {
614                 zfree((char **)&dso->short_name);
615                 dso->short_name_allocated = false;
616         }
617
618         if (dso->long_name_allocated) {
619                 zfree((char **)&dso->long_name);
620                 dso->long_name_allocated = false;
621         }
622
623         dso__data_close(dso);
624         dso_cache__free(&dso->data.cache);
625         dso__free_a2l(dso);
626         zfree(&dso->symsrc_filename);
627         free(dso);
628 }
629
630 void dso__set_build_id(struct dso *dso, void *build_id)
631 {
632         memcpy(dso->build_id, build_id, sizeof(dso->build_id));
633         dso->has_build_id = 1;
634 }
635
636 bool dso__build_id_equal(const struct dso *dso, u8 *build_id)
637 {
638         return memcmp(dso->build_id, build_id, sizeof(dso->build_id)) == 0;
639 }
640
641 void dso__read_running_kernel_build_id(struct dso *dso, struct machine *machine)
642 {
643         char path[PATH_MAX];
644
645         if (machine__is_default_guest(machine))
646                 return;
647         sprintf(path, "%s/sys/kernel/notes", machine->root_dir);
648         if (sysfs__read_build_id(path, dso->build_id,
649                                  sizeof(dso->build_id)) == 0)
650                 dso->has_build_id = true;
651 }
652
653 int dso__kernel_module_get_build_id(struct dso *dso,
654                                     const char *root_dir)
655 {
656         char filename[PATH_MAX];
657         /*
658          * kernel module short names are of the form "[module]" and
659          * we need just "module" here.
660          */
661         const char *name = dso->short_name + 1;
662
663         snprintf(filename, sizeof(filename),
664                  "%s/sys/module/%.*s/notes/.note.gnu.build-id",
665                  root_dir, (int)strlen(name) - 1, name);
666
667         if (sysfs__read_build_id(filename, dso->build_id,
668                                  sizeof(dso->build_id)) == 0)
669                 dso->has_build_id = true;
670
671         return 0;
672 }
673
674 bool __dsos__read_build_ids(struct list_head *head, bool with_hits)
675 {
676         bool have_build_id = false;
677         struct dso *pos;
678
679         list_for_each_entry(pos, head, node) {
680                 if (with_hits && !pos->hit)
681                         continue;
682                 if (pos->has_build_id) {
683                         have_build_id = true;
684                         continue;
685                 }
686                 if (filename__read_build_id(pos->long_name, pos->build_id,
687                                             sizeof(pos->build_id)) > 0) {
688                         have_build_id     = true;
689                         pos->has_build_id = true;
690                 }
691         }
692
693         return have_build_id;
694 }
695
696 void dsos__add(struct list_head *head, struct dso *dso)
697 {
698         list_add_tail(&dso->node, head);
699 }
700
701 struct dso *dsos__find(const struct list_head *head, const char *name, bool cmp_short)
702 {
703         struct dso *pos;
704
705         if (cmp_short) {
706                 list_for_each_entry(pos, head, node)
707                         if (strcmp(pos->short_name, name) == 0)
708                                 return pos;
709                 return NULL;
710         }
711         list_for_each_entry(pos, head, node)
712                 if (strcmp(pos->long_name, name) == 0)
713                         return pos;
714         return NULL;
715 }
716
717 struct dso *__dsos__findnew(struct list_head *head, const char *name)
718 {
719         struct dso *dso = dsos__find(head, name, false);
720
721         if (!dso) {
722                 dso = dso__new(name);
723                 if (dso != NULL) {
724                         dsos__add(head, dso);
725                         dso__set_basename(dso);
726                 }
727         }
728
729         return dso;
730 }
731
732 size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp,
733                                bool (skip)(struct dso *dso, int parm), int parm)
734 {
735         struct dso *pos;
736         size_t ret = 0;
737
738         list_for_each_entry(pos, head, node) {
739                 if (skip && skip(pos, parm))
740                         continue;
741                 ret += dso__fprintf_buildid(pos, fp);
742                 ret += fprintf(fp, " %s\n", pos->long_name);
743         }
744         return ret;
745 }
746
747 size_t __dsos__fprintf(struct list_head *head, FILE *fp)
748 {
749         struct dso *pos;
750         size_t ret = 0;
751
752         list_for_each_entry(pos, head, node) {
753                 int i;
754                 for (i = 0; i < MAP__NR_TYPES; ++i)
755                         ret += dso__fprintf(pos, i, fp);
756         }
757
758         return ret;
759 }
760
761 size_t dso__fprintf_buildid(struct dso *dso, FILE *fp)
762 {
763         char sbuild_id[BUILD_ID_SIZE * 2 + 1];
764
765         build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
766         return fprintf(fp, "%s", sbuild_id);
767 }
768
769 size_t dso__fprintf(struct dso *dso, enum map_type type, FILE *fp)
770 {
771         struct rb_node *nd;
772         size_t ret = fprintf(fp, "dso: %s (", dso->short_name);
773
774         if (dso->short_name != dso->long_name)
775                 ret += fprintf(fp, "%s, ", dso->long_name);
776         ret += fprintf(fp, "%s, %sloaded, ", map_type__name[type],
777                        dso__loaded(dso, type) ? "" : "NOT ");
778         ret += dso__fprintf_buildid(dso, fp);
779         ret += fprintf(fp, ")\n");
780         for (nd = rb_first(&dso->symbols[type]); nd; nd = rb_next(nd)) {
781                 struct symbol *pos = rb_entry(nd, struct symbol, rb_node);
782                 ret += symbol__fprintf(pos, fp);
783         }
784
785         return ret;
786 }