From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CKq0JTY9rV/FTAAAWB0awg (envelope-from ) for ; Thu, 12 Nov 2020 08:48:38 -0500 Received: by simark.ca (Postfix, from userid 112) id 96C281F08B; Thu, 12 Nov 2020 08:48:38 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 3E1CA1E58E for ; Thu, 12 Nov 2020 08:48:38 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E8E6739F7CB6; Thu, 12 Nov 2020 13:48:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8E6739F7CB6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605188917; bh=M93v0Q9TkxCOv74g7qMJPSDqSLi1Z/TNxo3CbvgPPww=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=tzkN4KZ38cu/8TLg3JIP0V5WHk7NX0Ld7O0KhMp2mgwHEFZvGhCtr3uBIfjtGJDBe FECVDuWVW7Kobc5WcJp08fUaM0XXOfaPTtSHbkZ98LMfx9TiPbO0tfoNMEhbwdTyvf o5Fi8jfyS+qZO+UqrnGljgGOy85ccPcXo8DDphTA= Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by sourceware.org (Postfix) with ESMTPS id 4B4023858006 for ; Thu, 12 Nov 2020 13:48:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4B4023858006 Received: by mail-ej1-x641.google.com with SMTP id za3so7791740ejb.5 for ; Thu, 12 Nov 2020 05:48:35 -0800 (PST) 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M93v0Q9TkxCOv74g7qMJPSDqSLi1Z/TNxo3CbvgPPww=; b=hI3bv0F0BTdYFXbAAyiJ+C/JFsMTQrpLIoxaUKa1NvsAdB2bfM0iS8R28Opu3uaaUB K7hWiCYEKGVbXIEK+CMFMwKBCklv7hEsulojPwIovzVZeyupl01ori8mPQjsj2pb+Xdg v03jfeT1fPUOx9wYqLKHaSo+o99JVTyyB3//CekqpLfZ0WTFIJUwMQHEkuACTF8mhOUQ UVjLsJXeKI8OIup6lZum+MPEqhlsa+cM9Z7KADMTVho72RSgZpbC7dd3MqyA8C0MDGwA rguKG/8ZYS3kgVvJ6yTEaqrLvzm33UaG7v+JBq5egmZUMktdzBLcFap1Kl1zMTHC1BxH JiMA== X-Gm-Message-State: AOAM530/PJc6Br3nXFU4VnzMY06ZPxoUyF+s130EIvMQU0prppNkYlu+ d0gv81SwZ85IQPc3i3isepbbwa9GLgCAWw== X-Google-Smtp-Source: ABdhPJyDqnpaukSKwokdl2NVeG3I7BKoZIXUxyKviAjC1cqAZolgYB9JaiJFLwR/r9ZMR1DhM42y4w== X-Received: by 2002:a17:906:7c4a:: with SMTP id g10mr29952721ejp.545.1605188911170; Thu, 12 Nov 2020 05:48:31 -0800 (PST) Received: from atlantis.home ([2a03:1b20:3:f011::6d]) by smtp.gmail.com with ESMTPSA id j7sm2198617ejk.14.2020.11.12.05.48.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2020 05:48:30 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH 1/2] arc: Take into account the REGNUM in supply/collect gdb hooks Date: Thu, 12 Nov 2020 14:48:10 +0100 Message-Id: <20201112134811.9074-2-shahab.vahedi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201112134811.9074-1-shahab.vahedi@gmail.com> References: <20201112134811.9074-1-shahab.vahedi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: Shahab Vahedi , Shahab Vahedi , Anton Kolesov , Francois Bedard Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Shahab Vahedi All the arc_linux_supply_*() target operations and the arc_linux_collect_v2_regset() in arc-linux-tdep.c were supplying/collecting all the registers in regcache as if the REGNUM was set to -1. The more efficient behavior is to examine the REGNUM and act accordingly. That is what this patch does. gdb/ChangeLog: * arc-linux-tdep.c (supply_register): New. (arc_linux_supply_gregset, arc_linux_supply_v2_regset, arc_linux_collect_v2_regset): Consider REGNUM. --- gdb/arc-linux-tdep.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c index b8ea2194934..e8e5461bc34 100644 --- a/gdb/arc-linux-tdep.c +++ b/gdb/arc-linux-tdep.c @@ -460,6 +460,18 @@ arc_linux_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) } } +/* Populate REGCACHE with register REGNUM from BUF. */ + +static void +supply_register (struct regcache *regcache, int regnum, const gdb_byte *buf) +{ + /* Skip non-existing registers. */ + if ((arc_linux_core_reg_offsets[regnum] == ARC_OFFSET_NO_REGISTER)) + return; + + regcache->raw_supply (regnum, buf + arc_linux_core_reg_offsets[regnum]); +} + void arc_linux_supply_gregset (const struct regset *regset, struct regcache *regcache, @@ -470,9 +482,14 @@ arc_linux_supply_gregset (const struct regset *regset, const bfd_byte *buf = (const bfd_byte *) gregs; - for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++) - if (arc_linux_core_reg_offsets[reg] != ARC_OFFSET_NO_REGISTER) - regcache->raw_supply (reg, buf + arc_linux_core_reg_offsets[reg]); + /* regnum == -1 means writing all the registers. */ + if (regnum == -1) + for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++) + supply_register (regcache, reg, buf); + else if (regnum <= ARC_LAST_REGNUM) + supply_register (regcache, regnum, buf); + else + gdb_assert_not_reached ("Invalid regnum in arc_linux_supply_gregset."); } void @@ -483,9 +500,12 @@ arc_linux_supply_v2_regset (const struct regset *regset, const bfd_byte *buf = (const bfd_byte *) v2_regs; /* user_regs_arcv2 is defined in linux arch/arc/include/uapi/asm/ptrace.h. */ - regcache->raw_supply (ARC_R30_REGNUM, buf); - regcache->raw_supply (ARC_R58_REGNUM, buf + REGOFF (1)); - regcache->raw_supply (ARC_R59_REGNUM, buf + REGOFF (2)); + if (regnum == -1 || regnum == ARC_R30_REGNUM) + regcache->raw_supply (ARC_R30_REGNUM, buf); + if (regnum == -1 || regnum == ARC_R58_REGNUM) + regcache->raw_supply (ARC_R58_REGNUM, buf + REGOFF (1)); + if (regnum == -1 || regnum == ARC_R59_REGNUM) + regcache->raw_supply (ARC_R59_REGNUM, buf + REGOFF (2)); } /* Populate BUF with register REGNUM from the REGCACHE. */ @@ -539,9 +559,12 @@ arc_linux_collect_v2_regset (const struct regset *regset, { bfd_byte *buf = (bfd_byte *) v2_regs; - regcache->raw_collect (ARC_R30_REGNUM, buf); - regcache->raw_collect (ARC_R58_REGNUM, buf + REGOFF (1)); - regcache->raw_collect (ARC_R59_REGNUM, buf + REGOFF (2)); + if (regnum == -1 || regnum == ARC_R30_REGNUM) + regcache->raw_collect (ARC_R30_REGNUM, buf); + if (regnum == -1 || regnum == ARC_R58_REGNUM) + regcache->raw_collect (ARC_R58_REGNUM, buf + REGOFF (1)); + if (regnum == -1 || regnum == ARC_R59_REGNUM) + regcache->raw_collect (ARC_R59_REGNUM, buf + REGOFF (2)); } /* Linux regset definitions. */ -- 2.29.2