From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by sourceware.org (Postfix) with ESMTPS id A7860386F83F for ; Mon, 14 Sep 2020 09:40:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A7860386F83F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=undo.io Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mbarisione@undo.io Received: by mail-wm1-x341.google.com with SMTP id q9so9950444wmj.2 for ; Mon, 14 Sep 2020 02:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=undo-io.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=w9YwqJd5SSdrI24pxdwjZRtCAhrfMuLoD9f3McdZcR0=; b=VPFFMz8MjvJqAUf+rPCI9UPyIzfLJ6csu+BTnoMTfi7AVEcf0XF80b1TdauDK78iAT 5cGaRtLV1IFdSCd7HHmmnPoun2CrUIrWzGhj6IwlQimzX9JM4ThiusutgHtwlBNAyQCR mTezKZjd4RQJ6+/w2Z9DmRiFdSt7U8DOdY4gJ7Ys89H/EiK99PQ8ylj6HYhA/ENU79Th tby2urntZ8Q9oBZ08lzyqR9G/XEUHOVsYBeoCkFnOa7usddQ8aE9h51ktvJBHmbV4AFa 1Yw6zUo8ZSFQFnR/kEOct7dobfC4s0fD5GJw86ULAXvmkpByIw+aBzI9jl6ElUDqjvyy I4QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w9YwqJd5SSdrI24pxdwjZRtCAhrfMuLoD9f3McdZcR0=; b=DBbX4gO4zk1gptM8pq8y4plCWXMNoTLtPc26kSaM4PSSRmm7fOJeMw065IphC7XCqp 7rbyo9rDpvHIUpxtmy8HhBMX6VW7+PbHeFm+0aKBA/5KAs1XFSzg/Q725S+Jv2CZJiUs VxA/v/9sILMRV7ULY64tz4KRjObsqn3HVuUGmBocHCdIzkf7Ix4Oy7O2rxAvnTjiCiyy CW8Ze3r+B4B2PzyiBcRV1QI/WMup6J2CBffk/WE64IqO8nd+ZGzJnJDRBC3t3JAYzytg nPrxSIG9C6i/LArk0tJIgnWH7AiHtKFI4nvf75TetRBM1CzhkUgGZBeqfdi83dRLRv2y UHug== X-Gm-Message-State: AOAM5314nZc6nVV75HcxW5RBnoRNfV7jJwFE3eDhjr/D/qMhCfPiX68+ LwJkPsfOHW8OjFZvETRdXKFyMwVzLcuDBEzbC7MyArlzw5IhwJbEQS2OMj+lGaanYn6IBnNogF4 VHqgw+mJT2DC7ymmAExbJ1i7m5Cw57+/6j8h1SEvhbcAD0LHqQNJaUGtfA4rnxrG3MswsyiCRiQ == X-Google-Smtp-Source: ABdhPJwpR6UGAW4DendFkVR8+0vRO1Z31wOnWcMBrhDTVY1gE/lL5ZeDQxvny4nDGSazpLG+oj532Q== X-Received: by 2002:a05:600c:214e:: with SMTP id v14mr14821040wml.118.1600076401311; Mon, 14 Sep 2020 02:40:01 -0700 (PDT) Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust117.5-4.cable.virginm.net. [81.111.29.118]) by smtp.gmail.com with ESMTPSA id q4sm21455375wru.65.2020.09.14.02.40.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 02:40:00 -0700 (PDT) From: Marco Barisione To: gdb-patches@sourceware.org Subject: [PATCH 1/2] Move the code to execute a cmd_list_element out from execute_command Date: Mon, 14 Sep 2020 09:39:24 +0000 Message-Id: <20200914093925.5442-2-mbarisione@undo.io> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200914093925.5442-1-mbarisione@undo.io> References: <20200914093925.5442-1-mbarisione@undo.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2020 09:40:04 -0000 gdb/ChangeLog: * gdbcmd.h (execute_cmd_list_command): Add declaration. * top.c (execute_command): Move out the code to execute a command from a cmd_list_element. (execute_cmd_list_command): Add from code originally in execute_command. * top.h (execute_cmd_list_command): Add declaration. --- gdb/gdbcmd.h | 3 +++ gdb/top.c | 66 ++++++++++++++++++++++++++++++---------------------- gdb/top.h | 2 ++ 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h index 4406094ea5..5be474ec1a 100644 --- a/gdb/gdbcmd.h +++ b/gdb/gdbcmd.h @@ -134,6 +134,9 @@ extern struct cmd_list_element *save_cmdlist; extern void execute_command (const char *, int); +extern void execute_cmd_list_command (struct cmd_list_element *, + const char *, int); + /* Execute command P and returns its output. If TERM_OUT, the output is built using terminal output behaviour such as cli_styling. */ diff --git a/gdb/top.c b/gdb/top.c index acd31afb9a..8eae15a488 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -581,7 +581,6 @@ execute_command (const char *p, int from_tty) const char *arg; std::string default_args; std::string default_args_and_arg; - int was_sync = current_ui->prompt_state == PROMPT_BLOCKED; line = p; @@ -641,33 +640,7 @@ execute_command (const char *p, int from_tty) if (c->deprecated_warn_user) deprecated_cmd_warning (line); - /* c->user_commands would be NULL in the case of a python command. */ - if (c->theclass == class_user && c->user_commands) - execute_user_command (c, arg); - else if (c->theclass == class_user - && c->prefixlist && !c->allow_unknown) - /* If this is a user defined prefix that does not allow unknown - (in other words, C is a prefix command and not a command - that can be followed by its args), report the list of - subcommands. */ - { - printf_unfiltered - ("\"%.*s\" must be followed by the name of a subcommand.\n", - (int) strlen (c->prefixname) - 1, c->prefixname); - help_list (*c->prefixlist, c->prefixname, all_commands, gdb_stdout); - } - else if (c->type == set_cmd) - do_set_command (arg, from_tty, c); - else if (c->type == show_cmd) - do_show_command (arg, from_tty, c); - else if (!cmd_func_p (c)) - error (_("That is not a command, just a help topic.")); - else if (deprecated_call_command_hook) - deprecated_call_command_hook (c, arg, from_tty); - else - cmd_func (c, arg, from_tty); - - maybe_wait_sync_command_done (was_sync); + execute_cmd_list_command (c, arg, from_tty); /* If this command has been post-hooked, run the hook last. */ execute_cmd_post_hook (c); @@ -690,6 +663,43 @@ execute_command (const char *p, int from_tty) cleanup_if_error.release (); } +/* Execute the C command. */ + +void +execute_cmd_list_command (struct cmd_list_element *c, const char *arg, + int from_tty) +{ + bool was_sync = current_ui->prompt_state == PROMPT_BLOCKED; + + /* c->user_commands would be NULL in the case of a python command. */ + if (c->theclass == class_user && c->user_commands) + execute_user_command (c, arg); + else if (c->theclass == class_user + && c->prefixlist && !c->allow_unknown) + { + /* If this is a user defined prefix that does not allow unknown + (in other words, C is a prefix command and not a command + that can be followed by its args), report the list of + subcommands. */ + printf_unfiltered + ("\"%.*s\" must be followed by the name of a subcommand.\n", + (int) strlen (c->prefixname) - 1, c->prefixname); + help_list (*c->prefixlist, c->prefixname, all_commands, gdb_stdout); + } + else if (c->type == set_cmd) + do_set_command (arg, from_tty, c); + else if (c->type == show_cmd) + do_show_command (arg, from_tty, c); + else if (!cmd_func_p (c)) + error (_("That is not a command, just a help topic.")); + else if (deprecated_call_command_hook) + deprecated_call_command_hook (c, arg, from_tty); + else + cmd_func (c, arg, from_tty); + + maybe_wait_sync_command_done (was_sync); +} + /* Run execute_command for P and FROM_TTY. Sends its output to FILE, do not display it to the screen. BATCH_FLAG will be temporarily set to true. */ diff --git a/gdb/top.h b/gdb/top.h index fd99297715..ba6c596da7 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -241,6 +241,8 @@ extern void quit_force (int *, int); extern void quit_command (const char *, int); extern void quit_cover (void); extern void execute_command (const char *, int); +extern void execute_cmd_list_command (struct cmd_list_element *, + const char *, int); /* If the interpreter is in sync mode (we're running a user command's list, running command hooks or similars), and we just ran a -- 2.20.1