Re: [PATCH v3 2/2] kdb: Simplify kdb_defcmd macro logic

From: Doug Anderson
Date: Thu May 20 2021 - 13:21:37 EST


Hi,

On Thu, May 13, 2021 at 4:29 AM Sumit Garg <sumit.garg@xxxxxxxxxx> wrote:
>
> Switch to use a linked list instead of dynamic array which makes
> allocation of kdb macro and traversing the kdb macro commands list
> simpler.
>
> Suggested-by: Daniel Thompson <daniel.thompson@xxxxxxxxxx>
> Signed-off-by: Sumit Garg <sumit.garg@xxxxxxxxxx>
> ---
> kernel/debug/kdb/kdb_main.c | 107 +++++++++++++++++++-----------------
> 1 file changed, 58 insertions(+), 49 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index de685b2a8ce7..ce7f4c71992d 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -654,13 +654,16 @@ static void kdb_cmderror(int diag)
> * zero for success, a kdb diagnostic if error
> */
> struct kdb_macro_t {
> - int count;
> - bool usable;
> - kdbtab_t cmd;
> - char **command;
> + kdbtab_t cmd; /* Macro command name */

It's more than just the name, right?


> + struct list_head commands; /* Associated command list */

I get confused between the two different usages of "command". Can we
call the individual entries of a macro "statements". So this would be:

struct list_head statements; /* Associated statement list */

...and the structure below would get renamed as well.

> };
> +
> +struct kdb_macro_cmd_t {
> + char *cmd; /* Command name */

This isn't the "name" of the command, is it? It's the actual statement
that the user entered?


Other than that, this looks like a nice patch to me.


-Doug