From patchwork Thu Aug 15 20:41:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 34130 Received: (qmail 100981 invoked by alias); 15 Aug 2019 20:41:53 -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 100968 invoked by uid 89); 15 Aug 2019 20:41:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=prefers X-HELO: esa3.mentor.iphmx.com Received: from esa3.mentor.iphmx.com (HELO esa3.mentor.iphmx.com) (68.232.137.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Aug 2019 20:41:51 +0000 IronPort-SDR: Q9zxMmVWBw5qm3CAFqoSiUo7Ye2mKXSKAWDx91hba+z+sSX4DxvyeyY4Y6+8LjsbHDB7PPS5VT i+R2KDSvW1Yhfir09uEZvjWqLm33TaZDju3/e6+c4L23UGY+HzR6okkFOYlvb/tDrwbSY0Sfuq Sw7faVhsAzswXSw4tMbKhwJTvvyTo6TJ4dlPBqVsipspdaQqEwjHujmzr8q+HD7ZYUSeXGMgmR lCVgCC57m15Dpis2SO66FOtkXPbIoyjAykZGWTPBkcwPDx9F10h0IVT06fwXA+LqXYo9yas9a1 ASI= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 15 Aug 2019 12:41:50 -0800 IronPort-SDR: bAFuHAcYjP1t6+0LKR4GXIeJHHTrIK+i+eBujMoFnGLteccQl+4Mx+m0rSw6H6cvwXU+8HRwYG 17zDaNQ5zAEXYPfBRqSBE8D2xEsJuwSWcaUd8sDrOyIfM/fpAdZ7MnHNzyoU84/lcCw428k5iA rDR/XN8SBgcm/iSrRSSYlM4jbB1lYmNQWyIVaaT45GSwyAIpAho3PrfCXvHTKG130Vly2woThB vT7xePmyK5VB1jNI4XKeJrJXhdXjXNVBZ7I5KDyFz2p2GdaY+Mprzo8IAC4yHnwnkSs3L/tEMr MQs= To: "gdb-patches@sourceware.org" CC: From: Sandra Loosemore Subject: [patch, nios2] Fix bug in nios2 prologue analysis. Message-ID: Date: Thu, 15 Aug 2019 14:41:43 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Return-Path: sandra@codesourcery.com This patch fixes a bug in the nios2 prologue analyzer that was causing failures in a couple of test cases. The bug has been there forever, but this code isn't terribly well exercised by the testsuite since the nios2 backend normally uses the dwarf2 unwinder. I realize the nios2 backend has a more general problem with using int or unsigned int to represent target word-sized values when it really ought to be using int32_t or uint32_t. I think that is a different issue than the signedness bug, though. So, OK to check this in? -Sandra commit 40a7589d1e2a0a8fe6a1891db7fcef156261937b Author: Sandra Loosemore Date: Thu Aug 15 13:12:00 2019 -0700 Fix bug in nios2 prologue analysis. The nios2 prologue analyzer was mistakenly using an unsigned int field to represent a 32-bit signed value. This caused problems with an incorrect conversion being applied to negative values when they were automatically promoted for addition to a 64-bit CORE_ADDR value. This patch fixes test failures in gdb.base/large-frame.exp and gdb.dwarf2/dw2-ref-missing-frame.exp. Normally the nios2 backend prefers to use the dwarf2 unwinder so the prologue analyzer is only invoked if there is no dwarf2 information. 2019-08-15 Sandra Loosemore gdb/ * nios2-tdep.c (struct reg_value): Improve comments. Make the offset field signed. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b6953b0..9775018 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-08-15 Sandra Loosemore + + * nios2-tdep.c (struct reg_value): Improve comments. Make + the offset field signed. + 2019-08-15 Tom de Vries * linux-nat-trad.c: Include gdbarch.h. diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index 2a21c33..8d685d4 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -58,13 +58,15 @@ static int nios2_debug = 0; analysis; see the reg_value and reg_saved tables in struct nios2_unwind_cache, respectively. */ -/* struct reg_value is used to record that a register has the same value - as reg at the given offset from the start of a function. */ +/* struct reg_value is used to record that a register has reg's initial + value at the start of a function plus the given constant offset. + If reg == 0, then the value is just the offset. + If reg < 0, then the value is unknown. */ struct reg_value { int reg; - unsigned int offset; + int offset; }; /* struct reg_saved is used to record that a register value has been saved at