From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sgHCNeryRWIFFAAAWB0awg (envelope-from ) for ; Thu, 31 Mar 2022 14:28:58 -0400 Received: by simark.ca (Postfix, from userid 112) id C77D81F163; Thu, 31 Mar 2022 14:28:58 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 325AE1ED17 for ; Thu, 31 Mar 2022 14:28:58 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DCF1388703B for ; Thu, 31 Mar 2022 18:28:57 +0000 (GMT) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by sourceware.org (Postfix) with ESMTPS id 5BB9B3858430 for ; Thu, 31 Mar 2022 18:28:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5BB9B3858430 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f53.google.com with SMTP id i132-20020a1c3b8a000000b0038ce25c870dso2189691wma.1 for ; Thu, 31 Mar 2022 11:28:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=VyulO6XCWNH7dUmoopHJg7mfCUuTLhjwdxNPyiko4Lw=; b=e9tvYdnXzv0oq6mKMrVDbRNHCTBKjG0eVABVQXOPGUD/FxIBj7AXsNZFzZaZQUPaNh 7ybXn7f/SNGWSIwqLAWzeygxsQtyXRsbYwPxwUSIeGpBFTgYVXaxgtHtm7g4C/VlPb// 5GiLWB/S9YsJ3ZgmFHbetS4hMlCIMnmGrEzpTB1XJbnJVM2XH02YRx7pHmca3j3iKsHo V6DiCt3zjkGxoY9bcHhwlKq/DnyXwL2pYzsIyrLjMmklFM3fLuPG6PjJcaVg1D2AsUz/ vAESlRXAQ2uVCoJr0D46VqC5+uiKMmcohId4Pldhe+MqjH8bNcYobr3wDKdN/2rojrdt p9mA== X-Gm-Message-State: AOAM530W/uYhSRwo1hmlmQR/Ei5+hPmc4hvceC3qK1qZVSC8Hh3bxQwf ghHkayDIDSFRuj3qvll82CY= X-Google-Smtp-Source: ABdhPJwhkQ6cHqIuZOLofFSdyK8vGQ9y8r8dcUbWi8+5KjTfOoS91JTzfe6kHvsR3A82t78R0sDn5A== X-Received: by 2002:a7b:cc17:0:b0:38d:af7:3848 with SMTP id f23-20020a7bcc17000000b0038d0af73848mr5719928wmh.41.1648751325424; Thu, 31 Mar 2022 11:28:45 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id t9-20020a05600c198900b0038cb8b38f9fsm8241789wmq.21.2022.03.31.11.28.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 31 Mar 2022 11:28:44 -0700 (PDT) Message-ID: <697452b1-271b-8802-1403-936e1b6bc706@palves.net> Date: Thu, 31 Mar 2022 19:28:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 8/8] gdb: resume ongoing step after handling fork or vfork Content-Language: en-US To: Simon Marchi , gdb-patches@sourceware.org References: <20220117162742.524350-1-simon.marchi@polymtl.ca> <20220117162742.524350-9-simon.marchi@polymtl.ca> From: Pedro Alves In-Reply-To: <20220117162742.524350-9-simon.marchi@polymtl.ca> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" [Lol, I reviewed this one twice, and the first time forgot to press send.] This is OK. Small nits in the testcase below. On 2022-01-17 16:27, Simon Marchi via Gdb-patches wrote: > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* Number of threads doing forks. */ > +#define N_FORKERS 4 > + > +static void * > +forker (void *arg) > +{ > + for (;;) > + { > + pid_t pid = FORK_FUNC (); > + > + if (pid == 0) > + _exit(11); Missing space before parens. > + > + assert (pid > 0); > + > + /* Wait for children to exit. */ > + int ret; > + int stat; > + do { { on the next line. Thus: > + ret = waitpid (pid, &stat, 0); > + } while (ret == EINTR); > + > + assert (ret == pid); > + assert (WIFEXITED (stat)); > + assert (WEXITSTATUS (stat) == 11); > + > + usleep (40 * 1000); Why not sleep_a_bit()? Is the fact that it's a little less time significant? > + } > + > + return NULL; > +} > + > +static void > +sleep_a_bit (void) > +{ > + usleep (1000 * 50); > +} > + > +int > +main (void) > +{ > + alarm (60); > + > + pthread_t thread[N_FORKERS]; > + for (int i = 0; i < N_FORKERS; ++i) Declare "int i" outside the loop so this compiles as C90 as well. Ditto below. > + { > + int ret = pthread_create (&thread[i], NULL, forker, NULL); > + assert (ret == 0); > + } > + > + for (int i = 0; i < INT_MAX; ++i) /* for loop */ > + { > + sleep_a_bit (); /* break here */ > + sleep_a_bit (); /* other line */ > + } > + > + for (int i = 0; i < N_FORKERS; ++i) > + pthread_join (thread[i], NULL); > + > + return 0; > +}