perf test vmlinux: Avoid printing headers for empty lists

Before:

  # perf test -F -v 1
   1: vmlinux symtab matches kallsyms:
  --- start ---
<SNIP>
  WARN: Maps only in vmlinux:
   ffffffffb7d7d000-ffffffffb7eeaac8 117d000 [kernel].init.text
   ffffffffb7eeaac8-ffffffffc03ad000 12eaac8 [kernel].exit.text
  WARN: Maps in vmlinux with a different name in kallsyms:
  WARN: Maps only in kallsyms:
  ---- end ----
  vmlinux symtab matches kallsyms: Ok
  #

The two last WARN lines are now suppressed, since there are no such
cases detected.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-9ww8uvzl682ykaw8ht1tozlr@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e267769e
...@@ -28,6 +28,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused) ...@@ -28,6 +28,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
enum map_type type = MAP__FUNCTION; enum map_type type = MAP__FUNCTION;
struct maps *maps = &vmlinux.kmaps.maps[type]; struct maps *maps = &vmlinux.kmaps.maps[type];
u64 mem_start, mem_end; u64 mem_start, mem_end;
bool header_printed;
/* /*
* Step 1: * Step 1:
...@@ -178,7 +179,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused) ...@@ -178,7 +179,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
if (!verbose) if (!verbose)
goto out; goto out;
pr_info("WARN: Maps only in vmlinux:\n"); header_printed = false;
for (map = maps__first(maps); map; map = map__next(map)) { for (map = maps__first(maps); map; map = map__next(map)) {
struct map * struct map *
...@@ -192,13 +193,18 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused) ...@@ -192,13 +193,18 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
(map->dso->kernel ? (map->dso->kernel ?
map->dso->short_name : map->dso->short_name :
map->dso->name)); map->dso->name));
if (pair) if (pair) {
pair->priv = 1; pair->priv = 1;
else } else {
if (!header_printed) {
pr_info("WARN: Maps only in vmlinux:\n");
header_printed = true;
}
map__fprintf(map, stderr); map__fprintf(map, stderr);
} }
}
pr_info("WARN: Maps in vmlinux with a different name in kallsyms:\n"); header_printed = false;
for (map = maps__first(maps); map; map = map__next(map)) { for (map = maps__first(maps); map; map = map__next(map)) {
struct map *pair; struct map *pair;
...@@ -211,7 +217,11 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused) ...@@ -211,7 +217,11 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
continue; continue;
if (pair->start == mem_start) { if (pair->start == mem_start) {
pair->priv = 1; if (!header_printed) {
pr_info("WARN: Maps in vmlinux with a different name in kallsyms:\n");
header_printed = true;
}
pr_info("WARN: %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as", pr_info("WARN: %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s in kallsyms as",
map->start, map->end, map->pgoff, map->dso->name); map->start, map->end, map->pgoff, map->dso->name);
if (mem_end != pair->end) if (mem_end != pair->end)
...@@ -222,14 +232,19 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused) ...@@ -222,14 +232,19 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
} }
} }
pr_info("WARN: Maps only in kallsyms:\n"); header_printed = false;
maps = &kallsyms.kmaps.maps[type]; maps = &kallsyms.kmaps.maps[type];
for (map = maps__first(maps); map; map = map__next(map)) { for (map = maps__first(maps); map; map = map__next(map)) {
if (!map->priv) if (!map->priv) {
if (!header_printed) {
pr_info("WARN: Maps only in kallsyms:\n");
header_printed = true;
}
map__fprintf(map, stderr); map__fprintf(map, stderr);
} }
}
out: out:
machine__exit(&kallsyms); machine__exit(&kallsyms);
machine__exit(&vmlinux); machine__exit(&vmlinux);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment