Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@gnu.org>
To: cagney@gnu.org
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA/RFC] Replace call_ptrace and ptrace_wait in inf-ptrace.c
Date: Mon, 20 Sep 2004 21:48:00 -0000	[thread overview]
Message-ID: <200409202147.i8KLlNd6041679@elgar.sibelius.xs4all.nl> (raw)
In-Reply-To: <414F30D1.7080706@gnu.org> (message from Andrew Cagney on Mon, 20 Sep 2004 15:34:41 -0400)

   Date: Mon, 20 Sep 2004 15:34:41 -0400
   From: Andrew Cagney <cagney@gnu.org>

   > This is another step in the direction of eliminating the need for both
   > inf-ptrace.c and infptrace.c.  It eliminates the calls to call_ptrace
   > and ptrace_wait.
   > 
   > Andrew has recently suggested that we'd want debugging support for the
   > ptrace(2) interface, which could be implemented by using call_ptrace()
   > unconditionally.

   Having, again, spent some time debugging GNU/Linux threads, I'm pretty 
   much certain of this.

   > That, however, is a bad idea, since this makes it
   > impossible for the compiler to properly typecheck the arguments to
   > ptrace().

   How so?

The variety in ptrace(2) prototypes is pretty big.  Arguments can be
integer or pointer types of various sizes (32-bit, 64-bit).  We simply
cannot get that right for all supported operating systems.  So we have
to guess.  Being conservative, we use a long integer type, say
CORE_ADDR, for the n-th argument of call_ptrace().  Suppose that on an
LP64 platform we pass, by mistake, a pointer as the n-th argument of
ptrace, but that argument should really be an int.  Because of the
intermediate call_ptrace() the compiler doesn't warn us about it.  The
result is probably a mysterious bug.

If we'd used a macro instead, the compiler would have warned us.

   I've noticed that ptrace can sometimes be declared with a variable 
   number of arguments, but that just suggests there should be a 
   gdb_ptrace4() and gdb_ptrace5() with explicitly 4 and 5 arguments.

Linux does variable number of arguments, although the underlying
system call isn't.  I believe the 5-arg SunOS-compatible
PTRACE_READDATA on SPARC Linux simply doesn't work.

We shouldn't need an explicit 5-arg ptrace.  The fifth argument is
always zero in GDB.

Mark


  parent reply	other threads:[~2004-09-20 21:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-20 19:14 Mark Kettenis
2004-09-20 19:37 ` Andrew Cagney
2004-09-20 19:42   ` Daniel Jacobowitz
2004-09-20 21:48   ` Mark Kettenis [this message]
2004-09-21 13:09     ` Andrew Cagney
2004-09-24 22:37       ` Mark Kettenis
2004-09-24 22:46         ` Andrew Cagney

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=200409202147.i8KLlNd6041679@elgar.sibelius.xs4all.nl \
    --to=kettenis@gnu.org \
    --cc=cagney@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    /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