From patchwork Thu Jun 14 22:54:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Korolev X-Patchwork-Id: 27866 Received: (qmail 68604 invoked by alias); 14 Jun 2018 22:54:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 68582 invoked by uid 89); 14 Jun 2018 22:54:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HTML_MESSAGE, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=corner, H*c:alternative X-HELO: mail-oi0-f67.google.com Received: from mail-oi0-f67.google.com (HELO mail-oi0-f67.google.com) (209.85.218.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Jun 2018 22:54:55 +0000 Received: by mail-oi0-f67.google.com with SMTP id a141-v6so7203207oii.8 for ; Thu, 14 Jun 2018 15:54:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=tLJF+1DKHTKAdtUK3Zd0hcApw6JZ8/ojooT7gWTBoVo=; b=SqAYsxbsSLxZdAwHXFVfqswSrjzi4nwjhyqP51S2h3YWj7Tu8V9qM/sQfOApTpuYpP ze3iqncc19p08thfiFW4gGrLWnbwtFYJiVtzc39e6fO31yFK2rwoJDPTGBKMrIdgwIAX oQzmrOyODnnU3kkhrAbTJozIzHwJWZuUPvrKz74N60deoTWN6xdfFzRGe8P+00VAkFKW qrdgJTazKNYMxeKz1gUBrMsJL1089Mcyx1//pJkZQT4N4Rv4hpo6DJXe0wvEpiK7OwB8 9v018VgzDkPg/C1l3NGErb0+EfQuHCOavYv+WPSzxHt1l/7/+2ZsFbkbA1ElUAWJq1cR DMng== X-Gm-Message-State: APt69E0TwnWax7boZ7+53ChTf1rw++lWSvQHnx5jaCRK3+GULgXtMSrr Bm4yz6xmeyEbCfmD65jva6XmnYCuTihfus1c2hXPoo8p X-Google-Smtp-Source: ADUXVKJLvdP1g3KX6ZCMyazt4mee3MKIPfOQ9wY4NcOOXOyu/nnfxhR/ASlZ+K7ScufftXIoX2oNGCNCTjUuAO6ZemI= X-Received: by 2002:aca:b287:: with SMTP id b129-v6mr2236781oif.148.1529016893185; Thu, 14 Jun 2018 15:54:53 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:4b97:0:0:0:0:0 with HTTP; Thu, 14 Jun 2018 15:54:12 -0700 (PDT) From: Sergey Korolev Date: Fri, 15 Jun 2018 01:54:12 +0300 Message-ID: Subject: [PATCH] MIPS/GDB/linux-nat.c: Fix a child detach condition for uClibc-ng To: gdb-patches@sourceware.org X-IsSubscribed: yes Current implementation expects that WIFSTOPPED (W_STOPCODE (0)) is true, but in the uClibc-ng it is false on MIPS. The patch adds a "detach" helper variable to avoid this corner case: WIFSTOPPED applied only to a status filled by a waitpid call that should never return the status with zero stop signal. --- gdb/linux-nat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) @@ -492,9 +493,11 @@ linux_nat_target::follow_fork (int follow_child, int detach_fork) perror_with_name (_("Couldn't do single step")); if (my_waitpid (child_pid, &status, 0) < 0) perror_with_name (_("Couldn't wait vfork process")); + else + detach = WIFSTOPPED (status); } - if (WIFSTOPPED (status)) + if (detach) { int signo; diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 445b59fa4a..916de2d335 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -468,6 +468,7 @@ linux_nat_target::follow_fork (int follow_child, int detach_fork) /* Detach new forked process? */ if (detach_fork) { + int detach = 1; struct cleanup *old_chain = make_cleanup (delete_lwp_cleanup, child_lp);