From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id dMLGFhgWyl+RLgAAWB0awg (envelope-from ) for ; Fri, 04 Dec 2020 05:57:28 -0500 Received: by simark.ca (Postfix, from userid 112) id 4FCFD1F0AB; Fri, 4 Dec 2020 05:57:28 -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 100061E552 for ; Fri, 4 Dec 2020 05:57:27 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7B10C397283D; Fri, 4 Dec 2020 10:57:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B10C397283D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607079446; bh=CXuZxY3LD2ELk4xYfnWKpWuN5rAFLkGZrQi4rriTrHA=; 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=hXV5HaUxqKwHuDswyXP44L3Vcc/6LjMVZHUR1XUS1yUtsZHuRLOWBBCcVfHobRdU/ jGMlq7DuGSMtdQ+11bAhH3yL6E+6T+gDgVlLG1BFE/aXyZN1ZZCJC27SKeEk7HpIP2 8gWqCKdzK1TK22+wHi0HLOoDaoVvIzPfoannx7ns= Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 60C283857C61 for ; Fri, 4 Dec 2020 10:57:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 60C283857C61 Received: by mail-ej1-x635.google.com with SMTP id jx16so8024301ejb.10 for ; Fri, 04 Dec 2020 02:57:23 -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=CXuZxY3LD2ELk4xYfnWKpWuN5rAFLkGZrQi4rriTrHA=; b=bSH7mFyeQh7XK4CCB8G9Ov5wUDn4GFT5wimzTpoUp3pnF6cbmeNyILc57O8L7vxY7t yCJz+JmF9OVvrLS12/9ADIgEk8dPxB0jrkPKaJR2ainB1ONREkwbB9ZmCu5x7IPOeocp d/wzcLFLykkL0TAIiWJWwlSQjRpZboRuLDD/2h4skfM+llOKgQ7bugweLovlQNc3UzOd RMN/9Fkt742hMgk4/T+tf/ebYGtDxDfZMuW3c2lan472V0EUTiMTnKT86KhbMB3u2IL9 oVYvQFks1+RKI19uAgXfoOZq9wcm+Og4nrtCc8K86Sxha1xea5K7nQSiWqMCqKjmadMK 2jQg== X-Gm-Message-State: AOAM531stUZkoTgausVMoPRCDOv948RSpsczzOf579c2rD1DnoX/vt+B 1VVL+CLUAewuDAhXzx6cySoT2h4iqO1k8mv6 X-Google-Smtp-Source: ABdhPJy6lrNkl10U2PulNKFcpbl2CwFRgPhRzckK9Vge8fpD5IMnTN8J+DQKBI6gfuGS2I6f9IkNKw== X-Received: by 2002:a17:907:210b:: with SMTP id qn11mr6737843ejb.41.1607079442150; Fri, 04 Dec 2020 02:57:22 -0800 (PST) Received: from atlantis.home ([2a03:1b20:3:f011::6d]) by smtp.gmail.com with ESMTPSA id h23sm2776369ejg.37.2020.12.04.02.57.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Dec 2020 02:57:21 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PUSHED gdb-10-branch] arc: Write correct "eret" value during register collection Date: Fri, 4 Dec 2020 11:57:14 +0100 Message-Id: <20201204105714.12903-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): Populate "eret" by "pc" value from the regcache when asked for "pc" value. --- gdb/ChangeLog | 5 +++++ gdb/arc-linux-tdep.c | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ad2c3db7d49..568e0cdc742 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-12-04 Shahab Vahedi + + * arc-linux-tdep.c (collect_register): Populate "eret" by + "pc" value from the regcache when asked for "pc" value. + 2020-11-29 Hannes Domani PR tui/26973 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