From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IF9GIVvvcl9nPwAAWB0awg (envelope-from ) for ; Tue, 29 Sep 2020 04:24:59 -0400 Received: by simark.ca (Postfix, from userid 112) id 848911E8D0; Tue, 29 Sep 2020 04:24:59 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: ** X-Spam-Status: No, score=2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FSL_HELO_FAKE,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [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 2203C1E58E for ; Tue, 29 Sep 2020 04:24:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 64B66384B010; Tue, 29 Sep 2020 08:24:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64B66384B010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1601367898; bh=08nvkZECyXYv3rEH8l5MeET9Sp3ID06O1wXzQHR2+7o=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UewO6X630San1MIGm5Iqk/diFqwaPTqp0wEH6e8tKbwuSMYqDL7F8kngTwEXdczZl VUMN4JKLNIzb0fucwNp+fV9tFNOTvMiuwjrBAlO23tA/w5hFbprdh5kODJiq6s3VtT MRVGS+UmPKaxgv6YVEyHUJmVcmSVLZM6WNEkySqw= Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by sourceware.org (Postfix) with ESMTPS id 6E4AA384B010 for ; Tue, 29 Sep 2020 08:24:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E4AA384B010 Received: by mail-ej1-x643.google.com with SMTP id i26so13732682ejb.12 for ; Tue, 29 Sep 2020 01:24:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-description:content-disposition:in-reply-to; bh=08nvkZECyXYv3rEH8l5MeET9Sp3ID06O1wXzQHR2+7o=; b=Tttf1Vyo+4nO4YbBl28YpAfs16r63icHcGt3oreGb+r4ztnMqHEOi1hLAWCCFNBYxY eKRDN5vJiL082RwkysfpzaBUqO34PD27Y3NfnRxSGEIacnS5WuxTA4GpkLoOXyb9GVbn jCEsNk8HgBOI1kVXWusVyEXLZInYi1gQep9IOjobfMw87vUlbrLh4mjQ+8/AmqBEvpw2 MXLQs3QUR5rWBixsabBOBLrmY6VF+HBrR0St/0nM7DLG0GIwc3xiapUt5sf+7VIlUjNR KI3g4NOupV2rdt+bG43X0sG9IcicrRBuSm/D1G1ip3KYzU1A3PdVZkAfqWhFuNYBxSVd 6cPQ== X-Gm-Message-State: AOAM5331rSTTj7EKygITlmsILLucf/YWQ6mRvz48ej94yIvMqYKqH7EO 6eBwCyFn4ieqyD+tC/U1yZA= X-Google-Smtp-Source: ABdhPJx2tTQjTx9qMPfQJ7NwbYZLB0hI7nKexVTyS3ZB0zWkc0y8177mR+zDImq8sjGwkPOASYl8XA== X-Received: by 2002:a17:906:5809:: with SMTP id m9mr2678662ejq.304.1601367894539; Tue, 29 Sep 2020 01:24:54 -0700 (PDT) Received: from gmail.com ([2a03:1b20:3:f011::6d]) by smtp.gmail.com with ESMTPSA id s14sm4469779eju.84.2020.09.29.01.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 01:24:53 -0700 (PDT) Date: Tue, 29 Sep 2020 10:24:56 +0200 To: "Aktemur, Tankut Baris" , Simon Marchi Subject: Re: [PATCH] arc: Add support for Linux coredump files Message-ID: <20200929082456.GB4717@gmail.com> References: <20200827112728.4275-1-shahab.vahedi@gmail.com> <18b98a56-e3cf-e05b-49a7-bd6e1f61aefb@simark.ca> <20200928134714.GA4717@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Description: target_read_memory Content-Disposition: inline In-Reply-To: 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: Shahab Vahedi via Gdb-patches Reply-To: Shahab Vahedi Cc: Anton Kolesov , Shahab Vahedi , "gdb-patches@sourceware.org" , Francois Bedard Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi Baris, Simon, On Mon, Sep 28, 2020 at 03:10:23PM -0400, Simon Marchi wrote: > On 2020-09-28 10:08 a.m., Aktemur, Tankut Baris wrote: > > > > 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. I've looked into those files in master branch [1] which at the time was at commit 9aed480c3a7. The relevant results are: -------- ==> linux-aarch32-low.relevant_grep_results <== the_target->read_memory (where, (unsigned char *) &insn, 2); the_target->read_memory (where + 2, (unsigned char *) &insn, 2); the_target->read_memory (where, (unsigned char *) &insn, 4); if (target_read_memory (*pcptr, buf, 2) == 0) target_read_memory (*pcptr, (gdb_byte *) &inst1, 2); ==> linux-arm-low.relevant_grep_results <== target_read_memory (memaddr, (unsigned char *) &res, len); the_target->read_memory (sp, (unsigned char *) &sp_data, 4); the_target->read_memory (sp + pc_offset, (unsigned char *) &next_pc, 4); the_target->read_memory (sp + pc_offset + 4, (unsigned char *) &cpsr, 4); target_read_memory (pc, (unsigned char *) &this_instr, 4); if (read_memory (pc - 4, (unsigned char *) &insn, 4)) ==> linux-low.relevant_grep_results <== return the_target->read_memory (memaddr, myaddr, len); ==> linux-riscv-low.relevant_grep_results <== if (target_read_memory (*pcptr, buf.bytes, sizeof (buf.insn)) == 0 if (target_read_memory (pc, buf.bytes, sizeof (buf.insn)) == 0 && target_read_memory (pc + sizeof (buf.insn), buf.bytes, ==> linux-sparc-low.relevant_grep_results <== the_target->read_memory (addr, tmp_reg_buf, sizeof (tmp_reg_buf)); read_memory (where, (unsigned char *) insn, sizeof (insn)); ==> win32-low.relevant_grep_results <== -------- First, I am confused, because apparently there are 3 ways to skin a target's memory [2]: the_target->read_memory() 8 occurrences target_read_memory() 7 occurrences read_memory() 2 occurrences "the_target->read_memory()" and "read_memory()" should be the same in terms of code execution (not code writing). Then, there is "target_read_memory()" which I think is the default implementation [3]. Maybe it is my style, but I dislike hunting the implementation of a pure virtual method somewhere along the inheritance line (lineage? :p). Since ARC is not overriding the "read_memory()", it is more meaningful to use the "target_read_memory()". I will be changing "the_target->read_memory()" to that then. [1] Master branch at commit 9aed480c3a7 https://sourceware.org/git/?p=binutils-gdb.git;hb=HEAD;a=tree [2] To be clear, what I mean is "There are 3 flavors". I just couldn't leave this joke alone. [3] "process_stratum_target" class (the base) provides "read_memory()" as pure virtual method. Therefore, it must be defined overridden somewhere and I _think_ this is the default implementation. > 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 :). Please see my answer above.