From patchwork Wed May 2 22:51:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 27074 Received: (qmail 106875 invoked by alias); 2 May 2018 22:51:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 106861 invoked by uid 89); 2 May 2018 22:51:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=toward, Hx-languages-length:2108, sea X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 May 2018 22:51:10 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CACB401DEBD; Wed, 2 May 2018 22:51:08 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF042022DE3; Wed, 2 May 2018 22:51:07 +0000 (UTC) Subject: Re: [PATCH 00/40] C++ify target_ops, toward multi-target To: Simon Marchi , gdb-patches@sourceware.org References: <20180414190953.24481-1-palves@redhat.com> <968579be-9689-d39a-8965-063ff97a4a13@simark.ca> From: Pedro Alves Message-ID: Date: Wed, 2 May 2018 23:51:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <968579be-9689-d39a-8965-063ff97a4a13@simark.ca> On 04/29/2018 04:22 PM, Simon Marchi wrote: > On 2018-04-14 03:09 PM, Pedro Alves wrote: >> Here's another chunk from the multi-target branch. > > Hi Pedro, > > It's kind of difficult to properly review this series, because the important > non-mechanical bits are lost in a sea of mechanical changes. Yeah, sorry about that. > But I didn't > find anything fundamental I would change, and all you wrote in commit logs > made sense to me. > > Maybe one little comment about 40/40 (because I just finished looking at that > patch): it might be good to add an assertion (the_native_target == nullptr) > in set_native_target and one in add_target > (target_factories.find (&t) == target_factories.end ()). I think it could > help catch problems if somebody is trying to add a new target or change > existing ones. Good idea. I'm adding this to patch #40: gdb/target.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) > Otherwise, I would suggest not waiting too long before merging it to > avoid having to resolve too many conflicts. Thanks a lot for doing this! Alright, I wrote the missing ChangeLogs today, and will proceed with squashing the patches that need to be squashed and getting it all in. Thanks, Pedro Alves diff --git a/gdb/target.c b/gdb/target.c index b957769a3f..824855e7df 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -352,7 +352,11 @@ add_target (const target_info &t, target_open_ftype *func, { struct cmd_list_element *c; - target_factories[&t] = func; + auto &func_slot = target_factories[&t]; + if (func_slot != nullptr) + internal_error (__FILE__, __LINE__, + "target already added (\"%s\").", t.shortname); + func_slot = func; if (targetlist == NULL) add_prefix_cmd ("target", class_run, target_command, _("\ @@ -2447,6 +2451,11 @@ static target_ops *the_native_target; void set_native_target (target_ops *target) { + if (the_native_target != NULL) + internal_error (__FILE__, __LINE__, + _("native target already set (\"%s\")."), + the_native_target->longname ()); + the_native_target = target; }