From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1590 invoked by alias); 7 Apr 2006 05:04:04 -0000 Received: (qmail 1581 invoked by uid 22791); 7 Apr 2006 05:04:03 -0000 X-Spam-Check-By: sourceware.org Received: from dsl027-180-168.sfo1.dsl.speakeasy.net (HELO sunset.davemloft.net) (216.27.180.168) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 07 Apr 2006 05:04:01 +0000 Received: from localhost ([127.0.0.1] ident=davem) by sunset.davemloft.net with esmtp (Exim 4.60) (envelope-from ) id 1FRj8X-0000rx-IB; Thu, 06 Apr 2006 22:03:57 -0700 Date: Fri, 07 Apr 2006 05:04:00 -0000 Message-Id: <20060406.220357.102230498.davem@davemloft.net> To: drow@false.org CC: gdb-patches@sources.redhat.com Subject: [PATCH]: PTRACE_PEEKUSER redux... From: "David S. Miller" Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00085.txt.bz2 Daniel, I've been thinking about that PTRACE_PEEKUSER dependency issue in linux-nat.c some more. And it's kind of unreasonable to expect people to get the latest and greatest Sparc Linux kernel in order to get a working gdb setup. Especially when we can handle this gracefully, and without much pain. In all cases, no matter what ptrace operation is specified, if the child does not exist the error return we will get is -ESRCH (task not found for pid) or -EPERM (trying to trace init or similar). Specifically checking for those two error codes allows us to cleanly handle Linux targets that do not need to implement PTRACE_PEEKUSER. Therefore, what do you think about the following patch? 2006-04-06 David S. Miller * linux-nat.c (linux_nat_thread_alive): Thread is alive as long as errno is neither -ESRCH nor -EPERM. This allows to handle cleanly the case where PTRACE_PEEKUSER is not a supported ptrace operation for a given Linux target. --- linux-nat.c.~1~ 2006-04-05 18:08:11.000000000 -0700 +++ linux-nat.c 2006-04-06 21:55:49.000000000 -0700 @@ -2382,7 +2383,7 @@ linux_nat_thread_alive (ptid_t ptid) "LLTA: PTRACE_PEEKUSER %s, 0, 0 (%s)\n", target_pid_to_str (ptid), errno ? safe_strerror (errno) : "OK"); - if (errno) + if (errno == -ESRCH || errno == -EPERM) return 0; return 1;