Commit a6d9de84 authored by Jin Yao's avatar Jin Yao Committed by Arnaldo Carvalho de Melo
Browse files

perf mem: Fix wrong verbose output for recording events



Current code:

for (j = 0; j < argc; j++, i++)
        rec_argv[i] = argv[j];

if (verbose > 0) {
        pr_debug("calling: record ");

        while (rec_argv[j]) {
                pr_debug("%s ", rec_argv[j]);
                j++;
        }
        pr_debug("\n");
}

The entries of argv[] are copied to the end of rec_argv[], not
copied to the beginning of rec_argv[]. So the index j at
rec_argv[] doesn't point to the first event.

Now we record the start index and end index for events in rec_argv[],
and print them if verbose is enabled.

Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210527001610.10553-7-yao.jin@linux.intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4a9086ad
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ static const char * const *record_mem_usage = __usage;
static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
{
	int rec_argc, i = 0, j, tmp_nr = 0;
	int start, end;
	const char **rec_argv;
	char **rec_tmp;
	int ret;
@@ -144,9 +145,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
	if (mem->data_page_size)
		rec_argv[i++] = "--data-page-size";

	start = i;
	ret = perf_mem_events__record_args(rec_argv, &i, rec_tmp, &tmp_nr);
	if (ret)
		goto out;
	end = i;

	if (all_user)
		rec_argv[i++] = "--all-user";
@@ -160,10 +163,9 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
	if (verbose > 0) {
		pr_debug("calling: record ");

		while (rec_argv[j]) {
		for (j = start; j < end; j++)
			pr_debug("%s ", rec_argv[j]);
			j++;
		}

		pr_debug("\n");
	}