public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@chello.nl>
To: gdb@sources.redhat.com
Subject: lin-lwp.c and UltraSPARC
Date: Fri, 31 Oct 2003 20:38:00 -0000	[thread overview]
Message-ID: <200310312038.h9VKc88W000928@elgar.kettenis.dyndns.org> (raw)

Ever since I created the file, lin-lwp.c has had the following code:

static int
lin_lwp_thread_alive (ptid_t ptid)
{
  gdb_assert (is_lwp (ptid));

  errno = 0;
  ptrace (PTRACE_PEEKUSER, GET_LWP (ptid), 0, 0);
  if (debug_lin_lwp)
    fprintf_unfiltered (gdb_stdlog,
			"LLTA: PTRACE_PEEKUSER %s, 0, 0 (%s)\n",
			target_pid_to_str (ptid),
			errno ? safe_strerror (errno) : "OK");
  if (errno)
    return 0;

  return 1;
}

Today I discovered that a sparc64 Linux kernel doesn't implement
PTRACE_PEEKUSER, and therefore always sets errno to EIO.  The result
is that for UltraSPARC systems running on a 64-bit kernel, all threads
are always considered to be dead.  Sooner or later this gets us into
real trouble.

There are basically two things we can do.  The first one is:

-  if (errno)
+  if (errno && errno != EIO)
     return 0;

The alternative is:

-  if (errno)
+  if (errno == ESRCH)
     return 0;

I'm leaning towards the latter since I think it is cleaner, although
perhaps a bit more riskier (I haven't looked at all the
architecture-specific ptrace(2) implementations in the Linux kernel).

I'm also thinking about replacing the PTRACE_PEEKUSER with a
PTRACE_PEEKDATA since the latter should be implemented on all
architectures.  In that case the call would probably fail the same way
on all architectures (assuming that nothing is mapped at address 0 on
all those architectures).

Opinions?

Mark

             reply	other threads:[~2003-10-31 20:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-31 20:38 Mark Kettenis [this message]
2003-10-31 23:31 ` Kevin Buettner
2003-11-01  0:47   ` Daniel Jacobowitz

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=200310312038.h9VKc88W000928@elgar.kettenis.dyndns.org \
    --to=kettenis@chello.nl \
    --cc=gdb@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).