From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id AtgVO9DNJWpc+joAWB0awg (envelope-from ) for ; Sun, 07 Jun 2026 16:00:16 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Opq9AR0n; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D45F91E0A3; Sun, 07 Jun 2026 16:00:16 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 61E151E062 for ; Sun, 07 Jun 2026 16:00:16 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0BC674C9174D for ; Sun, 7 Jun 2026 20:00:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0BC674C9174D Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Opq9AR0n Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 108C54C900EC for ; Sun, 7 Jun 2026 19:58:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 108C54C900EC Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 108C54C900EC Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780862287; cv=none; b=ghErUub+vUWGVsH6Us2vEtMoXpTSK70t4qAM1rgk9L+Zq47KZX+5o+BN77HElkVCxqLRn3J/Jr1rFmfkxG8pXKK089XQi9Hz1YILN4sNYjRBzGaHG8JTxk6yGcI+i2JVqctK547oti0LjKhwBybP7MN/UcbN4SjmBD1O9OMJTMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780862287; c=relaxed/simple; bh=b80NtMqFGSI/yNKtDFlrjPifQR7I1PeeoMhi73m9UQg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=by8qLPpkBH6cI6W+3dWsMzY52xOyvdjth3x6i6Zdy6Jo8t55IleMuN6vLxExRIYVImHarmoM1DpfxgNQ96T60paYAmc3S46Qxy3Zs3rl+xBq/VJxc8NwkjGhdDbdb9BDRhUdF7QlpheUYtLpZjrqA+KH1FLIHqsXLoaSbNbToF0= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Opq9AR0n DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 108C54C900EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780862286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vKxxsuPVVHGruFWHuNIDgsiqtiFGeQKLIUbJGksZF5o=; b=Opq9AR0nqpt2SUP2F5BbILcXHbMIrLV3HeuEJPQU9hu4EPjt2Av37tpdnbttryAoi/5eRd 0mMJv+FR7b7+4LltEQeKFFWQKza1o4ve8TDX5fmtvaMRwOX1tYuKQ2tb6fTsiQLtpEhzA0 kcGSYME0NKRZsjHiEd3JyXD1DkMPAOo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-Aa7L5FuuNC6CLM1Nq3VcGA-1; Sun, 07 Jun 2026 15:58:03 -0400 X-MC-Unique: Aa7L5FuuNC6CLM1Nq3VcGA-1 X-Mimecast-MFC-AGG-ID: Aa7L5FuuNC6CLM1Nq3VcGA_1780862282 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-45eec2badc4so1746518f8f.2 for ; Sun, 07 Jun 2026 12:58:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780862282; x=1781467082; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vKxxsuPVVHGruFWHuNIDgsiqtiFGeQKLIUbJGksZF5o=; b=qAPDBB21o5fJ/vhXbLNCxUtu0LhD2nnYBUBhl4o653tPqNN9Rbimqa2Ctc0d4Nkw75 REBNICY8+BpsW3oM2U/LNAUB20bA0lESdeISrI4zPudPvh5jW64okhAffJRFM8Dxp23J GM/xtqW4kIjZ+vkFl00xDlnkzjrB8O+Nj/rOdw3QGusfeZzkRtpKcxs/7x616d1bZ2Gb 2gQq3RHy0y6ZHUCB7Dh/q7qtwNGvcXecwq2QImfdYqhc+ZZNyWRU5rD2zTEKriyQQ+QG G/bi5fRHnyMPFAMuLPrEmy6US+w42UJSO4A9FCjJlsvTfmNX11quzrY4K6P51LJdNQkZ /RMQ== X-Gm-Message-State: AOJu0YyiUVpz48jPddIdGqGRBSWi6miDYrqDa9y+61onlNX8Oqk6RtwV LK5SX7amGyGF9P9uBXGmp5uuwZwlfY5na1m96xL/KD+hDBBaqfwvHSRIHcf++PICgP0Ht2NvHQh lZN2XdOHmQTY3bmFDfCunTbJZ6bBFvwwckn68BfyNV3VvGcBZ/w9CBtB+rjOpWaTKdm3bhyg= X-Gm-Gg: Acq92OEcYi4DPgZTdnUM83MR5IuVxTeVQrVMEie9H+PF7rPwFpa3w5kkOdj9OcEserZ 3xyW7ebUigq246+yC3WScfgrbQDhLNcGcuNelKAjYYntk/37ki1ROEjLWo8ghpQD03YhIDcBmAV 1wkbJZ+raiefLe79NMc7TToVvkRXVsjoCxG6joApU4nlEC8tBkgfk93U0IILajZg0w8jPe+QVwH +9s/jv/pEszta18jFb8PPB3zvGboJQ0VQVL44tz2JQPChBJ31Icgi9OB1gHHB5cpVGrZhGyPMBI TVPqkG1s0U75FB36yBpXJcpB+luTY8MP9iDQtDT3n1B+c/ndxvVvLj4oscgPk0/N+L/jUwSEIW0 5d+7AC7i7XHAq6HoqGLc6RSGXeA== X-Received: by 2002:a5d:4d48:0:b0:45e:ea3a:47e8 with SMTP id ffacd0b85a97d-4603050350cmr14247334f8f.24.1780862282187; Sun, 07 Jun 2026 12:58:02 -0700 (PDT) X-Received: by 2002:a5d:4d48:0:b0:45e:ea3a:47e8 with SMTP id ffacd0b85a97d-4603050350cmr14247324f8f.24.1780862281788; Sun, 07 Jun 2026 12:58:01 -0700 (PDT) Received: from localhost ([213.31.44.97]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4602cda3651sm33932030f8f.32.2026.06.07.12.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2026 12:58:01 -0700 (PDT) From: Andrew Burgess To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb/python: avoid switching threads for send_packet where possible In-Reply-To: <878q925lrk.fsf@tromey.com> References: <878q925lrk.fsf@tromey.com> Date: Sun, 07 Jun 2026 20:58:00 +0100 Message-ID: <87o6hmqg1j.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lNbrjbrBVK2GY0RNUrwhkyXRLvJM1g3sWNkuCGEOy3g_1780862282 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Tom Tromey writes: >>>>>> "Andrew" == Andrew Burgess writes: > > Andrew> Bug PR gdb/32120 identifies a case where a user tried to write a > Andrew> custom frame unwinder that made use of > Andrew> RemoteTargetConnection.send_packet > > Just for the record this seems like a weird and bad choice. Probably, I ended up looking at this because I added the send_packet API, and I was curious why this didn't "just work". > > Andrew> scoped_restore_current_thread restore_thread; > Andrew> switch_to_target_no_thread (conn->target); > > Andrew> The purpose of this is to ensure that the currently selected inferior > Andrew> has the required remote connection pushed on its target stack. This > Andrew> is necessary because `send_remote_packet` (see remote.c) still relies > Andrew> on global state read from the currently selected inferior. > > Andrew> Switching inferior and thread like this, and then switching back > Andrew> thanks to the scoped restore, will flush the frame cache. > > ... > > Andrew> I propose that we special case connpy_send_packet so if the correct > Andrew> inferior is already current then we avoid the switch completely. This > Andrew> avoids flushing the frame cache, and all the associated problems. > > No problem with the patch at all, but I wonder about the logic of > putting this check here and not elsewhere. Like would we want some sort > of "switch to this inferior and we don't care which thread" -- which > would be a no-op if the inferior is already selected? I posted a v2 that moves the conditional logic into a new helper function. It's still a little weird because when we switch we likely want to use switch_to_target_no_thread which ends with no thread selected, while in the case where we don't need to switch we leave the current thread selected. That thread / no-thread difference is strange, but hopefully with a good comment it shouldn't cause too many problems. Anyway, feel free to checkout the V2 and see if that looks OK to you. Thanks, Andrew