From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24749 invoked by alias); 29 Jan 2010 01:26:36 -0000 Received: (qmail 24733 invoked by uid 22791); 29 Jan 2010 01:26:35 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Jan 2010 01:26:31 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0T1QTor028671 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Jan 2010 20:26:29 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0T1QR7R029723 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 28 Jan 2010 20:26:29 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o0T1QQPs009056; Fri, 29 Jan 2010 02:26:26 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o0T1QP7D009054; Fri, 29 Jan 2010 02:26:25 +0100 Date: Fri, 29 Jan 2010 01:26:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: "H.J. Lu" , GDB Subject: Re: [patch] Fix CLONE_VM vs. TLS [Re: Is CLONE_VM really needed in gdbserver?] Message-ID: <20100129012625.GA8631@host0.dyn.jankratochvil.net> References: <6dc9ffc81001261551j6221db6v88e96713d6dd9497@mail.gmail.com> <20100127000821.GA29862@caradoc.them.org> <20100127221236.GA4746@host0.dyn.jankratochvil.net> <20100128170103.GA9936@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100128170103.GA9936@caradoc.them.org> User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00627.txt.bz2 On Thu, 28 Jan 2010 18:01:07 +0100, Daniel Jacobowitz wrote: > I don't recommend testing HAVE_FORK; uClibc may provide a dummy fork > that returns ENOSYS. There's a HAS_NOMMU in linux-low.c that should work. OK, copied the current usage of HAS_NOMMU. > For the test case, what defines UCLINUX? Seen in some Googled source but it is true nobody sets it. CodeSourcery arm-2009q3-66-arm-uclinuxeabi-i686-pc-linux-gnu.tar.bz2 gcc sets __uClinux__ although gdb/gdbserver/linux-low.c depends on __UCLIBC__. CLONE_VM is a kernel feature so gcc should be more appropriate but maybe it does not matter. Thanks, Jan gdb/gdbserver/ 2010-01-29 Jan Kratochvil PR libc/11214: * linux-low.c (linux_tracefork_child) [!(__UCLIBC__ && HAS_NOMMU)]: New. (linux_test_for_tracefork): Move `stack' into [__UCLIBC__ && HAS_NOMMU]. (linux_test_for_tracefork) [!(__UCLIBC__ && HAS_NOMMU)]: New. gdb/testsuite/ 2010-01-29 Jan Kratochvil PR libc/11214: * gdb.threads/current-lwp-dead.c (fn, main): Move CLONE_VM into [__uClinux__]. --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -2586,6 +2586,14 @@ linux_tracefork_child (void *arg) { ptrace (PTRACE_TRACEME, 0, 0, 0); kill (getpid (), SIGSTOP); + +#if !(defined(__UCLIBC__) && defined(HAS_NOMMU)) + + if (fork () == 0) + linux_tracefork_grandchild (NULL); + +#else /* defined(__UCLIBC__) && defined(HAS_NOMMU) */ + #ifdef __ia64__ __clone2 (linux_tracefork_grandchild, arg, STACK_SIZE, CLONE_VM | SIGCHLD, NULL); @@ -2593,6 +2601,9 @@ linux_tracefork_child (void *arg) clone (linux_tracefork_grandchild, arg + STACK_SIZE, CLONE_VM | SIGCHLD, NULL); #endif + +#endif /* defined(__UCLIBC__) && defined(HAS_NOMMU) */ + _exit (0); } @@ -2605,18 +2616,31 @@ linux_test_for_tracefork (void) { int child_pid, ret, status; long second_pid; +#if defined(__UCLIBC__) && defined(HAS_NOMMU) char *stack = xmalloc (STACK_SIZE * 4); +#endif /* defined(__UCLIBC__) && defined(HAS_NOMMU) */ linux_supports_tracefork_flag = 0; +#if !(defined(__UCLIBC__) && defined(HAS_NOMMU)) + + child_pid = fork (); + if (child_pid == 0) + linux_tracefork_child (NULL); + +#else /* defined(__UCLIBC__) && defined(HAS_NOMMU) */ + /* Use CLONE_VM instead of fork, to support uClinux (no MMU). */ #ifdef __ia64__ child_pid = __clone2 (linux_tracefork_child, stack, STACK_SIZE, CLONE_VM | SIGCHLD, stack + STACK_SIZE * 2); -#else +#else /* !__ia64__ */ child_pid = clone (linux_tracefork_child, stack + STACK_SIZE, CLONE_VM | SIGCHLD, stack + STACK_SIZE * 2); -#endif +#endif /* !__ia64__ */ + +#endif /* defined(__UCLIBC__) && defined(HAS_NOMMU) */ + if (child_pid == -1) perror_with_name ("clone"); @@ -2685,7 +2709,9 @@ linux_test_for_tracefork (void) } while (WIFSTOPPED (status)); +#if defined(__UCLIBC__) && defined(HAS_NOMMU) free (stack); +#endif /* defined(__UCLIBC__) && defined(HAS_NOMMU) */ } --- a/gdb/testsuite/gdb.threads/current-lwp-dead.c +++ b/gdb/testsuite/gdb.threads/current-lwp-dead.c @@ -51,8 +51,11 @@ fn (void *unused) stack = malloc (STACK_SIZE); assert (stack != NULL); - new_pid = clone (fn_return, stack + STACK_SIZE, CLONE_FILES | CLONE_VM, NULL, - NULL, NULL, NULL); + new_pid = clone (fn_return, stack + STACK_SIZE, CLONE_FILES +#ifdef __uClinux__ + | CLONE_VM +#endif /* __uClinux__ */ + , NULL, NULL, NULL, NULL); assert (new_pid > 0); return 0; @@ -67,8 +70,11 @@ main (int argc, char **argv) stack = malloc (STACK_SIZE); assert (stack != NULL); - new_pid = clone (fn, stack + STACK_SIZE, CLONE_FILES | CLONE_VM, NULL, NULL, - NULL, NULL); + new_pid = clone (fn, stack + STACK_SIZE, CLONE_FILES +#ifdef __uClinux__ + | CLONE_VM +#endif /* __uClinux__ */ + , NULL, NULL, NULL, NULL); assert (new_pid > 0); return 0;