From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48791 invoked by alias); 23 Jan 2020 19:54:13 -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 48782 invoked by uid 89); 23 Jan 2020 19:54:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail.efficios.com Received: from mail.efficios.com (HELO mail.efficios.com) (167.114.26.124) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Jan 2020 19:54:11 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 4722824379A; Thu, 23 Jan 2020 14:54:10 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id iaubWX9fIAiB; Thu, 23 Jan 2020 14:54:10 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id F12CA24343B; Thu, 23 Jan 2020 14:54:09 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com F12CA24343B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1579809250; bh=7rAPq2flv7HACUPStxCZdn1VdDY8M2YcugD0Kcab4ug=; h=To:From:Message-ID:Date:MIME-Version; b=u5qLWcLsZAJXTnBG2NlDrQ6cGxtpKacJ2bfre8BM3UV9FwIW73+Pmt1H1O9DQHW8b SjB8lQDxwhkaTJPt9owIoe51CtDk+xIGJXktGlzYxM/EIWVsJDZV9K5mHxG0HuIJgv /99RD5D2pvH/umtvkgQXQYE/BXAtAfflVLvnjJIZiWvduHNe4wDTDUuiFQRoHiALPb lLAabrN8LPJ1n4+/Sab7jD3Ry4h9VSfMPHl6bjRRUt0lyhPX2XzHyCM2EUqqtrL0H6 ebWbsWFu1EhvEjJd5VYVPbAF9txmHCCNBG+ZX+KIDqb29m+xwOYNqKuguIloOTbwKq dIpakMbahuoXQ== Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ysz7sy89B2rY; Thu, 23 Jan 2020 14:54:09 -0500 (EST) Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id 993A3243438; Thu, 23 Jan 2020 14:54:09 -0500 (EST) Subject: Re: [PATCH] gdb: fix darwin-nat.c build / adapt to multi-target To: Pedro Alves , gdb-patches@sourceware.org Cc: Simon Marchi References: <20200123165938.32116-1-simon.marchi@efficios.com> From: Simon Marchi Message-ID: <8508df56-f2c5-7075-86c8-c08f9be8ee6d@efficios.com> Date: Thu, 23 Jan 2020 20:59:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-01/txt/msg00754.txt.bz2 On 2020-01-23 1:19 p.m., Pedro Alves wrote: > On 1/23/20 4:59 PM, Simon Marchi wrote: >> From: Simon Marchi >> >> The darwin-nat.c file doesn't build since the multi-target changes >> (5b6d1e4f, "Multi-target support"). This patch makes it build. I have >> access to a macOS vm, so I am able to build it, but I wasn't able to >> successfully codesign it and try to actually debug something, so I don't >> know if it works. I don't have much more time to put on this to figure >> it out, so I thought I'd sent the patch anyway, as it's at least a step >> in the right direction. >> >> The bulk of the patch is to change a bunch of functions to be methods of >> the darwin_nat_target object, so that this can pass `this` to >> find_inferior_ptid and other functions that now require a >> process_stratum_target pointer. >> >> The darwin_ptrace_him function (renamed to darwin_nat_target::ptrace_him >> in this patch) is passed to fork_inferior as the `init_trace_fun` >> parameter. Since the method can't be passed as a plain function pointer >> (we need the `this` pointer), I changed the `init_trace_fun` parameter >> of fork_inferior to be a gdb::function_view, so we can pass a lambda and >> capture `this`. > > This LGTM. Thanks for doing this. > > The use of function_view infork_inferior gave me pause, but it's safe > since fork_inferior doesn't return until the child either exec'ed or > exited -- there's no risk that the fork parent returns from the current > function before the fork child accesses the function_view's closure. Hmm, but the fork child doesn't use that callback anyway. I presume you thought this was about `traceme_fun`. > Note that this larger patch wasn't really necessary, since for native > targets there's only ever one process_stratum_target object. So you > could instead have referred to the global where you need it. > But your patch is better. Oh, I forgot about that. Well, it's clean this way :). > >> diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c >> index 78f972a7496d..ef5a75292fb1 100644 >> --- a/gdb/nat/fork-inferior.c >> +++ b/gdb/nat/fork-inferior.c >> @@ -267,7 +267,8 @@ execv_argv::init_for_shell (const char *exec_file, >> pid_t >> fork_inferior (const char *exec_file_arg, const std::string &allargs, >> char **env, void (*traceme_fun) (), >> - void (*init_trace_fun) (int), void (*pre_trace_fun) (), >> + gdb::function_view init_trace_fun, > > There should be a space in "void (int)". Ack. I'll push the patch with this fixed, thanks. Simon