Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf symbols: Add dso__last_symbol()

Add a function to find the last symbol in a DSO. This will be used when
parsing address filters to calculate a region that includes the entire
DSO.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: http://lkml.kernel.org/r/1474641528-18776-7-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
cd67f99f 5c01ad60

+16
+15
tools/perf/util/symbol.c
··· 345 345 return NULL; 346 346 } 347 347 348 + static struct symbol *symbols__last(struct rb_root *symbols) 349 + { 350 + struct rb_node *n = rb_last(symbols); 351 + 352 + if (n) 353 + return rb_entry(n, struct symbol, rb_node); 354 + 355 + return NULL; 356 + } 357 + 348 358 static struct symbol *symbols__next(struct symbol *sym) 349 359 { 350 360 struct rb_node *n = rb_next(&sym->rb_node); ··· 474 464 struct symbol *dso__first_symbol(struct dso *dso, enum map_type type) 475 465 { 476 466 return symbols__first(&dso->symbols[type]); 467 + } 468 + 469 + struct symbol *dso__last_symbol(struct dso *dso, enum map_type type) 470 + { 471 + return symbols__last(&dso->symbols[type]); 477 472 } 478 473 479 474 struct symbol *dso__next_symbol(struct symbol *sym)
+1
tools/perf/util/symbol.h
··· 259 259 struct symbol *symbol__next_by_name(struct symbol *sym); 260 260 261 261 struct symbol *dso__first_symbol(struct dso *dso, enum map_type type); 262 + struct symbol *dso__last_symbol(struct dso *dso, enum map_type type); 262 263 struct symbol *dso__next_symbol(struct symbol *sym); 263 264 264 265 enum dso_type dso__type_fd(int fd);