From: Gabriele Monaco <gmonaco@redhat.com>
To: Nam Cao <namcao@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Wander Lairson Costa <wander@redhat.com>,
linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 10/13] verification/rvgen: Switch __get_event_variables() to Lark
Date: Wed, 10 Jun 2026 17:04:49 +0200 [thread overview]
Message-ID: <1a32dd83a1a667dadc6eeea3722a9b1b8b9e9101.camel@redhat.com> (raw)
In-Reply-To: <50df4dd278779328cf2aa283c8353bac2281a337.1780908661.git.namcao@linutronix.de>
On Mon, 2026-06-08 at 10:57 +0200, Nam Cao wrote:
> Switch __get_event_variables() to use the parsed results from Lark,
> instead
> of raw text processing.
>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>
> ---
> tools/verification/rvgen/rvgen/automata.py | 78 ++++++--------------
> --
> 1 file changed, 19 insertions(+), 59 deletions(-)
>
> diff --git a/tools/verification/rvgen/rvgen/automata.py
> b/tools/verification/rvgen/rvgen/automata.py
> index b86275e7bf28..2e26bb863245 100644
> --- a/tools/verification/rvgen/rvgen/automata.py
> +++ b/tools/verification/rvgen/rvgen/automata.py
> @@ -591,45 +591,22 @@ class Automata:
> def __get_event_variables(self) -> tuple[list[str], list[str]]:
> events: list[str] = []
> envs: list[str] = []
> - # here we are at the begin of transitions, take a note, we
> will return later.
> - cursor = self.__get_cursor_begin_events()
>
> - for line in map(str.lstrip, islice(self.__dot_lines, cursor,
> None)):
> - if not line.startswith('"'):
> - break
> + for transition in self.transitions:
> + events.append(transition.event)
>
> - # transitions have the format:
> - # "all_fired" -> "both_fired" [ label = "disable_irq" ];
> - # ------------ event is here ------------^^^^^
> - split_line = line.split()
> - if len(split_line) > 1 and split_line[1] == "->":
> - event = "".join(split_line[split_line.index("label")
> + 2:-1]).replace('"', '')
> -
> - # when a transition has more than one label, they
> are like this
> - # "local_irq_enable\nhw_local_irq_enable_n"
> - # so split them.
> -
> - for i in event.split("\\n"):
> - # if the event contains a constraint (hybrid
> automata),
> - # it will be separated by a ";":
> - # "sched_switch;x<1000;reset(x)"
> - ev, *constr = i.split(";")
> - if constr:
> - if len(constr) > 2:
> - raise AutomataError("Only 1 constraint
> and 1 reset are supported")
> - envs += self.__extract_env_var(constr)
> - events.append(ev)
> - else:
> - # state labels have the format:
> - # "enable_fired" [label =
> "enable_fired\ncondition"];
> - # ----- label is here -----^^^^^
> - # label and node name must be the same, condition is
> optional
> - state = line.split("label")[1].split('"')[1]
> - _, *constr = state.split("\\n")
> - if constr:
> - if len(constr) > 1:
> - raise AutomataError("Only 1 constraint is
> supported in the state")
> - envs +=
> self.__extract_env_var([constr[0].replace(" ", "")])
> + if transition.reset:
> + envs.append(transition.reset.env)
> + self.env_stored.add(transition.reset.env)
> + if transition.rule:
> + for c, _ in transition.rule.rules:
> + envs.append(c.env)
> + self.__extract_env_var(c)
> +
> + for state in self._states:
> + if state.inv:
> + envs.append(state.inv.env)
> + self.__extract_env_var(state.inv)
>
> return sorted(set(events)), sorted(set(envs))
>
> @@ -653,28 +630,11 @@ class Automata:
> seps.append(None)
> return zip(exprs, seps)
>
> - def __extract_env_var(self, constraint: list[str]) -> list[str]:
> - env = []
> - for c, _ in self._split_constraint_expr(constraint):
> - rule = self.constraint_rule.search(c)
> - reset = self.constraint_reset.search(c)
> - if rule:
> - env.append(rule["env"])
> - if rule.groupdict().get("unit"):
> - self.env_types[rule["env"]] = rule["unit"]
> - if rule["val"][0].isalpha():
> - self.constraint_vars.add(rule["val"])
> - # try to infer unit from constants or parameters
> - val_for_unit = rule["val"].lower().replace("()", "")
> - if val_for_unit.endswith("_ns"):
> - self.env_types[rule["env"]] = "ns"
> - if val_for_unit.endswith("_jiffies"):
> - self.env_types[rule["env"]] = "j"
> - if reset:
> - env.append(reset["env"])
> - # environment variables that are reset need a
> storage
> - self.env_stored.add(reset["env"])
> - return env
> + def __extract_env_var(self, constraint: ConstraintCondition):
> + if constraint.unit:
> + self.env_types[constraint.env] = constraint.unit
> + if constraint.val[0].isalpha():
> + self.constraint_vars.add(constraint.val)
>
> def __create_matrix(self) -> tuple[list[list[str]],
> dict[_ConstraintKey, list[str]]]:
> # transform the array into a dictionary
next prev parent reply other threads:[~2026-06-10 15:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 8:56 [PATCH v3 00/13] rv: Convert rvgen " Nam Cao
2026-06-08 8:56 ` [PATCH v3 01/13] verification/rvgen: Switch LTL parser " Nam Cao
2026-06-08 8:56 ` [PATCH v3 02/13] verification/rvgen: Introduce a parse tree for automata using Lark Nam Cao
2026-06-08 8:56 ` [PATCH v3 03/13] verification/rvgen: Implement state and transition parser based on Lark Nam Cao
2026-06-09 12:54 ` Gabriele Monaco
2026-06-09 13:23 ` Gabriele Monaco
2026-06-08 8:57 ` [PATCH v3 04/13] verification/rvgen: Convert __fill_verify_invariants_func() to Lark Nam Cao
2026-06-08 8:57 ` [PATCH v3 05/13] verification/rvgen: Convert __fill_setup_invariants_func() " Nam Cao
2026-06-09 12:39 ` Gabriele Monaco
2026-06-16 9:00 ` Nam Cao
2026-06-08 8:57 ` [PATCH v3 06/13] verification/rvgen: Convert __fill_verify_guards_func() " Nam Cao
2026-06-08 8:57 ` [PATCH v3 07/13] rv: Simplify hybrid automata monitors's clock variables Nam Cao
2026-06-08 8:57 ` [PATCH v3 08/13] verification/rvgen: Simplify the generation for " Nam Cao
2026-06-11 8:39 ` Gabriele Monaco
2026-06-08 8:57 ` [PATCH v3 09/13] verification/rvgen: Delete __parse_constraint() Nam Cao
2026-06-10 15:04 ` Gabriele Monaco
2026-06-17 9:59 ` Nam Cao
2026-06-18 8:13 ` Gabriele Monaco
2026-06-18 13:24 ` Nam Cao
2026-06-08 8:57 ` [PATCH v3 10/13] verification/rvgen: Switch __get_event_variables() to Lark Nam Cao
2026-06-10 15:04 ` Gabriele Monaco [this message]
2026-06-08 8:57 ` [PATCH v3 11/13] verification/rvgen: Switch __create_matrix() " Nam Cao
2026-06-10 15:05 ` Gabriele Monaco
2026-06-08 8:57 ` [PATCH v3 12/13] verification/rvgen: Remove the old state variables Nam Cao
2026-06-10 15:06 ` Gabriele Monaco
2026-06-08 8:57 ` [PATCH v3 13/13] verification/rvgen: Remove dead code Nam Cao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a32dd83a1a667dadc6eeea3722a9b1b8b9e9101.camel@redhat.com \
--to=gmonaco@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=namcao@linutronix.de \
--cc=rostedt@goodmis.org \
--cc=wander@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®