This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [commit] Fix compilation warning in procfs.c on mips-irix


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]