perf parse-events: Fixes relating to no_value terms

A term may have no value in which case it is assumed to have a value
of 1. It doesn't just apply to alias/event terms so change the
parse_events_term__to_strbuf assert.

Commit 99e7138eb7897aa0 ("perf tools: Fail on using multiple bits long
terms without value") made it so that no_value terms could only be for a
single bit. Prior to commit 64199ae4b8a3 ("perf parse-events: Fix
propagation of term's no_value when cloning") this missed a test case
where config1 had no_value.

Fixes: 64199ae4b8a36038 ("perf parse-events: Fix propagation of term's no_value when cloning")
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230901233949.2930562-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by Ian Rogers and committed by Arnaldo Carvalho de Melo 9ea150a8 64199ae4

Changed files
+4 -4
tools
+1 -1
tools/perf/tests/parse-events.c
··· 2170 2170 2171 2171 static const struct evlist_test test__events_pmu[] = { 2172 2172 { 2173 - .name = "cpu/config=10,config1,config2=3,period=1000/u", 2173 + .name = "cpu/config=10,config1=1,config2=3,period=1000/u", 2174 2174 .valid = test__pmu_cpu_valid, 2175 2175 .check = test__checkevent_pmu, 2176 2176 /* 0 */
+1 -1
tools/perf/util/parse-events.c
··· 2607 2607 2608 2608 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) 2609 2609 if (term->no_value) { 2610 - assert(term->type_term == PARSE_EVENTS__TERM_TYPE_USER); 2610 + assert(term->val.num == 1); 2611 2611 ret = strbuf_addf(sb, "%s", term->config); 2612 2612 } else 2613 2613 ret = strbuf_addf(sb, "%s=%#"PRIx64, term->config, term->val.num);
+2 -2
tools/perf/util/parse-events.h
··· 124 124 */ 125 125 bool weak; 126 126 /** 127 - * @no_value: Is there no value. TODO: this should really be part of 128 - * type_val. 127 + * @no_value: Is there no value. If a numeric term has no value then the 128 + * value is assumed to be 1. An event name also has no value. 129 129 */ 130 130 bool no_value; 131 131 };