Commit 2d4f2799 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

perf data: Add global path holder



Add a 'path' member to 'struct perf_data'. It will keep the configured
path for the data (const char *). The path in struct perf_data_file is
now dynamically allocated (duped) from it.

This scheme is useful/used in following patches where struct
perf_data::path holds the 'configure' directory path and struct
perf_data_file::path holds the allocated path for specific files.

Also it actually makes the code little simpler.

Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190221094145.9151-3-jolsa@kernel.org


[ Fixup data-convert-bt.c missing conversion ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 45112e89
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -441,7 +441,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
	}

	if (total_nr_samples == 0) {
		ui__error("The %s file has no samples!\n", session->data->file.path);
		ui__error("The %s data has no samples!\n", session->data->path);
		goto out;
	}

@@ -578,7 +578,7 @@ int cmd_annotate(int argc, const char **argv)
	if (quiet)
		perf_quiet_option();

	data.file.path = input_name;
	data.path = input_name;

	annotate.session = perf_session__new(&data, false, &annotate.tool);
	if (annotate.session == NULL)
+2 −2
Original line number Diff line number Diff line
@@ -416,7 +416,7 @@ int cmd_buildid_cache(int argc, const char **argv)
		nsi = nsinfo__new(ns_id);

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

		session = perf_session__new(&data, false, NULL);
+3 −5
Original line number Diff line number Diff line
@@ -52,9 +52,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
{
	struct perf_session *session;
	struct perf_data data = {
		.file      = {
		.path  = input_name,
		},
		.mode  = PERF_DATA_MODE_READ,
		.force = force,
	};
+2 −2
Original line number Diff line number Diff line
@@ -2750,7 +2750,7 @@ static int perf_c2c__report(int argc, const char **argv)
	if (!input_name || !strlen(input_name))
		input_name = "perf.data";

	data.file.path = input_name;
	data.path  = input_name;
	data.force = symbol_conf.force;

	err = setup_display(display);
+6 −6
Original line number Diff line number Diff line
@@ -708,7 +708,7 @@ static void data__fprintf(void)

	data__for_each_file(i, d)
		fprintf(stdout, "#  [%d] %s %s\n",
			d->idx, d->data.file.path,
			d->idx, d->data.path,
			!d->idx ? "(Baseline)" : "");

	fprintf(stdout, "#\n");
@@ -779,14 +779,14 @@ static int __cmd_diff(void)
	data__for_each_file(i, d) {
		d->session = perf_session__new(&d->data, false, &tool);
		if (!d->session) {
			pr_err("Failed to open %s\n", d->data.file.path);
			pr_err("Failed to open %s\n", d->data.path);
			ret = -1;
			goto out_delete;
		}

		ret = perf_session__process_events(d->session);
		if (ret) {
			pr_err("Failed to process %s\n", d->data.file.path);
			pr_err("Failed to process %s\n", d->data.path);
			goto out_delete;
		}

@@ -1289,7 +1289,7 @@ static int data_init(int argc, const char **argv)
	data__for_each_file(i, d) {
		struct perf_data *data = &d->data;

		data->file.path = use_default ? defaults[i] : argv[i];
		data->path  = use_default ? defaults[i] : argv[i];
		data->mode  = PERF_DATA_MODE_READ,
		data->force = force,

Loading