From patchwork Fri Aug 25 01:33:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weimin Pan X-Patchwork-Id: 22353 Received: (qmail 97446 invoked by alias); 25 Aug 2017 01:44:49 -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 97311 invoked by uid 89); 25 Aug 2017 01:44:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy= X-HELO: aserp1050.oracle.com Received: from aserp1050.oracle.com (HELO aserp1050.oracle.com) (141.146.126.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Aug 2017 01:44:42 +0000 Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) by aserp1050.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v7P1iEZS007459 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 25 Aug 2017 01:44:15 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v7P1hhpo000318 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 25 Aug 2017 01:43:44 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v7P1hhpJ018174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 25 Aug 2017 01:43:43 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v7P1hgCd024823 for ; Fri, 25 Aug 2017 01:43:43 GMT Received: from wmpan.us.oracle.com (/10.147.27.127) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Aug 2017 18:43:42 -0700 From: Weimin Pan To: gdb-patches@sourceware.org Subject: [PATCH v2] break gdb build on 32-bit host with ADI support Date: Thu, 24 Aug 2017 20:33:04 -0500 Message-Id: <1503624784-124602-1-git-send-email-weimin.pan@oracle.com> The problem of failing to build with arm-linux-gnueabihf-g++-4.8 was that type CORE_ADDR is of "unsigned long" on a 64-bit machine so it's OK to use %lx but is of type "unsigned long long" on a 32 bit system. Fixed the problem in three places - (1) use a temp variable of type CORE_ADDR as argument 3 when calling target_auxv_search() then assign its value to "blksize" and "nbits" in 2 calls; (2) redo adi_normalize_address() using masks and xor operators to calculate normalized address; (3) call paddress() to print CORE_ADDR in either printf_filtered() or error(). Thank you, Pedro, for all your suggestions. --- gdb/sparc64-tdep.c | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-) diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 6f4fca7..a1d9158 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -93,8 +93,8 @@ typedef struct unsigned long blksize; /* Number of bits used for an ADI version tag which can be - * used together with the shift value for an ADI version tag - * to encode or extract the ADI version value in a pointer. */ + used together with the shift value for an ADI version tag + to encode or extract the ADI version value in a pointer. */ unsigned long nbits; /* The maximum ADI version tag value supported. */ @@ -217,15 +217,17 @@ adi_available (void) { pid_t pid = ptid_get_pid (inferior_ptid); sparc64_adi_info *proc = get_adi_info_proc (pid); + CORE_ADDR value; if (proc->stat.checked_avail) return proc->stat.is_avail; proc->stat.checked_avail = true; - if (target_auxv_search (¤t_target, AT_ADI_BLKSZ, - &proc->stat.blksize) <= 0) - return false; - target_auxv_search (¤t_target, AT_ADI_NBITS, &proc->stat.nbits); + if (target_auxv_search (¤t_target, AT_ADI_BLKSZ, &value) <= 0) + return false; + proc->stat.blksize = value; + target_auxv_search (¤t_target, AT_ADI_NBITS, &value); + proc->stat.nbits = value; proc->stat.max_version = (1 << proc->stat.nbits) - 2; proc->stat.is_avail = true; @@ -240,7 +242,7 @@ adi_normalize_address (CORE_ADDR addr) adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid)); if (ast.nbits) - return ((CORE_ADDR)(((long)addr << ast.nbits) >> ast.nbits)); + return (addr & ((1 << ast.nbits) - 1)) ^ (addr & (-1 >> ast.nbits)); return addr; } @@ -346,7 +348,8 @@ adi_read_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags) if (!adi_is_addr_mapped (vaddr, size)) { adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid)); - error(_("Address at 0x%lx is not in ADI maps"), vaddr*ast.blksize); + error(_("Address at %s is not in ADI maps"), + paddress (target_gdbarch (), vaddr * ast.blksize)); } int target_errno; @@ -366,7 +369,8 @@ adi_write_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags) if (!adi_is_addr_mapped (vaddr, size)) { adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid)); - error(_("Address at 0x%lx is not in ADI maps"), vaddr*ast.blksize); + error(_("Address at %s is not in ADI maps"), + paddress (target_gdbarch (), vaddr * ast.blksize)); } int target_errno; @@ -387,7 +391,8 @@ adi_print_versions (CORE_ADDR vaddr, size_t cnt, unsigned char *tags) while (cnt > 0) { QUIT; - printf_filtered ("0x%016lx:\t", vaddr * adi_stat.blksize); + printf_filtered ("%s:\t", + paddress (target_gdbarch (), vaddr * adi_stat.blksize)); for (int i = maxelts; i > 0 && cnt > 0; i--, cnt--) { if (tags[v_idx] == 0xff) /* no version tag */ @@ -418,7 +423,7 @@ do_examine (CORE_ADDR start, int bcnt) if (read_cnt == -1) error (_("No ADI information")); else if (read_cnt < cnt) - error(_("No ADI information at 0x%lx"), vaddr); + error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr)); adi_print_versions (vstart, cnt, buf); @@ -438,7 +443,7 @@ do_assign (CORE_ADDR start, size_t bcnt, int version) if (set_cnt == -1) error (_("No ADI information")); else if (set_cnt < cnt) - error(_("No ADI information at 0x%lx"), vaddr); + error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr)); }