From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42436 invoked by alias); 12 Jul 2018 22:18:25 -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 42427 invoked by uid 89); 12 Jul 2018 22:18:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: sesbmg22.ericsson.net Received: from sesbmg22.ericsson.net (HELO sesbmg22.ericsson.net) (193.180.251.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jul 2018 22:18:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1531433900; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7pN98fR+uR8Luyfl/W3Ng5rRTfrFIbeHPO7AODjDmwg=; b=W8K1YRVKyn8lOM38fmftKf/nvWnt29fVtCILnbcAr3iJC8M65BXBW+rfaygWwV/c UIp9my/KzfNdZz0BBy8amj/Kb1nS2lvD7qXt8R8iPiwauuscWoVePQ2DwNwDj8iH py303zL7KQxBSczFVkmnom+T4sgQ5MjX6cp2ic9JMk8=; Received: from ESESBMB505.ericsson.se (Unknown_Domain [153.88.183.118]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id BD.4E.02679.CA3D74B5; Fri, 13 Jul 2018 00:18:20 +0200 (CEST) Received: from ESESBMR503.ericsson.se (153.88.183.135) by ESESBMB505.ericsson.se (153.88.183.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 13 Jul 2018 00:17:45 +0200 Received: from ESESBMB503.ericsson.se (153.88.183.170) by ESESBMR503.ericsson.se (153.88.183.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 13 Jul 2018 00:17:45 +0200 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB503.ericsson.se (153.88.183.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Fri, 13 Jul 2018 00:17:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+otp9Rq1NqJgstEnDs1NUxzDEIhyP9ajsjc5BoT6ehI=; b=BZMAYpasfKC+toYJ6o7UAgOro9RSONMCBjaFJ5GSIr0xLR0uy2Nl4ZY6bqQ3w4+5qgbcc52HmAB77RHzRCzaj3bKLk62YQeSmPjuj7NyDsFqussSQt9U005II0iK6KSnNuYlRRXGIXNnsggYV29ihVG3OISMBABVwGub6iJ9lPk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [142.133.61.147] (192.75.88.130) by SN6PR15MB2399.namprd15.prod.outlook.com (2603:10b6:805:24::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.18; Thu, 12 Jul 2018 22:17:42 +0000 Subject: Re: [RFA 06/13] Remove dead code from m32c-tdep.c To: Tom Tromey , References: <20180712205208.32646-1-tom@tromey.com> <20180712205208.32646-7-tom@tromey.com> From: Simon Marchi Message-ID: <7b6df05d-0a2d-4ec5-7b32-91ba9e919250@ericsson.com> Date: Thu, 12 Jul 2018 22:18:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180712205208.32646-7-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00367.txt.bz2 On 2018-07-12 04:52 PM, Tom Tromey wrote: > This removes some dead code from m32c-tdep.c. I broke this out into a > separate patch because the dead code seemed unusual, as if perhaps it > had not been completed; and so I thought it deserved extra scrutiny. > > gdb/ChangeLog > 2018-07-12 Tom Tromey > > * m32c-tdep.c (mark_dma): Remove. > (make_regs): Remove dead code. > --- > gdb/ChangeLog | 5 +++++ > gdb/m32c-tdep.c | 23 ----------------------- > 2 files changed, 5 insertions(+), 23 deletions(-) > > diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c > index f696568e3a7..6b1d1e83121 100644 > --- a/gdb/m32c-tdep.c > +++ b/gdb/m32c-tdep.c > @@ -689,15 +689,6 @@ mark_general (struct m32c_reg *reg) > } > > > -/* Mark REG as a DMA register, and return it. */ > -static struct m32c_reg * > -mark_dma (struct m32c_reg *reg) > -{ > - reg->dma_p = 1; > - return reg; > -} > - > - > /* Mark REG as a SYSTEM register, and return it. */ > static struct m32c_reg * > mark_system (struct m32c_reg *reg) > @@ -839,20 +830,6 @@ make_regs (struct gdbarch *arch) > struct m32c_reg *pc = G (RC (pc)); > struct m32c_reg *flg = G (R16U (flg)); > > - if (mach == bfd_mach_m32c) > - { > - struct m32c_reg *svf = S (R16U (svf)); > - struct m32c_reg *svp = S (RC (svp)); > - struct m32c_reg *vct = S (RC (vct)); > - > - struct m32c_reg *dmd01 = DMA (RP (dmd, tdep->uint8)); > - struct m32c_reg *dct01 = DMA (RP (dct, tdep->uint16)); > - struct m32c_reg *drc01 = DMA (RP (drc, tdep->uint16)); > - struct m32c_reg *dma01 = DMA (RP (dma, tdep->data_addr_reg_type)); > - struct m32c_reg *dsa01 = DMA (RP (dsa, tdep->data_addr_reg_type)); > - struct m32c_reg *dra01 = DMA (RP (dra, tdep->data_addr_reg_type)); > - } > - > num_raw_regs = tdep->num_regs; > > r0 = G (CB (r0, raw_r0_pair)); > I'm unsure about this one. If you expand the macros, it looks something like this: mark_dma((add_reg (arch, "dmd" "0", tdep->uint8, m32c_sim_reg_dmd0, m32c_raw_read, m32c_raw_write, 0, 0, 0), add_reg (arch, "dmd" "1", tdep->uint8, m32c_sim_reg_dmd1, m32c_raw_read, m32c_raw_write, 0, 0, 0) - 1)) On one hand, the add_reg calls look important to me, because they add registers to the gdbarch_tdep structure, so I would keep them. But the mark_dma call looks really fishy. It only receives the first register, because this expression actually ends up using the "comma" operator, returning the value on the right. A little bit like in this small program: #include int foo(int a) { return a; } int main() { int val = foo((1, 2)); printf("%d\n", val); } $ gcc test.c -Wall test.c: In function ‘main’: test.c:9:19: warning: left-hand operand of comma expression has no effect [-Wunused-value] int val = foo((1, 2)); ^ $ ./a.out 2 And the expression on the right actually returns the first register (because of the -1). So we end up marking only one of the two registers as DMA. I have no idea if that's intended or not. So maybe the safe thing to do would be to make mark_dma return void, and get rid of the local variables and assignments (but keep the DMA(...) calls). Simon