From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7604 invoked by alias); 31 Oct 2003 20:38:19 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 7525 invoked from network); 31 Oct 2003 20:38:10 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.115.144) by sources.redhat.com with SMTP; 31 Oct 2003 20:38:10 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id h9VKc9BD000622 for ; Fri, 31 Oct 2003 21:38:09 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id h9VKc9uV000931 for ; Fri, 31 Oct 2003 21:38:09 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6/Submit) id h9VKc88W000928; Fri, 31 Oct 2003 21:38:08 +0100 (CET) Date: Fri, 31 Oct 2003 20:38:00 -0000 Message-Id: <200310312038.h9VKc88W000928@elgar.kettenis.dyndns.org> From: Mark Kettenis To: gdb@sources.redhat.com Subject: lin-lwp.c and UltraSPARC X-SW-Source: 2003-10/txt/msg00354.txt.bz2 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