From patchwork Mon Jul 17 11:32:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 21642 Received: (qmail 75365 invoked by alias); 17 Jul 2017 11:32:52 -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 75296 invoked by uid 89); 17 Jul 2017 11:32:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:clients, H*RU:sk:static., Hx-spam-relays-external:sk:static. X-HELO: mail-io0-f193.google.com Received: from mail-io0-f193.google.com (HELO mail-io0-f193.google.com) (209.85.223.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Jul 2017 11:32:48 +0000 Received: by mail-io0-f193.google.com with SMTP id 84so7248489iop.2 for ; Mon, 17 Jul 2017 04:32:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=7UqxG1xNS92BkBpVc8nC5J76k7UWsU96wW3UFYtaHIU=; b=Db4DD9uukqe2YMf+8vKWvo4BTin5fkOVLAyHUr6dQSpMSgw/Ovyq+EsvNbQ19aur7U zXFpM59ztA1SwGG3pYQS6aDjQIUtcISL8Yr/cIGzivolYMaySRFc/bIeOhO/88s5UAC/ AQanOeBjlsXjzO5G3vfJIFVY3I0OWEJ6d0GDs9D7BRFZQPuHhohKWZppAhwZpJP7SwnV izb1qvLjne19b/kB73PY50Ax+EkFtgJtnxYfbYxugB6h54RDzEkJlt/mDkfBzbxPpVw5 0NAjez/0iCyQxbnYL+G9qikMFb3abR/fzwcQDYXvTEslVKLRVFkR4BeF8pBhxk6/tRU5 Jf+Q== X-Gm-Message-State: AIVw1115X0g4Uy13ZnQip7AE/GPTFR/ngubNNTeWrntNNhWsRCTgG12R Vx7TlbLHg8GZpw== X-Received: by 10.107.129.9 with SMTP id c9mr18270653iod.17.1500291167003; Mon, 17 Jul 2017 04:32:47 -0700 (PDT) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id m27sm9067072ioi.19.2017.07.17.04.32.45 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 17 Jul 2017 04:32:46 -0700 (PDT) From: Yao Qi To: Alan Hayward Cc: "gdb-patches\@sourceware.org" , nd Subject: Re: [PATCH] Simplify regcache_cpy and remove regcache::cpy_no_passthrough References: <1498549057-3942-1-git-send-email-yao.qi@linaro.org> Date: Mon, 17 Jul 2017 12:32:38 +0100 In-Reply-To: (Alan Hayward's message of "Mon, 17 Jul 2017 09:04:22 +0000") Message-ID: <86k237s3hl.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Alan Hayward writes: > If not, then there should be a comment above regcache_cpy stating the > restrictions. I updated the comments to regcache_dup and regcache_cpy. diff --git a/gdb/regcache.c b/gdb/regcache.c index 7eeb737..e8f92d6 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -388,36 +388,9 @@ regcache_cpy (struct regcache *dst, struct regcache *src) gdb_assert (src != NULL && dst != NULL); gdb_assert (src->m_descr->gdbarch == dst->m_descr->gdbarch); gdb_assert (src != dst); - gdb_assert (src->m_readonly_p || dst->m_readonly_p); + gdb_assert (src->m_readonly_p && !dst->m_readonly_p); - if (!src->m_readonly_p) - regcache_save (dst, do_cooked_read, src); - else if (!dst->m_readonly_p) - dst->restore (src); - else - dst->cpy_no_passthrough (src); -} - -/* Copy/duplicate the contents of a register cache. Unlike regcache_cpy, - which is pass-through, this does not go through to the target. - Only values values already in the cache are transferred. The SRC and DST - buffers must not overlap. */ - -void -regcache::cpy_no_passthrough (struct regcache *src) -{ - gdb_assert (src != NULL); - gdb_assert (src->m_descr->gdbarch == m_descr->gdbarch); - /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough - move of data into a thread's regcache. Doing this would be silly - - it would mean that regcache->register_status would be - completely invalid. */ - gdb_assert (m_readonly_p && src->m_readonly_p); - - memcpy (m_registers, src->m_registers, - m_descr->sizeof_cooked_registers); - memcpy (m_register_status, src->m_register_status, - m_descr->sizeof_cooked_register_status); + dst->restore (src); } struct regcache * diff --git a/gdb/regcache.h b/gdb/regcache.h index b416d5e..aa64a00 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -369,8 +369,6 @@ private: void restore (struct regcache *src); - void cpy_no_passthrough (struct regcache *src); - enum register_status xfer_part (int regnum, int offset, int len, void *in, const void *out, decltype (regcache_raw_read) read, @@ -415,13 +413,12 @@ private: regcache_cpy (struct regcache *dst, struct regcache *src); }; -/* Copy/duplicate the contents of a register cache. By default, the - operation is pass-through. Writes to DST and reads from SRC will - go through to the target. See also regcache_cpy_no_passthrough. - - regcache_cpy can not have overlapping SRC and DST buffers. */ - +/* Duplicate the contents of a register cache to a read-only register + cache. The operation is pass-through. */ extern struct regcache *regcache_dup (struct regcache *regcache); + +/* Writes to DEST will go through to the target. SRC is a read-only + register cache. */ extern void regcache_cpy (struct regcache *dest, struct regcache *src); extern void registers_changed (void);