From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ABJsLO0u+F+2JwAAWB0awg (envelope-from ) for ; Fri, 08 Jan 2021 05:07:41 -0500 Received: by simark.ca (Postfix, from userid 112) id 6508F1E99A; Fri, 8 Jan 2021 05:07:40 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 07C961E4F4; Fri, 8 Jan 2021 05:07:40 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACD0C384A01A; Fri, 8 Jan 2021 10:07:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACD0C384A01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610100459; bh=BZNl8nJyB4vzlfXOI0yZQ1Awg0QERRYp1xKWthIGQA0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yix57uG6hR0Zvq1sukMaH4mfNbfIM8dZ0KLw56zvXwRLZzHmIJJV4tNT4JZgT5tFH 0mJ/HkY+vSvAx0tHpM27xopRC/Rh6f2CfoBByUU/758ttntPjh1R97OEEqHb7aZXk9 c0iSHj9+d0VtSEiSw5VJmWQEqN3Q+G+ab70HS2uk= Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 42F3C397301D for ; Fri, 8 Jan 2021 10:07:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 42F3C397301D Received: by mail-wr1-x431.google.com with SMTP id q18so8452108wrn.1 for ; Fri, 08 Jan 2021 02:07:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BZNl8nJyB4vzlfXOI0yZQ1Awg0QERRYp1xKWthIGQA0=; b=tQvlzcRzWCDokrhw0NlwWOU7nz01seRJZaJae7AkRAC6ocm9HhbZWwcaK73/ihrCgP txwmHpxPzrZRN0jFsOe6ULuKv9o1s1WflBg1XUE3vGqfRJ4xd95MTswAUcYUPdZQSE8M jigAdkug2/MO8Npw3ZfWe+gx5JsWlnhug9/eF0zENbnqheM8fMxeljU4EGp2EPIIz5cg W1DXUQnbbcfSIoS5iohlaP9YRlMywD0MLE6ySuoUTCr2C3S+Hqyam0mWRVV2D463CQiG HCJWBk2vx1PnWW9TvInmNXoE2PQmZs02PkKyP7vFWQKxfUoxm7laN5YZFwHxb4KSgwh2 fyoQ== X-Gm-Message-State: AOAM532H0FPd0qlwbUV+A6s9l/R72IGMQiyBh4VchCorhMMDy5DcmEs5 1L69XzyVIohRPC1VFTdnGI3ohIJqbamS8Q3Qk0VjswwcWD5FTlEW/nOnrRQ5vZGsDSMmTgMWDp6 Xc7hPB8k1IUAuNLY6xAEgl/QCubVb7i1oTFYT1lgbHfOdeTfOgc/vlX/n6+p9cPM8t9+eSDfAx7 Zq X-Google-Smtp-Source: ABdhPJwnU5693Xtty/VELG7R1u8iiCG4fP1m7bPgARnIHWhQ/7SE2NcyZZ5uv4j5Bb/5WPsPMEb4NQ== X-Received: by 2002:adf:c64f:: with SMTP id u15mr2781688wrg.270.1610100454950; Fri, 08 Jan 2021 02:07:34 -0800 (PST) Received: from focaccia.undoers.io (cpc159317-cmbg20-2-0-cust151.5-4.cable.virginm.net. [81.111.29.152]) by smtp.gmail.com with ESMTPSA id s205sm11579143wmf.46.2021.01.08.02.07.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jan 2021 02:07:34 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH 3/4] gdb: update the docs for add_cmd and do_add_cmd to match reality Date: Fri, 8 Jan 2021 10:07:05 +0000 Message-Id: <20210108100706.96190-4-mbarisione@undo.io> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210108100706.96190-1-mbarisione@undo.io> References: <20210108100706.96190-1-mbarisione@undo.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: Marco Barisione via Gdb-patches Reply-To: Marco Barisione Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" It looks like the docs for add_cmd ended up being the docs for do_add_cmd. Moreover, they were outdated. gdb/ChangeLog: * cli/cli-decode.c (do_add_cmd): Remove outdated documentation and refer to the documentation for add_cmd. (add_cmd): Add comment referring to the docs in command.h. * command.h (add_cmd): Add updated documentation. --- gdb/cli/cli-decode.c | 22 +++++----------------- gdb/command.h | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 87785107e3d..a25e3f420b3 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -160,23 +160,7 @@ set_cmd_completer_handle_brkchars (struct cmd_list_element *cmd, cmd->completer_handle_brkchars = func; } -/* Add element named NAME. - Space for NAME and DOC must be allocated by the caller. - CLASS is the top level category into which commands are broken down - for "help" purposes. - FUN should be the function to execute the command; - it will get a character string as argument, with leading - and trailing blanks already eliminated. - - DOC is a documentation string for the command. - Its first line should be a complete sentence. - It should start with ? for a command that is an abbreviation - or with * for a command that most users don't need to know about. - - Add this command to command list *LIST. - - Returns a pointer to the added command (not necessarily the head - of *LIST). */ +/* Like ADD_CMD, but the command function fields are not modified. */ static struct cmd_list_element * do_add_cmd (const char *name, enum command_class theclass, @@ -227,6 +211,8 @@ do_add_cmd (const char *name, enum command_class theclass, return c; } +/* See command.h. */ + struct cmd_list_element * add_cmd (const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list) @@ -237,6 +223,8 @@ add_cmd (const char *name, enum command_class theclass, return result; } +/* See command.h. */ + struct cmd_list_element * add_cmd (const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, diff --git a/gdb/command.h b/gdb/command.h index 827a19637a2..df40cbf7119 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -155,18 +155,44 @@ extern bool valid_user_defined_cmd_name_p (const char *name); extern bool valid_cmd_char_p (int c); -/* Const-correct variant of the above. */ +/* Add a command named NAME in command list *LIST. -extern struct cmd_list_element *add_cmd (const char *, enum command_class, + NAME and DOC are not duplicated. If they are not static string, they + must have been allocated with xmalloc or xstrdup and the + NAME_ALLOCATED/DOC_ALLOCATED fields must be set to 1 on the returned + command. + + THECLASS is the top level category into which commands are broken down + for "help" purposes. + + FUN should be the function to execute the command; it will get two + arguments, a character string (with leading and trailing blanks already + eliminated) containing the command arguments, and an integer indicating + whether input comes from a TTY or not. + + DOC is a documentation string for the command. + Its first line should be a complete sentence. + It should start with ? for a command that is an abbreviation + or with * for a command that most users don't need to know about. + + If NAME already existed in *LIST, all its hooks and aliases are moved + to the new command. + + Return a pointer to the added command (not necessarily the head of + *LIST). */ + +extern struct cmd_list_element *add_cmd (const char *name, + enum command_class theclass, cmd_const_cfunc_ftype *fun, - const char *, - struct cmd_list_element **); + const char *doc, + struct cmd_list_element **list); /* Like add_cmd, but no command function is specified. */ -extern struct cmd_list_element *add_cmd (const char *, enum command_class, - const char *, - struct cmd_list_element **); +extern struct cmd_list_element *add_cmd (const char *name, + enum command_class theclass, + const char *doc, + struct cmd_list_element **list); extern struct cmd_list_element *add_cmd_suppress_notification (const char *name, enum command_class theclass, -- 2.28.0