From patchwork Fri Dec 21 00:57:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 30788 Received: (qmail 79510 invoked by alias); 21 Dec 2018 00:57:34 -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 79482 invoked by uid 89); 21 Dec 2018 00:57:33 -0000 Authentication-Results: sourceware.org; auth=none 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=cxx, CXX, ld, Hx-languages-length:2025 X-HELO: mail-wr1-f45.google.com Received: from mail-wr1-f45.google.com (HELO mail-wr1-f45.google.com) (209.85.221.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Dec 2018 00:57:32 +0000 Received: by mail-wr1-f45.google.com with SMTP id x10so3555428wrs.8 for ; Thu, 20 Dec 2018 16:57:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=y+W8ojl/I7VSAwMGOpvFVu3bb0zqLsh7xy1eLm86+6c=; b=e5DtXWn/cVt/EAvgDobavf4P4USA1EuCqFd8NxPmOLCgPfMIR45cQLfsmWzu3Szu7v EIGoHTSrx8aYPW/Xkl0L7hbKSZRmFZy4per2tboeAT2A6hOBUfyGu+cqxsYpes3jLFXo HzqjuFqMD4mIsUOUgyrGyUFXgHE0dVeGud510mB8Jq70JWVK6rNUhjNwGzsFoeV1QBcq gX5Y/tEGHXHpn4ALqgWVWKgdM/91s7ejlveowyD2oCcb7wa7up6Thr2gJAmJknFBgcak t18Zdx7YrYbkP/+XC2yBfQVRWHtmL8lwAVULZ/7yqErv2owIsTJ1UbQByqYSEd911rDY MajA== Return-Path: Received: from localhost (host86-156-236-210.range86-156.btcentralplus.com. [86.156.236.210]) by smtp.gmail.com with ESMTPSA id t63sm8013471wmt.8.2018.12.20.16.57.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Dec 2018 16:57:28 -0800 (PST) Date: Fri, 21 Dec 2018 00:57:27 +0000 From: Andrew Burgess To: Simon Marchi Cc: GDB Patches Subject: Re: riscv-tdep.c in 32-bits build Message-ID: <20181221005727.GF3456@embecosm.com> References: <6948b903-63f2-b0d2-4f66-738b95b51385@ericsson.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6948b903-63f2-b0d2-4f66-738b95b51385@ericsson.com> X-Fortune: If you think before you speak the other guy gets his joke in first. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes * Simon Marchi [2018-12-20 17:26:01 +0000]: > Hi Andrew, > > I just noticed this error when building for i386-linux-gnu. > > CXX riscv-tdep.o > /home/emaisin/src/binutils-gdb/gdb/riscv-tdep.c: In function ‘CORE_ADDR riscv_scan_prologue(gdbarch*, CORE_ADDR, CORE_ADDR, riscv_unwind_cache*)’: > /home/emaisin/src/binutils-gdb/gdb/riscv-tdep.c:1548:43: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘CORE_ADDR {aka long long unsigned int}’ [-Werror=format=] > offset); > ^ > I looked at it a bit and decided to let you choose how you wanted to fix > it. Since this is a CORE_ADDR, I first thought we should call paddress. > But this variable represents an offset, not an absolute address, so I am > not sure if paddress is really appropriate. Thanks for the report. The use of CORE_ADDR is not ideal, that's just what the existing API into pv_area uses. Given it's an offset, possibly LONGEST would be more appropriate? Anyway, I propose casting to LONGEST and printing that. Unless you object I'll push this in a few days. Thanks, Andrew --- gdb/riscv: Format CORE_ADDR as a string for printing Avoid compiler errors caused by trying to print CORE_ADDR using '%ld' format, instead convert to a string and print that instead. gdb/ChangeLog: * riscv-tdep.c (riscv_scan_prologue): Use plongest to format offset as a string. --- gdb/ChangeLog | 5 +++++ gdb/riscv-tdep.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 88b79af866f..464021f664c 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1543,9 +1543,9 @@ riscv_scan_prologue (struct gdbarch *gdbarch, { if (riscv_debug_unwinder) fprintf_unfiltered (gdb_stdlog, - "Register $%s at stack offset %ld\n", + "Register $%s at stack offset %s\n", gdbarch_register_name (gdbarch, i), - offset); + plongest ((LONGEST) offset)); trad_frame_set_addr (cache->regs, i, offset); } }