Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: muller@ics.u-strasbg.fr (Pierre Muller)
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC/RFA] Allow cygwin native to compile with       --enable-64-bit-bfd
Date: Mon, 26 Nov 2007 15:18:00 -0000	[thread overview]
Message-ID: <200711261518.lAQFIH3E012398@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <000001c8300c$8446c370$8cd44a50$@u-strasbg.fr> from "Pierre Muller" at Nov 26, 2007 10:12:49 AM

Pierre Muller wrote:

>   I didn't find many double typecast in gdb directory:
> grep "([a-zA-Z0-9 ]*) *([a-zA-Z0-9 ]*)" *nat* 
> only found one occurrence:
> spu-linux-nat.c:  return (ULONGEST) (unsigned long) res;
> and this does not even seem to be a pointer<->integer cast...

Your regexp is missing "_", so it actually cannot match the
cases involving intptr_t.  It's true that even so there is
not a large number of precedents, but that is because the
operation of casting between host pointers and CORE_ADDR
is quite rare (and that is how it should be!):

inf-ptrace.c:                               (PTRACE_TYPE_ARG3)(uintptr_t)
inf-ptrace.c:               (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset,
inf-ptrace.c:                   (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset,
inf-ptrace.c:                             (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset,
inf-ptrace.c:      buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)(uintptr_t)addr, 0);
inf-ptrace.c:      ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)(uintptr_t)addr, buf[i]);
linux-thread-db.c:           ? (CORE_ADDR) (intptr_t) notify.u.bptaddr
linux-thread-db.c:           : (CORE_ADDR) (uintptr_t) notify.u.bptaddr),
linux-thread-db.c:            ? (CORE_ADDR) (intptr_t) address
linux-thread-db.c:            : (CORE_ADDR) (uintptr_t) address);
ppc-linux-nat.c:  *addr_p = (CORE_ADDR) (uintptr_t) siginfo_p->si_addr;
proc-service.c:    return (psaddr_t) (intptr_t) addr;
proc-service.c:    return (psaddr_t) (uintptr_t) addr;
spu-linux-nat.c:  return (ULONGEST) (unsigned long) res;
spu-linux-nat.c:    *word = ptrace (PT_READ_I, tid, (PTRACE_TYPE_ARG3) (size_t) memaddr, 0);
spu-linux-nat.c:    ptrace (PT_WRITE_D, tid, (PTRACE_TYPE_ARG3) (size_t) memaddr, word);

>   Please remember that my C knowledge is mainly limited to
> the gdb sources themselves...
>   so if I have a CORE_ADDR that could be 64 bit
> and I want to cast it to a pointer, I should use
>   (LPVOID) (uintptr_t) core_addr
> and if I have a win32 API pointer that I want to
> convert to a CORE_ADDR, I should use
>   (CORE_ADDR) (uintptr_t) pointer_var.

Basically, yes.  Except that "LPVOID" is rather a Windows-ism,
it is not actually defined anywhere else ...

You should be using "void *", or preferably the actual
target pointer type.

>   My patch contained two conversions of the first type and
> four of the second type (all with the same memaddr variable)
> are macros really useful? Maybe to avoid future
> similar problems...

I'd prefer to not have macros, but just an explicitly
written intermediate cast.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2007-11-26 15:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-23  8:50 Pierre Muller
2007-11-24 21:07 ` Christopher Faylor
2007-11-24 22:47   ` Daniel Jacobowitz
2007-11-25 17:32     ` Christopher Faylor
2007-11-25 19:08       ` Daniel Jacobowitz
2007-11-25 22:12         ` Christopher Faylor
2007-11-26  9:12           ` Pierre Muller
2007-11-26 15:18             ` Ulrich Weigand [this message]
2007-11-29 10:11           ` [RFA v2] " Pierre Muller
2007-12-02  2:43             ` Christopher Faylor
2007-12-02  4:00               ` Daniel Jacobowitz
2007-12-03 15:18                 ` [RFA v3] " Pierre Muller
2007-12-06  9:23                   ` Christopher Faylor
2007-12-06 14:06                     ` Pierre Muller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200711261518.lAQFIH3E012398@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=muller@ics.u-strasbg.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox