Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* riscv-tdep.c in 32-bits build
@ 2018-12-20 17:26 Simon Marchi
  2018-12-21  0:57 ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2018-12-20 17:26 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: GDB Patches

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 864 bytes --]

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.

Simon
\x16º&Öéj×!zÊÞ¶êçם¼÷™b²Ö«r\x18\x1dn–­r\x17¬

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: riscv-tdep.c in 32-bits build
  2018-12-20 17:26 riscv-tdep.c in 32-bits build Simon Marchi
@ 2018-12-21  0:57 ` Andrew Burgess
  2018-12-21 15:22   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2018-12-21  0:57 UTC (permalink / raw)
  To: Simon Marchi; +Cc: GDB Patches

* Simon Marchi <simon.marchi@ericsson.com> [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);
             }
 	}
-- 
2.14.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: riscv-tdep.c in 32-bits build
  2018-12-21  0:57 ` Andrew Burgess
@ 2018-12-21 15:22   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2018-12-21 15:22 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Simon Marchi, GDB Patches

>>>>> "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.

Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-21 15:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 17:26 riscv-tdep.c in 32-bits build Simon Marchi
2018-12-21  0:57 ` Andrew Burgess
2018-12-21 15:22   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox