From patchwork Fri Dec 21 17:16:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 30794 Received: (qmail 109759 invoked by alias); 21 Dec 2018 17:16:48 -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 109748 invoked by uid 89); 21 Dec 2018 17:16:47 -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= X-HELO: mail-wr1-f52.google.com Received: from mail-wr1-f52.google.com (HELO mail-wr1-f52.google.com) (209.85.221.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Dec 2018 17:16:46 +0000 Received: by mail-wr1-f52.google.com with SMTP id c14so6037122wrr.0 for ; Fri, 21 Dec 2018 09:16:45 -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:in-reply-to:user-agent; bh=p2Nwj9nGHyHu5DS+biR2ovRHhN1CAJInMV017zVf4QI=; b=EvYvvqirf82G4UxAOE1W97g1aVPnX/EWbFYT1dsZH30dJly1ahbtfStppAvBHpWBd/ NStK9pPpATO6FQN7NEqWg1EGTelKQPDurEU3fdCFhZJna9KD6SEO3oCgxLZ39lryt7ga Pm7md1TAQQULPGqYtO+9nO7oSCVMsd30/6T+3b/fEyyKdISt65lnKu8uJ8ZaI4ZiNCJB sjLJ/fHgO6ETv4uai+m43TVpdtItW2JUqjczkmchN9C9X8DthYFUR8HwQWJuZps2Z5E8 8MBqy1fJSjcRLM+nZ1jHYeGBfPyuCDMnpalxVutGJKzPNG8Kj/3Wjv6IdeMYJ1XAsgAc gRmQ== Return-Path: Received: from localhost (host86-156-236-210.range86-156.btcentralplus.com. [86.156.236.210]) by smtp.gmail.com with ESMTPSA id s1sm15153129wro.9.2018.12.21.09.16.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Dec 2018 09:16:42 -0800 (PST) Date: Fri, 21 Dec 2018 17:16:41 +0000 From: Andrew Burgess To: Tom Tromey Cc: Simon Marchi , GDB Patches Subject: Re: riscv-tdep.c in 32-bits build Message-ID: <20181221171641.GH3456@embecosm.com> References: <6948b903-63f2-b0d2-4f66-738b95b51385@ericsson.com> <20181221005727.GF3456@embecosm.com> <87va3msy4t.fsf@tromey.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87va3msy4t.fsf@tromey.com> X-Fortune: Sauron is alive in Argentina! X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes * Tom Tromey [2018-12-21 08:22:26 -0700]: > >>>>> "Andrew" == Andrew Burgess writes: > > Andrew> Anyway, I propose casting to LONGEST and printing that. Unless you > Andrew> object I'll push this in a few days. > > It's fine; but as CORE_ADDR is (and will always be) unsigned, I think > you could use pulongest without a cast. Thanks for the review. I pushed a version that still uses 'plongest' as the offsets in questions are signed, and always (assuming descending stack) negative. I understand some of interfaces are a bit wonky in this area as far as signed/unsigned types, so maybe there's a bigger improvement that needs to be done? Any suggestions welcome :) Here's what I pushed, 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 a signed offset as a string. --- gdb/ChangeLog | 5 +++++ gdb/riscv-tdep.c | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 88b79af866f..6a55ab8b643 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1542,10 +1542,16 @@ riscv_scan_prologue (struct gdbarch *gdbarch, if (stack.find_reg (gdbarch, i, &offset)) { if (riscv_debug_unwinder) - fprintf_unfiltered (gdb_stdlog, - "Register $%s at stack offset %ld\n", - gdbarch_register_name (gdbarch, i), - offset); + { + /* Display OFFSET as a signed value, the offsets are from + the frame base address to the registers location on + the stack, with a descending stack this means the + offsets are always negative. */ + fprintf_unfiltered (gdb_stdlog, + "Register $%s at stack offset %s\n", + gdbarch_register_name (gdbarch, i), + plongest ((LONGEST) offset)); + } trad_frame_set_addr (cache->regs, i, offset); } }