From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 720CD3850407 for ; Mon, 28 Sep 2020 19:10:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 720CD3850407 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 898851E58E; Mon, 28 Sep 2020 15:10:23 -0400 (EDT) Subject: Re: [PATCH] arc: Add support for Linux coredump files To: "Aktemur, Tankut Baris" , Shahab Vahedi Cc: "gdb-patches@sourceware.org" , Anton Kolesov , Shahab Vahedi , Francois Bedard References: <20200827112728.4275-1-shahab.vahedi@gmail.com> <18b98a56-e3cf-e05b-49a7-bd6e1f61aefb@simark.ca> <20200928134714.GA4717@gmail.com> From: Simon Marchi Message-ID: Date: Mon, 28 Sep 2020 15:10:23 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, 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, 28 Sep 2020 19:10:25 -0000 On 2020-09-28 10:08 a.m., Aktemur, Tankut Baris wrote: > Hi Shahab, > > On Monday, September 28, 2020 3:47 PM, Shahab Vahedi wrote: >> Hi Baris, >> >> On Thu, Sep 17, 2020 at 11:55:42AM +0000, Aktemur, Tankut Baris wrote: >>>> On 2020-08-27 7:27 a.m., Shahab Vahedi via Gdb-patches wrote: >>>> +bool >>>> +arc_target::low_breakpoint_at (CORE_ADDR where) >>>> +{ >>>> + uint16_t insn; >>>> + uint16_t breakpoint = ntohs (TRAP_S_1_OPCODE); >>>> + >>>> + the_target->read_memory (where, (gdb_byte *) &insn, TRAP_S_1_SIZE); >>> >>> Because 'the_target' is the same as 'this', you may want to simply call >>> 'read_memory' without explicitly stating the receiver object. This way, >>> accessing the global variable could be avoided. >> >> Thank you very much for your input, but since it is not very obvious to >> me where/when the "the_target" is initialized, I'd rather keep it this >> way. Specially seeing that other targets (ARM and RISCV) doing the same. >> >> >> Cheers, >> Shahab > > Just for the record, there are similar uses in linux-aarch32-low.cc, > linux-arm-low.cc, linux-low.cc, linux-sparc-low.cc, and win32-low.cc (I don't > see it in linux-riscv-low.cc), and in all of these uses the context is a function > (not a method) where the 'this' pointer is not available. > > Regards > -Baris FWIW, I'm leaning towards what Baris says, better use "this" than the global variable. And I even prefer to make it explicit, "this->read_memory (...", to make it clear that we call a method and not a free function. But I don't want to start an endless discussion about coding style :). Simon