From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id RX7YEvVXrV+eTwAAWB0awg (envelope-from ) for ; Thu, 12 Nov 2020 10:42:45 -0500 Received: by simark.ca (Postfix, from userid 112) id 40FA81F08B; Thu, 12 Nov 2020 10:42:45 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham 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 9049E1E552 for ; Thu, 12 Nov 2020 10:42:44 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1EAD7386F020; Thu, 12 Nov 2020 15:42:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EAD7386F020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605195764; bh=UaffbyXoasfcSt6pqxthso5TAnLo2vwVtl1rGMnXI5U=; 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=sILc0FapIBvd5OZi1w4GFKco0SuqOfp4fRJc/ZnhgT3y5eqEgk1rXcTgQ7Z1egjLy qVnTxUH45ew6WQRdBP8KXX8K5evW+gbm5uAiP3PAsG20RuVWB6300UJ1EY1cXyW64v SHnRYoA1Vy7tvOGf1T/nbGUixUC81o+mYFDQe9ZA= Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by sourceware.org (Postfix) with ESMTPS id B143B384A00F for ; Thu, 12 Nov 2020 15:42:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B143B384A00F Received: by mail-ed1-x541.google.com with SMTP id v4so6804246edi.0 for ; Thu, 12 Nov 2020 07:42:40 -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=UaffbyXoasfcSt6pqxthso5TAnLo2vwVtl1rGMnXI5U=; b=OuvovKbB0xmiXWmkBtfEbemi0nSjo75kTSjDB8hgXwjKI0Q1+qraBXyUJPuk4ViV0l jpaR5OjRkZ07c40WuyMFHrCYI1dI1XlfewQKeqd1XehIawDk452oreyClhGfdkIGom7c r31lMIns2Q3pmJftq4jmsqY5jSM8QVAXtHltt9zK3Gmv6/4A1cJz72z9R6lDe9dQNvl4 szD9ZHqQ5yA1dmxiOfIJOwFC51HT2j6qAP+o/MSjoBhsIzNDMtZyIV7WLGqWjcbEwe6e Uu0RJymzkAQGek0cUNN47gwWsc4Rve8zaJ2tnmso7FeWGuZPQEBOlTzkS65CGRCBgD7h zcfA== X-Gm-Message-State: AOAM531wCsUIeOnJTyUUUWVm/UTLp3abvLCps+PsCHWcNF2S1dEG84mf kSv/OYVRWxGz9Cn3eDAlQXfw5Say7KEglhUN X-Google-Smtp-Source: ABdhPJyUJ1xPYo7H08eABGXCTokfQB/iJv9/ltKrdcN3Wx6R/rlU803k2FdX9R9OL48jRlmP1oZ8jQ== X-Received: by 2002:a05:6402:cb4:: with SMTP id cn20mr310260edb.235.1605195759398; Thu, 12 Nov 2020 07:42:39 -0800 (PST) Received: from atlantis.home ([2a03:1b20:3:f011::6d]) by smtp.gmail.com with ESMTPSA id l8sm2322553ejk.67.2020.11.12.07.42.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2020 07:42:38 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH v2] arc: Write correct "eret" value during register collection Date: Thu, 12 Nov 2020 16:42:28 +0100 Message-Id: <20201112154228.16634-1-shahab.vahedi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201112134310.8544-1-shahab.vahedi@gmail.com> References: <20201112134310.8544-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 , Tom Tromey , Francois Bedard Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Shahab Vahedi In collect_register() function of arc-linux-tdep.c, the "eret" (exception return) register value was not being reported correctly. This patch fixes that. Background: When asked for the "pc" value, we have to update the "eret" register with GDB's STOP_PC. The "eret" instructs the kernel code where to jump back when an instruction has stopped due to a breakpoint. This is how collect_register() was doing so: --------------8<-------------- if (regnum == gdbarch_pc_regnum (gdbarch)) regnum = ARC_ERET_REGNUM; regcache->raw_collect (regnum, buf + arc_linux_core_reg_offsets[regnum]); -------------->8-------------- Root cause: Although this is using the correct offset (ERET register's), it is also changing the REGNUM itself. Therefore, raw_collect (regnum, ...) is not reading from "pc" anymore. v2: - Fix a copy/paste issue as rightfully addressed by Tom [1]. [1] https://sourceware.org/pipermail/gdb-patches/2020-November/173208.html gdb/ChangeLog: * arc-linux-tdep.c (collect_register): Use "eret" value while still writing to "pc" register cache. --- gdb/arc-linux-tdep.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c index 9ff5f1214a1..6e74bae8056 100644 --- a/gdb/arc-linux-tdep.c +++ b/gdb/arc-linux-tdep.c @@ -319,8 +319,10 @@ static void collect_register (const struct regcache *regcache, struct gdbarch *gdbarch, int regnum, gdb_byte *buf) { + int offset; + /* Skip non-existing registers. */ - if ((arc_linux_core_reg_offsets[regnum] == ARC_OFFSET_NO_REGISTER)) + if (arc_linux_core_reg_offsets[regnum] == ARC_OFFSET_NO_REGISTER) return; /* The address where the execution has stopped is in pseudo-register @@ -332,8 +334,10 @@ collect_register (const struct regcache *regcache, struct gdbarch *gdbarch, the program will continue at the address after the current instruction. */ if (regnum == gdbarch_pc_regnum (gdbarch)) - regnum = ARC_ERET_REGNUM; - regcache->raw_collect (regnum, buf + arc_linux_core_reg_offsets[regnum]); + offset = arc_linux_core_reg_offsets[ARC_ERET_REGNUM]; + else + offset = arc_linux_core_reg_offsets[regnum]; + regcache->raw_collect (regnum, buf + offset); } void -- 2.29.2