free(self);
}
-void map__fixup_start(struct map *self, struct rb_root *symbols)
+void map__fixup_start(struct map *self)
{
+ struct rb_root *symbols = &self->dso->symbols[self->type];
struct rb_node *nd = rb_first(symbols);
if (nd != NULL) {
struct symbol *sym = rb_entry(nd, struct symbol, rb_node);
}
}
-void map__fixup_end(struct map *self, struct rb_root *symbols)
+void map__fixup_end(struct map *self)
{
+ struct rb_root *symbols = &self->dso->symbols[self->type];
struct rb_node *nd = rb_last(symbols);
if (nd != NULL) {
struct symbol *sym = rb_entry(nd, struct symbol, rb_node);
#define DSO__DELETED "(deleted)"
-struct symbol *map__find_function(struct map *self, u64 ip,
- symbol_filter_t filter)
+struct symbol *map__find_symbol(struct map *self, u64 addr,
+ symbol_filter_t filter)
{
if (!dso__loaded(self->dso, self->type)) {
int nr = dso__load(self->dso, self, filter);
}
}
- return self->dso->find_function(self->dso, ip);
+ return self->dso->find_symbol(self->dso, self->type, addr);
}
struct map *map__clone(struct map *self)
static void dsos__add(struct list_head *head, struct dso *dso);
static struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
static void kernel_maps__insert(struct map *map);
+struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
static int dso__load_kernel_sym(struct dso *self, struct map *map,
symbol_filter_t filter);
unsigned int symbol__priv_size;
struct dso *self = malloc(sizeof(*self) + strlen(name) + 1);
if (self != NULL) {
+ int i;
strcpy(self->name, name);
dso__set_long_name(self, self->name);
self->short_name = self->name;
- self->functions = RB_ROOT;
- self->find_function = dso__find_function;
+ for (i = 0; i < MAP__NR_TYPES; ++i)
+ self->symbols[i] = RB_ROOT;
+ self->find_symbol = dso__find_symbol;
self->slen_calculated = 0;
self->origin = DSO__ORIG_NOT_FOUND;
self->loaded = 0;
void dso__delete(struct dso *self)
{
- symbols__delete(&self->functions);
+ int i;
+ for (i = 0; i < MAP__NR_TYPES; ++i)
+ symbols__delete(&self->symbols[i]);
if (self->long_name != self->name)
free(self->long_name);
free(self);
return NULL;
}
-struct symbol *dso__find_function(struct dso *self, u64 ip)
+struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr)
{
- return symbols__find(&self->functions, ip);
+ return symbols__find(&self->symbols[type], addr);
}
int build_id__sprintf(u8 *self, int len, char *bf)
return fprintf(fp, "%s", sbuild_id);
}
+static const char * map_type__name[MAP__NR_TYPES] = {
+ [MAP__FUNCTION] = "Functions",
+};
+
size_t dso__fprintf(struct dso *self, FILE *fp)
{
+ int i;
struct rb_node *nd;
size_t ret = fprintf(fp, "dso: %s (", self->short_name);
ret += dso__fprintf_buildid(self, fp);
- ret += fprintf(fp, ")\nFunctions:\n");
+ ret += fprintf(fp, ")\n");
+ for (i = 0; i < MAP__NR_TYPES; ++i) {
+ ret += fprintf(fp, "%s:\n", map_type__name[i]);
- for (nd = rb_first(&self->functions); nd; nd = rb_next(nd)) {
- struct symbol *pos = rb_entry(nd, struct symbol, rb_node);
- ret += symbol__fprintf(pos, fp);
+ for (nd = rb_first(&self->symbols[i]); nd; nd = rb_next(nd)) {
+ struct symbol *pos = rb_entry(nd, struct symbol, rb_node);
+ ret += symbol__fprintf(pos, fp);
+ }
}
return ret;
* kernel_maps__split_kallsyms, when we have split the
* maps per module
*/
- symbols__insert(&kernel_map__functions->dso->functions, sym);
+ symbols__insert(&kernel_map__functions->dso->symbols[MAP__FUNCTION], sym);
}
free(line);
struct map *map = kernel_map__functions;
struct symbol *pos;
int count = 0;
- struct rb_node *next = rb_first(&kernel_map__functions->dso->functions);
+ struct rb_node *next = rb_first(&kernel_map__functions->dso->symbols[map->type]);
int kernel_range = 0;
while (next) {
}
if (filter && filter(map, pos)) {
- rb_erase(&pos->rb_node, &kernel_map__functions->dso->functions);
+ rb_erase(&pos->rb_node, &kernel_map__functions->dso->symbols[map->type]);
symbol__delete(pos);
} else {
if (map != kernel_map__functions) {
rb_erase(&pos->rb_node,
- &kernel_map__functions->dso->functions);
- symbols__insert(&map->dso->functions, pos);
+ &kernel_map__functions->dso->symbols[map->type]);
+ symbols__insert(&map->dso->symbols[map->type], pos);
}
count++;
}
if (kernel_maps__load_all_kallsyms())
return -1;
- symbols__fixup_end(&kernel_map__functions->dso->functions);
+ symbols__fixup_end(&kernel_map__functions->dso->symbols[MAP__FUNCTION]);
kernel_map__functions->dso->origin = DSO__ORIG_KERNEL;
return kernel_maps__split_kallsyms(filter);
if (filter && filter(map, sym))
symbol__delete(sym);
else {
- symbols__insert(&self->functions, sym);
+ symbols__insert(&self->symbols[map->type], sym);
nr_syms++;
}
}
if (filter && filter(map, f))
symbol__delete(f);
else {
- symbols__insert(&self->functions, f);
+ symbols__insert(&self->symbols[map->type], f);
++nr;
}
}
if (filter && filter(map, f))
symbol__delete(f);
else {
- symbols__insert(&self->functions, f);
+ symbols__insert(&self->symbols[map->type], f);
++nr;
}
}
if (filter && filter(curr_map, f))
symbol__delete(f);
else {
- symbols__insert(&curr_dso->functions, f);
+ symbols__insert(&curr_dso->symbols[curr_map->type], f);
nr++;
}
}
* For misannotated, zeroed, ASM function sizes.
*/
if (nr > 0)
- symbols__fixup_end(&self->functions);
+ symbols__fixup_end(&self->symbols[map->type]);
err = nr;
out_elf_end:
elf_end(elf);
if (map) {
ip = map->map_ip(map, ip);
- return map__find_function(map, ip, filter);
+ return map__find_symbol(map, ip, filter);
} else
WARN_ONCE(RB_EMPTY_ROOT(&kernel_maps__functions),
"Empty kernel_maps, was symbol__init() called?\n");
if (err > 0) {
out_fixup:
- map__fixup_start(map, &map->dso->functions);
- map__fixup_end(map, &map->dso->functions);
+ map__fixup_start(map);
+ map__fixup_end(map);
}
return err;