From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oKUmNIFDZWN4ERQAWB0awg (envelope-from ) for ; Fri, 04 Nov 2022 12:53:21 -0400 Received: by simark.ca (Postfix, from userid 112) id D38C41E124; Fri, 4 Nov 2022 12:53:21 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Rl12XF7y; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 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 658971E0D3 for ; Fri, 4 Nov 2022 12:53:21 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05FDA38582A3 for ; Fri, 4 Nov 2022 16:53:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05FDA38582A3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667580801; bh=snETJ3d+tmLDoROijBwTOPWXybTzhhtSYWy7tjL+2Do=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Rl12XF7ydGkrPORKzDqo61l0UkmhIN38F6AxE3nXu8Uv/TjQsU0rW7lVyRnSiCEHo mGXX1iT/nvqRVGDMViG4WKxrx2MtfQca3c1r49EHbheztin5VBcpG/wPZMschMeerK REtfHgUUpxR5FIfYRbsgvvhZ/T2cC06oD3E6sCr8= Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 2E9FF3858D32 for ; Fri, 4 Nov 2022 16:52:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E9FF3858D32 Received: from [172.16.42.100] (modemcable092.73-163-184.mc.videotron.ca [184.163.73.92]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id B40EE1E0D3; Fri, 4 Nov 2022 12:52:55 -0400 (EDT) Message-ID: Date: Fri, 4 Nov 2022 12:52:55 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH] gdb: make "start" breakpoint inferior-specific Content-Language: fr To: Bruno Larsen , gdb-patches@sourceware.org References: <20220804174035.2441960-1-simon.marchi@efficios.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 8/31/22 10:03, Bruno Larsen via Gdb-patches wrote: > On 04/08/2022 19:40, Simon Marchi via Gdb-patches wrote: >> I saw this failure on a CI: >> >>      (gdb) add-inferior >>      [New inferior 2] >>      Added inferior 2 >>      (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: add-inferior >>      inferior 2 >>      [Switching to inferior 2 [] ()] >>      (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: inferior 2 >>      kill >>      The program is not being run. >>      (gdb) file /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior-sleep >>      Reading symbols from /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior-sleep... >>      (gdb) run & >>      Starting program: /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior-sleep >>      (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: run inferior 2 >>      inferior 1 >>      [Switching to inferior 1 [] ()] >>      (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: inferior 1 >>      kill >>      The program is not being run. >>      (gdb) file /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior >>      Reading symbols from /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior... >>      (gdb) break should_break_here >>      Breakpoint 1 at 0x11b1: file /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/src/binutils-gdb/gdb/testsuite/gdb.threads/vfork-multi-inferior.c, line 25. >>      (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: break should_break_here >>      [Thread debugging using libthread_db enabled] >>      Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". >>      start >>      Temporary breakpoint 2 at 0x11c0: -qualified main. (2 locations) >>      Starting program: /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior >>      [Thread debugging using libthread_db enabled] >>      Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". >> >>      Thread 2.1 "vfork-multi-inf" hit Temporary breakpoint 2, main () at /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/src/binutils-gdb/gdb/testsuite/gdb.threads/vfork-multi-inferior-sleep.c:23 >>      23      sleep (30); >>      (gdb) FAIL: gdb.threads/vfork-multi-inferior.exp: method=non-stop: start inferior 1 >> >> What happens is: >> >>   1. We start inferior 2 with "run&", it runs very slowly, takes time to >>      get to main >>   2. We switch to inferior 1, and run "start" >>   3. The temporary breakpoint inserted by "start" applies to all inferiors >>   4. Inferior 2 hits that breakpoint and GDB reports that hit >> >> To avoid this, breakpoints inserted by "start" should be >> inferior-specific.  However, we don't have a nice way to make >> inferior-specific breakpoints yet.  It's possible to make >> pspace-specific breakpoints (for example how the internal_breakpoint >> constructor does) by creating a symtab_and_line manually.  However, >> inferiors can share program spaces (usually on particular embedded >> targets), so we could have a situation where two inferiors run the same >> code in the same program space.  In that case, it would just not be >> possible to insert a breakpoint in one inferior but not the other. >> >> A simple solution that should work all the time is to add a condition to >> the breakpoint inserted by "start", to check the inferior reporting the >> hit is the expected one.  This is what this patch implements. >> >> Add a test that does: >> >>   - start a background inferior 1 that calls main in a loop >>   - start aninferior 2 with the "start" command >>   - validate that we hit the breakpoint in inferior 2 >> >> Without the fix, we hit the breakpoint in inferior 1 pretty much all the >> time. >> >> Change-Id: Ib0148498a476bfa634ed62353c95f163623c686a > > Hi Simon, > > This change makes a lot of sense, I just wonder if it would make sense to make breakpoints inferior-specific. I could see a situation where someone would run the same program twice, one with an ok input while the other has a buggy input for instance, to see the difference between them, and inferior-specific breakpoints could come in handy in a situation like this. > > If you think it would be too much work for a usecase that is too niche, this patch is pretty straight forward, I'd suggest you approve your patch. I certainly don't want to add a new user-facing feature just for this fix, as that's a lot of work (figuring out the syntax, doc, NEWS, tests, etc). We could enhance the internal API to allow passing an inferior to make a breakpoint inferior-specific, but I don't think it should be a prerequisite for this fix. It would end up doing functionally identical. Would you like to to add your Reviewed-By on this patch? Simon