summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-event.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-01-16 16:40:25 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-01-21 10:06:15 -0300
commit0a3873a8e2709ebc759361e2d872d9f71541806c (patch)
tree735b7be4757a8af9f4b5fd8363440c9cdeb980fc /tools/perf/util/probe-event.c
parent564c62a4d7f9a4b60920ee0b02cfe890471d87f4 (diff)
downloadop-kernel-dev-0a3873a8e2709ebc759361e2d872d9f71541806c.zip
op-kernel-dev-0a3873a8e2709ebc759361e2d872d9f71541806c.tar.gz
perf symbols: Introduce 'for' method to iterate over the symbols with a given name
Removing boilerplate from two places, where one would have to find the first entry, then iterate using symbol__next_by_name + strcmp to see if the next member had the same 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-eh73z8gthv20yowirmx2yk38@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r--tools/perf/util/probe-event.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b24482e..7cc89b1 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2196,14 +2196,11 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
static int find_probe_functions(struct map *map, char *name)
{
int found = 0;
- struct symbol *sym = map__find_symbol_by_name(map, name, NULL);
+ struct symbol *sym;
- while (sym != NULL) {
+ map__for_each_symbol_by_name(map, name, sym) {
if (sym->binding == STB_GLOBAL || sym->binding == STB_LOCAL)
found++;
- sym = symbol__next_by_name(sym);
- if (sym == NULL || strcmp(sym->name, name))
- break;
}
return found;
@@ -2275,9 +2272,8 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
}
ret = 0;
- sym = map__find_symbol_by_name(map, pp->function, NULL);
- while (sym != NULL) {
+ map__for_each_symbol_by_name(map, pp->function, sym) {
tev = (*tevs) + ret;
tp = &tev->point;
if (ret == num_matched_functions) {
@@ -2325,10 +2321,6 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
strdup_or_goto(pev->args[i].type,
nomem_out);
}
-
- sym = symbol__next_by_name(sym);
- if (sym == NULL || strcmp(sym->name, pp->function))
- break;
}
out:
OpenPOWER on IntegriCloud