From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10317 invoked by alias); 27 Jun 2018 14:30:55 -0000 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 Received: (qmail 1554 invoked by uid 89); 27 Jun 2018 14:30:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 14:30:51 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8614818A6B0; Wed, 27 Jun 2018 14:30:49 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3CEF1C678; Wed, 27 Jun 2018 14:30:48 +0000 (UTC) Subject: Re: [PATCH] nat/fork-inferior: include linux-ptrace.h To: Simon Marchi , Thomas Petazzoni References: <20180625080547.7629-1-thomas.petazzoni@bootlin.com> <3acce11a3e5ed352af945ab71739468b@polymtl.ca> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: Date: Wed, 27 Jun 2018 14:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <3acce11a3e5ed352af945ab71739468b@polymtl.ca> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-06/txt/msg00648.txt.bz2 On 06/27/2018 03:24 PM, Simon Marchi wrote: > On 2018-06-25 04:05, Thomas Petazzoni wrote: >> To decide whether fork() or vfork() should be used, fork-inferior.c >> uses the following test: >> >>   #if !(defined(__UCLIBC__) && defined(HAS_NOMMU)) >> >> However, HAS_NOMMU is never defined, because it gets defined in >> linux-ptrace.h, which is not included by fork-inferior.c. Due to this, >> gdbserver fails to build on noMMU architectures. This commit fixes >> that by simply including linux-ptrace.h. >> >> This bug was introduced by commit >> 2090129c36c7e582943b7d300968d19b46160d84 ("Share fork_inferior et al >> with gdbserver"). Indeed, the same fork()/vfork() selection was done, >> but in another file where linux-ptrace.h was included. >> >> Fixes the following build issue: >> >> ../nat/fork-inferior.c: In function 'pid_t fork_inferior(const char*, >> const string&, char**, void (*)(), void (*)(int), void (*)(), const >> char*, void (*)(const char*, char* const*, char* const*))': >> ../nat/fork-inferior.c:376:11: error: 'fork' was not declared in this scope >>      pid = fork (); >>            ^~~~ >> ../nat/fork-inferior.c:376:11: note: suggested alternative: 'vfork' >>      pid = fork (); >>            ^~~~ >>            vfork >> >> Signed-off-by: Thomas Petazzoni >> --- >>  gdb/nat/fork-inferior.c | 1 + >>  1 file changed, 1 insertion(+) >> >> diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c >> index 8b59387fa5..05167628a6 100644 >> --- a/gdb/nat/fork-inferior.c >> +++ b/gdb/nat/fork-inferior.c >> @@ -26,6 +26,7 @@ >>  #include "common-gdbthread.h" >>  #include "signals-state-save-restore.h" >>  #include "gdb_tilde_expand.h" >> +#include "linux-ptrace.h" >>  #include >> >>  extern char **environ; > > Hi Thomas, > > fork-inferior.c is also included in native builds for BSDs, AIX, Solaris and Darwin (see gdb/configure.nat).  I am a bit concerned that linux-ptrace.h could use some Linux-specific things, and thus would break the other builds.  However, I built-tested on FreeBSD and it seems fine.  Worst case, we can probably wrap this include in "#ifdef __linux__" if that becomes a problem. Please don't. It seems very wrong to me to include this header on other hosts. It is full of Linux-only details. Thanks, Pedro Alves