From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 2DF0B3858C83 for ; Fri, 1 Apr 2022 18:43:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2DF0B3858C83 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 231IgqQv025369 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 1 Apr 2022 14:42:57 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 231IgqQv025369 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 028801E787; Fri, 1 Apr 2022 14:42:51 -0400 (EDT) Message-ID: <91b49c61-5371-0d12-5a3a-121500fe2cd6@polymtl.ca> Date: Fri, 1 Apr 2022 14:42:45 -0400 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: Pedro Alves , gdb-patches@sourceware.org Cc: Simon Marchi References: <20220117162742.524350-1-simon.marchi@polymtl.ca> <20220117162742.524350-9-simon.marchi@polymtl.ca> <697452b1-271b-8802-1403-936e1b6bc706@palves.net> From: Simon Marchi In-Reply-To: <697452b1-271b-8802-1403-936e1b6bc706@palves.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 1 Apr 2022 18:42:52 +0000 X-Spam-Status: No, score=-3032.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 01 Apr 2022 18:43:04 -0000 >> +#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. Done. > >> + >> + assert (pid > 0); >> + >> + /* Wait for children to exit. */ >> + int ret; >> + int stat; >> + do { > > { on the next line. Thus: Done (and re-indented the whole do-while). Is there a missing part to your comment that should come after "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? Ah, good question. We need the forking threads to fork reasonably often, if we want the bug to reproduce most of the time. But we need some sleep, with any sleep the forking threads just spam events and starve the stepping thread, and we don't really make progress. I'll add a comment to that effect. > >> + } >> + >> + 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. Done. Simon