diff mbox

riscv-tdep.c in 32-bits build

Message ID 20181221171641.GH3456@embecosm.com
State New
Headers show

Commit Message

Andrew Burgess Dec. 21, 2018, 5:16 p.m. UTC
* Tom Tromey <tom@tromey.com> [2018-12-21 08:22:26 -0700]:

> >>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> 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 mbox

Patch

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);
             }
 	}