From patchwork Sat May 26 00:58:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omair Javaid X-Patchwork-Id: 27515 Received: (qmail 70368 invoked by alias); 26 May 2018 00:59:13 -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 70356 invoked by uid 89); 26 May 2018 00:59:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=regarded, HX-Received:sk:g7-v6mr X-HELO: mail-wr0-f196.google.com Received: from mail-wr0-f196.google.com (HELO mail-wr0-f196.google.com) (209.85.128.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 26 May 2018 00:59:10 +0000 Received: by mail-wr0-f196.google.com with SMTP id r13-v6so11836889wrj.10 for ; Fri, 25 May 2018 17:59:09 -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:date:message-id; bh=qgoq5Tk24RiSeE1NAJDiTw0Plw9SnQppPvmSRarCpHA=; b=f/VNVzDVKIhuazfQCQUiCSuuy5zOHyc/gXnLsAksdq6NrwHJbkYNUxvE6AdJSeAvK0 YNACuqwt+xxz9JNRFukjpcrsmFxdSZ2X7OLGAe8iZWY1xmaavVbh1eFfcg/fKQoWoGGU OyyeNgAGH8nKSuKHzwvq+V836iN4XDT/R4e9+EEY/t/ILrkw6QTDIEdfPZwXOTt2ty1K N9BaBgib5jYz2Vw7VODDx5IfnjDAYOPf9Map9Vr+4SjCKyM8ojRm7H/+Q8VxnOXPRD/F ZwEAqS5rnbMIHODCxtTG7SUhrDCCiUb3bd54NAeRm2ajPTV0vjXeKJ0m8iJiucgj68eC GbuQ== X-Gm-Message-State: ALKqPwcBnVDNcM6x8EBflSMzfbYoUuptaQ1VIUKTEycBU60jovvR74ie eAeun44YuVoh0AKxBQiIRoD0VjA8kj4= X-Google-Smtp-Source: AB8JxZpAcucBS0jp/BBwXRnDs4Yms9ECi4C9ldjYwbSpugA0QPf1+TyYdeI2t9ADvYC8DP90qZZsaA== X-Received: by 2002:adf:e407:: with SMTP id g7-v6mr3847292wrm.143.1527296347668; Fri, 25 May 2018 17:59:07 -0700 (PDT) Received: from localhost.localdomain ([119.152.132.180]) by smtp.gmail.com with ESMTPSA id o53-v6sm37286177wrc.96.2018.05.25.17.59.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 May 2018 17:59:07 -0700 (PDT) From: Omair Javaid To: gdb-patches@sourceware.org Cc: Omair Javaid Subject: [PATCH v2][PR gdb/23210] Unset gdbarch significant_addr_bit by default Date: Sat, 26 May 2018 05:58:51 +0500 Message-Id: <1527296331-32213-1-git-send-email-omair.javaid@linaro.org> X-IsSubscribed: yes This version fixes the typo and gdbarch.sh issue highlighted in review. LGTM? This patch fixes a bug introduced by fix to AArch64 pointer tagging. In our fix for tagged pointer support our agreed approach was to sign extend user-space address after clearing tag bits. This is not same for all architectures and this patch allows sign extension for addresses on targets which specifically set significant_addr_bit. More information about patch that caused the issues and discussion around tagged pointer support can be found in links below: https://sourceware.org/ml/gdb-patches/2018-05/msg00000.html https://sourceware.org/ml/gdb-patches/2017-12/msg00159.html gdb/ChangeLog: 2018-05-23 Omair Javaid * gdbarch.sh (significant_addr_bit): Default to zero when not set by target architecture. * gdbarch.c: Re-generated. * utils.c (address_significant): Update. --- gdb/gdbarch.c | 4 ++-- gdb/gdbarch.sh | 2 +- gdb/utils.c | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index c430ebe..558cc55 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -615,8 +615,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of stabs_argument_has_addr, invalid_p == 0 */ /* Skip verify of convert_from_func_ptr_addr, invalid_p == 0 */ /* Skip verify of addr_bits_remove, invalid_p == 0 */ - if (gdbarch->significant_addr_bit == 0) - gdbarch->significant_addr_bit = gdbarch_addr_bit (gdbarch); + /* Skip verify of significant_addr_bit, invalid_p == 0 */ /* Skip verify of software_single_step, has predicate. */ /* Skip verify of single_step_through_delay, has predicate. */ /* Skip verify of print_insn, invalid_p == 0 */ @@ -3209,6 +3208,7 @@ int gdbarch_significant_addr_bit (struct gdbarch *gdbarch) { gdb_assert (gdbarch != NULL); + /* Skip verify of significant_addr_bit, invalid_p == 0 */ if (gdbarch_debug >= 2) fprintf_unfiltered (gdb_stdlog, "gdbarch_significant_addr_bit called\n"); return gdbarch->significant_addr_bit; diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 7330430..0a23b1e 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -622,7 +622,7 @@ m;CORE_ADDR;addr_bits_remove;CORE_ADDR addr;addr;;core_addr_identity;;0 # For example, on AArch64, the top bits of an address known as the "tag" # are ignored by the kernel, the hardware, etc. and can be regarded as # additional data associated with the address. -v;int;significant_addr_bit;;;;;gdbarch_addr_bit (gdbarch); +v;int;significant_addr_bit;;;;;;0 # FIXME/cagney/2001-01-18: This should be split in two. A target method that # indicates if the target needs software single step. An ISA method to diff --git a/gdb/utils.c b/gdb/utils.c index a2e933b..fe9a674 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2708,10 +2708,11 @@ address_significant (gdbarch *gdbarch, CORE_ADDR addr) /* Clear insignificant bits of a target address and sign extend resulting address, avoiding shifts larger or equal than the width of a CORE_ADDR. The local variable ADDR_BIT stops the compiler reporting a shift overflow - when it won't occur. */ + when it won't occur. Skip updating of target address if current target + has not set gdbarch significant_addr_bit. */ int addr_bit = gdbarch_significant_addr_bit (gdbarch); - if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) + if (addr_bit && (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))) { CORE_ADDR sign = (CORE_ADDR) 1 << (addr_bit - 1); addr &= ((CORE_ADDR) 1 << addr_bit) - 1;