From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15052 invoked by alias); 3 May 2019 22:40:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 14999 invoked by uid 89); 3 May 2019 22:40:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 May 2019 22:40:24 +0000 Received: from [172.16.0.120] (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 84D011E180; Fri, 3 May 2019 18:40:22 -0400 (EDT) Subject: Re: [RFC 1/8] Use std::map for MI commands in mi-cmds.c To: Jan Vrany , gdb-patches@sourceware.org Cc: Didier Nadeau References: <20190418152337.6376-1-jan.vrany@fit.cvut.cz> <20190418152337.6376-2-jan.vrany@fit.cvut.cz> From: Simon Marchi Message-ID: <4cddb376-4e03-4d24-1938-0bd561e03a23@simark.ca> Date: Fri, 03 May 2019 22:40:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190418152337.6376-2-jan.vrany@fit.cvut.cz> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-05/txt/msg00085.txt.bz2 On 2019-04-18 11:23 a.m., Jan Vrany wrote: > @@ -82,7 +82,7 @@ mi_cmd_info_gdb_mi_command (const char *command, char **argv, int argc) > if (cmd_name[0] == '-') > cmd_name++; > > - cmd = mi_lookup (cmd_name); > + cmd = mi_cmd_lookup (cmd_name); > > ui_out_emit_tuple tuple_emitter (uiout, "command"); > uiout->field_string ("exists", cmd != NULL ? "true" : "false"); > diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c > index fe30ac2e82..2b3cf297cf 100644 > --- a/gdb/mi/mi-cmds.c > +++ b/gdb/mi/mi-cmds.c > @@ -22,267 +22,243 @@ > #include "top.h" > #include "mi-cmds.h" > #include "mi-main.h" > +#include > +#include > +#include Is there something that uses ? > +/* Create an mi_cmd structure with name NAME. */ > + > +static mi_cmd_up > +create_mi_cmd (const char *name) > { > - return *lookup_table (command); > + mi_cmd_up cmd (new mi_cmd ()); > + > + cmd->name = name; > + > + return cmd; > } create_mi_cmd could be a constructor to mi_cmd instead. In fact, there could be two constructors of mi_cmd for each version (the mi-based MI commands and the cli-based MI commands), each taking the appropriate parameters. Simon