Commit 18bd726418f2a2e12f85104f0f4b5d5d077e1752

Authored by Arnaldo Carvalho de Melo
1 parent de4809999d

perf symbols: Introduce method to iterate symbols ordered by name

Given a symbol, go to the next entry in a rbtree sorted by symbol name.

Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Link: http://lkml.kernel.org/n/tip-aq210drxprnu2so4dye5xa3j@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Showing 2 changed files with 12 additions and 0 deletions Side-by-side Diff

tools/perf/util/symbol.c
... ... @@ -450,6 +450,17 @@
450 450 return symbols__next(sym);
451 451 }
452 452  
  453 +struct symbol *symbol__next_by_name(struct symbol *sym)
  454 +{
  455 + struct symbol_name_rb_node *s = container_of(sym, struct symbol_name_rb_node, sym);
  456 + struct rb_node *n = rb_next(&s->rb_node);
  457 +
  458 + return n ? &rb_entry(n, struct symbol_name_rb_node, rb_node)->sym : NULL;
  459 +}
  460 +
  461 + /*
  462 + * Teturns first symbol that matched with @name.
  463 + */
453 464 struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type,
454 465 const char *name)
455 466 {
tools/perf/util/symbol.h
... ... @@ -231,6 +231,7 @@
231 231 u64 addr);
232 232 struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type,
233 233 const char *name);
  234 +struct symbol *symbol__next_by_name(struct symbol *sym);
234 235  
235 236 struct symbol *dso__first_symbol(struct dso *dso, enum map_type type);
236 237 struct symbol *dso__next_symbol(struct symbol *sym);