Skip to content

Commit

Permalink
perf buildid-cache: Move session handling into cmd_buildid_cache()
Browse files Browse the repository at this point in the history
This is a preparation of fixing dso__load_kernel_sym().  It needs a
session info before calling symbol__init().

Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1407825645-24586-5-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Aug 13, 2014
1 parent fa10f31 commit e3ed75b
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions tools/perf/builtin-buildid-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,9 @@ static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused)
return true;
}

static int build_id_cache__fprintf_missing(const char *filename, bool force, FILE *fp)
static int build_id_cache__fprintf_missing(struct perf_session *session, FILE *fp)
{
struct perf_data_file file = {
.path = filename,
.mode = PERF_DATA_MODE_READ,
.force = force,
};
struct perf_session *session = perf_session__new(&file, false, NULL);
if (session == NULL)
return -1;

perf_session__fprintf_dsos_buildid(session, fp, dso__missing_buildid_cache, 0);
perf_session__delete(session);

return 0;
}

Expand Down Expand Up @@ -303,6 +292,11 @@ int cmd_buildid_cache(int argc, const char **argv,
*update_name_list_str = NULL,
*kcore_filename;

struct perf_data_file file = {
.mode = PERF_DATA_MODE_READ,
};
struct perf_session *session = NULL;

const struct option buildid_cache_options[] = {
OPT_STRING('a', "add", &add_name_list_str,
"file list", "file(s) to add"),
Expand All @@ -326,8 +320,17 @@ int cmd_buildid_cache(int argc, const char **argv,
argc = parse_options(argc, argv, buildid_cache_options,
buildid_cache_usage, 0);

if (missing_filename) {
file.path = missing_filename;
file.force = force;

session = perf_session__new(&file, false, NULL);
if (session == NULL)
return -1;
}

if (symbol__init() < 0)
return -1;
goto out;

setup_pager();

Expand Down Expand Up @@ -370,7 +373,7 @@ int cmd_buildid_cache(int argc, const char **argv,
}

if (missing_filename)
ret = build_id_cache__fprintf_missing(missing_filename, force, stdout);
ret = build_id_cache__fprintf_missing(session, stdout);

if (update_name_list_str) {
list = strlist__new(true, update_name_list_str);
Expand All @@ -394,5 +397,9 @@ int cmd_buildid_cache(int argc, const char **argv,
build_id_cache__add_kcore(kcore_filename, debugdir, force))
pr_warning("Couldn't add %s\n", kcore_filename);

out:
if (session)
perf_session__delete(session);

return ret;
}

0 comments on commit e3ed75b

Please sign in to comment.