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: 137003 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp235591lji; Fri, 25 May 2018 17:59:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp6nQ3QUj1vKA9YM882KgTZSZcWbXd1cd4v8qweFwg8ZWjKYGDBYNwADwYbpX0yKJyoa1mC X-Received: by 2002:a63:6887:: with SMTP id d129-v6mr3711184pgc.128.1527296359396; Fri, 25 May 2018 17:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527296359; cv=none; d=google.com; s=arc-20160816; b=ZCAlEbQp+9RFdUe9/7vVLdtc1+sr863t6JZ1UG8ZPWBfTAJRDgDxejVaWhUiPmaMdQ Pz1q3aCyLOW7U6cV0Cgwguwu6eP4DRa10Oarl/AEKn3nA5sxvVUhK8Zec5RH8YOOQBiQ suvCAuXu9NcAdtYzt0DwZxKCg5GPrHL0a4/QA9eTpmIxNLMSae4iNqatFkA5pvrOx6Y4 3BKzQ/vs66DJ7OLEsmpY1XC24D70UpJmxC3I8NRlCxHoNdvADiciPIS8aOnhcRmGLoOv 4ex3Pb2ib30FdJmon008OSX2oJRMjLCYB1uuQhkngMQYYoRRmN/XOWquyG2fZZlWA2N1 gtSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=qgoq5Tk24RiSeE1NAJDiTw0Plw9SnQppPvmSRarCpHA=; b=yliNkvWdXFLUx+5XDQlxZLg355eV0oEotB8dPKhFh4zKpvbeDx+GU86k8jdbqWhBg2 rZzCdQVqSYeCip4RCxJ+SgGGfT+3NsILWU4MKPQhHn46/YIAaNie9lLTzj6GeDk9jcSZ zeQjKFsvVXU6F0Myub7T+qSV0wOMqSNe5RbkPZdUxqFIMfpNpxoPfHYEfzmZYudXBEK3 rgU7/rAbm0v9CPmcIE/2WitpwtDR88/8StYVkdGSCpar8RQ70or8ulhd4suEQf5xEDMt SWAgDY2/S8vgjJ31BcjfMwxY1HpR+7tjvxdWSZWLPJbEe6/Q20crx2rBj+JPdjzWZCvy LNBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=gdecbRjP; spf=pass (google.com: domain of gdb-patches-return-147690-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gdb-patches-return-147690-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v16-v6si24183087pfn.77.2018.05.25.17.59.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 17:59:19 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-return-147690-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=gdecbRjP; spf=pass (google.com: domain of gdb-patches-return-147690-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gdb-patches-return-147690-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=FJxRUg3voaKtNNW4v2X6kzPnuUk48yHjg7ZLp+06c74yo8NKnK6Sp 4fr3ZA0vN3yGVp9uoWNo/9fXk1PAVFipz5qZIeLmaJxraWgXKq5wD0lktLZejNO1 vOzk9vSDqZVib+b4wH/WbMfohxVrF+QiOcE2mHvbteuTVyMkUArbtc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=G/aS3ZAEITpAXNIa7KXnQI3Il+8=; b=gdecbRjPa7diPoi3P4BZVAQE9OVa dxcdYh1xV7oo9njlQnnY02SOCM2dUx+RZxOUA8tviXgHx5Fbxl3vDE2fSx9UO2XJ UbKRtWWiARPCpDQthAk9/dolro8gPC7UI5WfInUrzevlDGd0hvqOQ7v76nFtENVO rP9DatGde8VkRlw= 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-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(-) -- 2.7.4 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;