Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit] Fix compilation warning in procfs.c on mips-irix
@ 2009-04-16 17:30 Joel Brobecker
  2009-04-16 18:24 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2009-04-16 17:30 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 721 bytes --]

While I was building GDB on mips-irix, I noticed a couple of warnings, 
so I decided to fix them.

On mips-irix, the pr_vaddr field is a caddr, and apparently, CORE_ADDR
is not the same size as this type.  So we need to cast it to an integer
type with the same size first, and then to CORE_ADDR.

2009-04-16  Joel Brobecker  <brobecker@adacore.com>

        * procfs.c (solib_mappings_callback, find_memory_regions_callback):
        Fix a compilation warning on mips-irix due to casting from
        a pointer of different size.

I actually meant to post this patch and wait for a few days before
checking in, but I accidently did the checkin. I'm pretty sure it's OK,
but let me know if not, and I'll revert.

-- 
Joel

[-- Attachment #2: procfs.diff --]
[-- Type: text/x-diff, Size: 1023 bytes --]

commit b39e37470c731a5a201a3466ff01aad38b3d4f36
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Wed Apr 8 15:02:40 2009 -0700

        * procfs.c (solib_mappings_callback, find_memory_regions_callback):
        Fix a compilation warning on mips-irix due to casting from
        a pointer of different size.

diff --git a/gdb/procfs.c b/gdb/procfs.c
index adb44f4..36d0e47 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -5473,7 +5473,7 @@ int solib_mappings_callback (struct prmap *map,
      no file, so the ioctl may return failure, but that's
      not a problem.  */
 #endif
-  return (*func) (fd, (CORE_ADDR) map->pr_vaddr);
+  return (*func) (fd, (CORE_ADDR) (uintptr_t) map->pr_vaddr);
 }
 
 /*
@@ -5524,7 +5524,7 @@ find_memory_regions_callback (struct prmap *map,
 					   void *),
 			      void *data)
 {
-  return (*func) ((CORE_ADDR) map->pr_vaddr,
+  return (*func) ((CORE_ADDR) (uintptr_t) map->pr_vaddr,
 		  map->pr_size,
 		  (map->pr_mflags & MA_READ) != 0,
 		  (map->pr_mflags & MA_WRITE) != 0,

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

* Re: [commit] Fix compilation warning in procfs.c on mips-irix
  2009-04-16 17:30 [commit] Fix compilation warning in procfs.c on mips-irix Joel Brobecker
@ 2009-04-16 18:24 ` Pedro Alves
  2009-04-16 18:45   ` Joel Brobecker
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2009-04-16 18:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

On Thursday 16 April 2009 18:30:25, Joel Brobecker wrote:
> While I was building GDB on mips-irix, I noticed a couple of warnings, 
> so I decided to fix them.
> 
> On mips-irix, the pr_vaddr field is a caddr, and apparently, CORE_ADDR
> is not the same size as this type.  So we need to cast it to an integer
> type with the same size first, and then to CORE_ADDR.

 {
-  return (*func) ((CORE_ADDR) map->pr_vaddr,
+  return (*func) ((CORE_ADDR) (uintptr_t) map->pr_vaddr,
                  map->pr_size,
                  (map->pr_mflags & MA_READ) != 0,
                  (map->pr_mflags & MA_WRITE) != 0,

Isn't this a problem for MIPS, due to pointer sign-extension?

proc-service has these utility routines to handle the similar
case on mips-linux:

/* Convert a psaddr_t to a CORE_ADDR.  */

static CORE_ADDR
ps_addr_to_core_addr (psaddr_t addr)
{
  if (exec_bfd && bfd_get_sign_extend_vma (exec_bfd))
    return (intptr_t) addr;
  else
    return (uintptr_t) addr;
}

/* Convert a CORE_ADDR to a psaddr_t.  */

static psaddr_t
core_addr_to_ps_addr (CORE_ADDR addr)
{
  if (exec_bfd && bfd_get_sign_extend_vma (exec_bfd))
    return (psaddr_t) (intptr_t) addr;
  else
    return (psaddr_t) (uintptr_t) addr;
}

-- 
Pedro Alves


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

* Re: [commit] Fix compilation warning in procfs.c on mips-irix
  2009-04-16 18:24 ` Pedro Alves
@ 2009-04-16 18:45   ` Joel Brobecker
  2009-04-16 19:52     ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2009-04-16 18:45 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

> -  return (*func) ((CORE_ADDR) map->pr_vaddr,
> +  return (*func) ((CORE_ADDR) (uintptr_t) map->pr_vaddr,
>                   map->pr_size,
>                   (map->pr_mflags & MA_READ) != 0,
>                   (map->pr_mflags & MA_WRITE) != 0,
> 
> Isn't this a problem for MIPS, due to pointer sign-extension?

Hmmm, you are probably right. I reverted the patch for now, and will look
further into your suggestion a bit later.

Thanks!
-- 
Joel


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

* Re: [commit] Fix compilation warning in procfs.c on mips-irix
  2009-04-16 18:45   ` Joel Brobecker
@ 2009-04-16 19:52     ` Daniel Jacobowitz
  2009-04-17 13:27       ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2009-04-16 19:52 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Pedro Alves, gdb-patches

On Thu, Apr 16, 2009 at 11:45:39AM -0700, Joel Brobecker wrote:
> > -  return (*func) ((CORE_ADDR) map->pr_vaddr,
> > +  return (*func) ((CORE_ADDR) (uintptr_t) map->pr_vaddr,
> >                   map->pr_size,
> >                   (map->pr_mflags & MA_READ) != 0,
> >                   (map->pr_mflags & MA_WRITE) != 0,
> > 
> > Isn't this a problem for MIPS, due to pointer sign-extension?
> 
> Hmmm, you are probably right. I reverted the patch for now, and will look
> further into your suggestion a bit later.

Note, if you don't have any code above 0x80000000, it doesn't much
matter... I don't remember how the MIPS bits ever came to be used, or
if they were theoretical.  Threaded code on 32-bit MIPS Linux is
always going to be below KSEG0 at 0x80000000.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [commit] Fix compilation warning in procfs.c on mips-irix
  2009-04-16 19:52     ` Daniel Jacobowitz
@ 2009-04-17 13:27       ` Pedro Alves
  0 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2009-04-17 13:27 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches

On Thursday 16 April 2009 20:51:53, Daniel Jacobowitz wrote:
> On Thu, Apr 16, 2009 at 11:45:39AM -0700, Joel Brobecker wrote:
> > > -  return (*func) ((CORE_ADDR) map->pr_vaddr,
> > > +  return (*func) ((CORE_ADDR) (uintptr_t) map->pr_vaddr,
> > >                   map->pr_size,
> > >                   (map->pr_mflags & MA_READ) != 0,
> > >                   (map->pr_mflags & MA_WRITE) != 0,
> > > 
> > > Isn't this a problem for MIPS, due to pointer sign-extension?
> > 
> > Hmmm, you are probably right. I reverted the patch for now, and will look
> > further into your suggestion a bit later.

Eh, it was a legit question, not a request for reverting!

> Note, if you don't have any code above 0x80000000, it doesn't much
> matter... I don't remember how the MIPS bits ever came to be used, or
> if they were theoretical.  Threaded code on 32-bit MIPS Linux is
> always going to be below KSEG0 at 0x80000000.

Yeah... I assumed that since we had that handling in proc-service.c
that mips-linux could have user code above 0x80000000.  If that's not
the case on irix as well (it seems likely, since those KSEG
things are hardware-decided mappings?), then we don't have to worry
about this here.  In addition, these warning have surely been
there for a long while, it's just that up until recently procfs.c
was always built with -Werror disabled.

-- 
Pedro Alves


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

end of thread, other threads:[~2009-04-17 13:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-16 17:30 [commit] Fix compilation warning in procfs.c on mips-irix Joel Brobecker
2009-04-16 18:24 ` Pedro Alves
2009-04-16 18:45   ` Joel Brobecker
2009-04-16 19:52     ` Daniel Jacobowitz
2009-04-17 13:27       ` Pedro Alves

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