Home | History | Annotate | Download | only in util

Lines Matching refs:dso

40 static bool dso__build_id_equal(const struct dso *dso, u8 *build_id);
42 static void dsos__add(struct list_head *head, struct dso *dso);
43 static struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
44 static int dso__load_kernel_sym(struct dso *dso, struct map *map,
46 static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map,
58 int dso__name_len(const struct dso *dso)
61 return dso->long_name_len;
63 return dso->short_name_len;
66 bool dso__loaded(const struct dso *dso, enum map_type type)
68 return dso->loaded & (1 << type);
71 bool dso__sorted_by_name(const struct dso *dso, enum map_type type)
73 return dso->sorted_by_name & (1 << type);
76 static void dso__set_sorted_by_name(struct dso *dso, enum map_type type)
78 dso->sorted_by_name |= (1 << type);
184 void dso__set_long_name(struct dso *dso, char *name)
188 dso->long_name = name;
189 dso->long_name_len = strlen(name);
192 static void dso__set_short_name(struct dso *dso, const char *name)
196 dso->short_name = name;
197 dso->short_name_len = strlen(name);
200 static void dso__set_basename(struct dso *dso)
202 dso__set_short_name(dso, basename(dso->long_name));
205 struct dso *dso__new(const char *name)
207 struct dso *dso = calloc(1, sizeof(*dso) + strlen(name) + 1);
209 if (dso != NULL) {
211 strcpy(dso->name, name);
212 dso__set_long_name(dso, dso->name);
213 dso__set_short_name(dso, dso->name);
215 dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
216 dso->symtab_type = SYMTAB__NOT_FOUND;
217 dso->loaded = 0;
218 dso->sorted_by_name = 0;
219 dso->has_build_id = 0;
220 dso->kernel = DSO_TYPE_USER;
221 INIT_LIST_HEAD(&dso->node);
224 return dso;
240 void dso__delete(struct dso *dso)
244 symbols__delete(&dso->symbols[i]);
245 if (dso->sname_alloc)
246 free((char *)dso->short_name);
247 if (dso->lname_alloc)
248 free(dso->long_name);
249 free(dso);
252 void dso__set_build_id(struct dso *dso, void *build_id)
254 memcpy(dso->build_id, build_id, sizeof(dso->build_id));
255 dso->has_build_id = 1;
364 struct symbol *dso__find_symbol(struct dso *dso,
367 return symbols__find(&dso->symbols[type], addr);
370 struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type,
373 return symbols__find_by_name(&dso->symbol_names[type], name);
376 void dso__sort_by_name(struct dso *dso, enum map_type type)
378 dso__set_sorted_by_name(dso, type);
379 return symbols__sort_by_name(&dso->symbol_names[type],
380 &dso->symbols[type]);
398 size_t dso__fprintf_buildid(struct dso *dso, FILE *fp)
402 build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
406 size_t dso__fprintf_symbols_by_name(struct dso *dso,
413 for (nd = rb_first(&dso->symbol_names[type]); nd; nd = rb_next(nd)) {
421 size_t dso__fprintf(struct dso *dso, enum map_type type, FILE *fp)
424 size_t ret = fprintf(fp, "dso: %s (", dso->short_name);
426 if (dso->short_name != dso->long_name)
427 ret += fprintf(fp, "%s, ", dso->long_name);
429 dso->loaded ? "" : "NOT ");
430 ret += dso__fprintf_buildid(dso, fp);
432 for (nd = rb_first(&dso->symbols[type]); nd; nd = rb_next(nd)) {
516 struct dso *dso;
532 struct rb_root *root = &a->dso->symbols[a->map->type];
551 * Loads the function entries in /proc/kallsyms into kernel_map->dso,
555 static int dso__load_all_kallsyms(struct dso *dso, const char *filename,
558 struct process_kallsyms_args args = { .map = map, .dso = dso, };
567 static int dso__split_kallsyms(struct dso *dso, struct map *map,
575 struct rb_root *root = &dso->symbols[map->type];
592 if (strcmp(curr_map->dso->short_name, module)) {
594 dso->kernel == DSO_TYPE_GUEST_KERNEL &&
603 dso__set_loaded(curr_map->dso,
618 if (curr_map->dso->loaded &&
630 struct dso *ndso;
637 if (dso->kernel == DSO_TYPE_GUEST_KERNEL)
650 ndso->kernel = dso->kernel;
669 symbols__insert(&curr_map->dso->symbols[curr_map->type], pos);
677 dso->kernel == DSO_TYPE_GUEST_KERNEL &&
679 dso__set_loaded(curr_map->dso, curr_map->type);
703 int dso__load_kallsyms(struct dso *dso, const char *filename,
709 if (dso__load_all_kallsyms(dso, filename, map) < 0)
712 if (dso->kernel == DSO_TYPE_GUEST_KERNEL)
713 dso->symtab_type = SYMTAB__GUEST_KALLSYMS;
715 dso->symtab_type = SYMTAB__KALLSYMS;
717 return dso__split_kallsyms(dso, map, filter);
720 static int dso__load_perf_map(struct dso *dso, struct map *map,
728 file = fopen(dso->long_name, "r");
766 symbols__insert(&dso->symbols[map->type], sym);
882 * And always look at the original dso, not at debuginfo packages, that
885 static int dso__synthesize_plt_symbols(struct dso *dso, struct map *map,
904 symbol_conf.symfs, dso->long_name);
980 symbols__insert(&dso->symbols[map->type], f);
1002 symbols__insert(&dso->symbols[map->type], f);
1018 __func__, dso->long_name);
1066 static int dso__load_sym(struct dso *dso, struct map *map, const char *name,
1070 struct kmap *kmap = dso->kernel ? map__kmap(map) : NULL;
1072 struct dso *curr_dso = dso;
1098 if (dso->has_build_id) {
1105 if (!dso__build_id_equal(dso, build_id))
1148 if (dso->kernel == DSO_TYPE_USER) {
1149 dso->adjust_symbols = (ehdr.e_type == ET_EXEC ||
1154 dso->adjust_symbols = 0;
1205 if (dso->kernel != DSO_TYPE_USER || kmodule) {
1210 dso->short_name_len)) == 0)
1215 curr_dso = dso;
1220 "%s%s", dso->short_name, section_name);
1232 curr_dso->kernel = dso->kernel;
1233 curr_dso->long_name = dso->long_name;
1234 curr_dso->long_name_len = dso->long_name_len;
1243 curr_dso->symtab_type = dso->symtab_type;
1245 dsos__add(&dso->node, curr_dso);
1248 curr_dso = curr_map->dso;
1287 symbols__fixup_end(&dso->symbols[map->type]);
1303 static bool dso__build_id_equal(const struct dso *dso, u8 *build_id)
1305 return memcmp(dso->build_id, build_id, sizeof(dso->build_id)) == 0;
1311 struct dso *pos;
1466 char dso__symtab_origin(const struct dso *dso)
1481 if (dso == NULL || dso->symtab_type == SYMTAB__NOT_FOUND)
1483 return origin[dso->symtab_type];
1486 int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
1496 dso__set_loaded(dso, map->type);
1498 if (dso->kernel == DSO_TYPE_KERNEL)
1499 return dso__load_kernel_sym(dso, map, filter);
1500 else if (dso->kernel == DSO_TYPE_GUEST_KERNEL)
1501 return dso__load_guest_kernel_sym(dso, map, filter);
1512 dso->adjust_symbols = 0;
1514 if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
1515 ret = dso__load_perf_map(dso, map, filter);
1516 dso->symtab_type = ret > 0 ? SYMTAB__JAVA_JIT :
1527 for (dso->symtab_type = SYMTAB__BUILD_ID_CACHE;
1528 dso->symtab_type != SYMTAB__NOT_FOUND;
1529 dso->symtab_type++) {
1530 switch (dso->symtab_type) {
1534 (dso__build_id_filename(dso, name, size) == NULL)) {
1540 symbol_conf.symfs, dso->long_name);
1544 symbol_conf.symfs, dso->long_name);
1549 if (!dso->has_build_id)
1552 build_id__sprintf(dso->build_id,
1553 sizeof(dso->build_id),
1562 symbol_conf.symfs, dso->long_name);
1570 root_dir, dso->long_name);
1575 dso->long_name);
1585 ret = dso__load_sym(dso, map, name, fd, filter, 0,
1597 int nr_plt = dso__synthesize_plt_symbols(dso, map,
1615 if (ret < 0 && strstr(dso->name, " (deleted)") != NULL)
1628 if (map->dso && strcmp(map->dso->short_name, name) == 0)
1635 static int dso__kernel_module_get_build_id(struct dso *dso,
1643 const char *name = dso->short_name + 1;
1649 if (sysfs__read_build_id(filename, dso->build_id,
1650 sizeof(dso->build_id)) == 0)
1651 dso->has_build_id = true;
1712 dso__set_long_name(map->dso, long_name);
1713 map->dso->lname_alloc = 1;
1714 dso__kernel_module_get_build_id(map->dso, "");
1771 static struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
1774 (dso->kernel ? sizeof(struct kmap) : 0)));
1779 map__init(map, type, start, 0, 0, dso);
1789 struct dso *dso = __dsos__findnew(&machine->kernel_dsos, filename);
1791 if (dso == NULL)
1794 map = map__new2(start, dso, MAP__FUNCTION);
1799 dso->symtab_type = SYMTAB__SYSTEM_PATH_KMODULE;
1801 dso->symtab_type = SYMTAB__GUEST_KMODULE;
1860 dso__kernel_module_get_build_id(map->dso, machine->root_dir);
1874 int dso__load_vmlinux(struct dso *dso, struct map *map,
1886 dso__set_long_name(dso, (char *)vmlinux);
1887 dso__set_loaded(dso, map->type);
1888 err = dso__load_sym(dso, map, symfs_vmlinux, fd, filter, 0, 0);
1897 int dso__load_vmlinux_path(struct dso *dso, struct map *map,
1906 filename = dso__build_id_filename(dso, NULL, 0);
1908 err = dso__load_vmlinux(dso, map, filename, filter);
1910 dso__set_long_name(dso, filename);
1917 err = dso__load_vmlinux(dso, map, vmlinux_path[i], filter);
1919 dso__set_long_name(dso, strdup(vmlinux_path[i]));
1927 static int dso__load_kernel_sym(struct dso *dso, struct map *map,
1954 err = dso__load_vmlinux(dso, map,
1957 dso__set_long_name(dso,
1965 err = dso__load_vmlinux_path(dso, map, filter);
1975 * Say the kernel DSO was created when processing the build-id header table,
1979 if (dso->has_build_id) {
1985 if (dso__build_id_equal(dso, kallsyms_build_id)) {
1994 build_id__sprintf(dso->build_id, sizeof(dso->build_id),
2021 err = dso__load_kallsyms(dso, kallsyms_filename, map, filter);
2029 dso__set_long_name(dso, strdup("[kernel.kallsyms]"));
2037 static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map,
2058 err = dso__load_vmlinux(dso, map,
2071 err = dso__load_kallsyms(dso, kallsyms_filename, map, filter);
2079 dso__set_long_name(dso, strdup(path));
2088 static void dsos__add(struct list_head *head, struct dso *dso)
2090 list_add_tail(&dso->node, head);
2093 static struct dso *dsos__find(struct list_head *head, const char *name)
2095 struct dso *pos;
2103 struct dso *__dsos__findnew(struct list_head *head, const char *name)
2105 struct dso *dso = dsos__find(head, name);
2107 if (!dso) {
2108 dso = dso__new(name);
2109 if (dso != NULL) {
2110 dsos__add(head, dso);
2111 dso__set_basename(dso);
2115 return dso;
2120 struct dso *pos;
2149 struct dso *pos;
2181 struct dso *dso__new_kernel(const char *name)
2183 struct dso *dso = dso__new(name ?: "[kernel.kallsyms]");
2185 if (dso != NULL) {
2186 dso__set_short_name(dso, "[kernel]");
2187 dso->kernel = DSO_TYPE_KERNEL;
2190 return dso;
2193 static struct dso *dso__new_guest_kernel(struct machine *machine,
2197 struct dso *dso = dso__new(name ?: machine__mmap_name(machine, bf,
2199 if (dso != NULL) {
2200 dso__set_short_name(dso, "[guest.kernel]");
2201 dso->kernel = DSO_TYPE_GUEST_KERNEL;
2204 return dso;
2207 void dso__read_running_kernel_build_id(struct dso *dso, struct machine *machine)
2214 if (sysfs__read_build_id(path, dso->build_id,
2215 sizeof(dso->build_id)) == 0)
2216 dso->has_build_id = true;
2219 static struct dso *machine__create_kernel(struct machine *machine)
2222 struct dso *kernel;
2283 int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
2340 struct dso *kernel = machine__create_kernel(machine);
2419 struct dso *kdso = machine->vmlinux_maps[MAP__FUNCTION]->dso;
2496 symbol_conf.dso_list_str, "dso") < 0)
2654 int ret = dso__load_kallsyms(map->dso, filename, map, filter);
2657 dso__set_loaded(map->dso, type);
2673 int ret = dso__load_vmlinux_path(map->dso, map, filter);
2676 dso__set_loaded(map->dso, type);