Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: "H.J. Lu" <hjl.tools@gmail.com>, GDB <gdb@sourceware.org>
Subject: Re: [patch] Fix CLONE_VM vs. TLS  [Re: Is CLONE_VM really needed in    gdbserver?]
Date: Fri, 29 Jan 2010 12:41:00 -0000	[thread overview]
Message-ID: <20100129124128.GA6588@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <20100129023040.GA20267@caradoc.them.org>

On Fri, 29 Jan 2010 03:30:43 +0100, Daniel Jacobowitz wrote:
> On Fri, Jan 29, 2010 at 02:26:25AM +0100, Jan Kratochvil wrote:
> > 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.
> 
> It's the __UCLIBC_HAS_MMU__ / __ARCH_HAS_MMU__ that make this OK; the end
> result is functionally equivalent to a __uClinux__ check.  uClibc can
> be used on full Linux too, and there you have fork.

In such case __uClinux__ can be unified with what is already in use in
linux-low.c.

Going to check it in in some times as this change is IMO pre-approved.


Thanks,
Jan


gdb/gdbserver/
2010-01-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

	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  <jan.kratochvil@redhat.com>

	PR libc/11214:
	* gdb.threads/current-lwp-dead.c: Include features.h.
	(HAS_NOMMU): New.
	(fn, main): Move CLONE_VM into [__UCLIBC__ && HAS_NOMMU].

--- 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
@@ -30,6 +30,13 @@
 #include <unistd.h>
 #include <stdlib.h>
 
+#include <features.h>
+#ifdef __UCLIBC__
+#if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
+#define HAS_NOMMU
+#endif
+#endif
+
 #define STACK_SIZE 0x1000
 
 static int
@@ -51,8 +58,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
+#if defined(__UCLIBC__) && defined(HAS_NOMMU)
+		   | CLONE_VM
+#endif /* defined(__UCLIBC__) && defined(HAS_NOMMU) */
+		   , NULL, NULL, NULL, NULL);
   assert (new_pid > 0);
 
   return 0;
@@ -67,8 +77,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
+#if defined(__UCLIBC__) && defined(HAS_NOMMU)
+		   | CLONE_VM
+#endif /* defined(__UCLIBC__) && defined(HAS_NOMMU) */
+		   , NULL, NULL, NULL, NULL);
   assert (new_pid > 0);
 
   return 0;


  reply	other threads:[~2010-01-29 12:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6dc9ffc81001261551j6221db6v88e96713d6dd9497@mail.gmail.com>
     [not found] ` <20100127000821.GA29862@caradoc.them.org>
2010-01-27 22:12   ` Jan Kratochvil
2010-01-28 16:22     ` H.J. Lu
2010-01-28 17:01     ` Daniel Jacobowitz
2010-01-29  1:26       ` Jan Kratochvil
2010-01-29  2:30         ` Daniel Jacobowitz
2010-01-29 12:41           ` Jan Kratochvil [this message]
2010-02-01 20:20             ` Jan Kratochvil

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=20100129124128.GA6588@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=gdb@sourceware.org \
    --cc=hjl.tools@gmail.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