From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wNyYMztke2XdgiAAWB0awg (envelope-from ) for ; Thu, 14 Dec 2023 15:23:23 -0500 Received: by simark.ca (Postfix, from userid 112) id D0FE01E0C3; Thu, 14 Dec 2023 15:23:23 -0500 (EST) Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C11A11E0AC for ; Thu, 14 Dec 2023 15:23:21 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B9C8384DEEB for ; Thu, 14 Dec 2023 20:23:21 +0000 (GMT) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by sourceware.org (Postfix) with ESMTPS id C096738618F5 for ; Thu, 14 Dec 2023 20:22:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C096738618F5 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C096738618F5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702585375; cv=none; b=tLV86kNb9qf13so9w3+mQzbk6omCDtgA3pI8LIleY24FYt1AK7K/BGMWNLx0zVCkoDvhQuUe5bur/I7oBBdvZOkGzEZxaQKt+ah16orSrVPDU53ykXpNoUxdE53HGOq82YFB/dCzrybzGId04jLeg4VM+MTBXbEsnW300VrvdaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702585375; c=relaxed/simple; bh=aGcGeQVOc9ii0UHHGkkKHcFn99d+pPDOh020UrfgfX0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=xXfr8tDDRsUVQcRIOT+9Ukj3BZD+e8SiUk6LwMS4CSOXYzJ9Zz/YDuTYqApfj2Y9f5V4uA5eRdhgeqPF64zXGzmf4uRAzI4xBmnqjMgoYylziZobgrDCfj5ddlfVZ1TvNexlU7Z5U9idH3wBnAcA8f0/wT05GhtDlrmL8n+BcXY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-336445a2749so1189325f8f.0 for ; Thu, 14 Dec 2023 12:22:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702585372; x=1703190172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I1Higu9aMo8ZYN7IeeDxxEewR7Av2+i3U/0AhwN9Aas=; b=ua1uYLdY0O2agR257SwnmTYrt8X9DedXkjdwR0KI/ZYkY9ORZHSnbY1J1pqLref0fV gI8vvuZdTRoOqIvDSkzvWUVa7+EbM5J53bPFsT/opRsRSUYtASuRqcOOufBV7Dw+2GDP bJR5Xjwop3iPn9fNa/B5GL2+OzwcsUkY5wdBU39Dzx6Q9eWJDxbTP9/mad67sJLyC1iv 6fWHp3SLIEHixb5enwTGfJAAipaAh3Yl+LSvZl+WS5B6o0jdXyLwACyAZ4DUVxsRnszS Jd5RcBiGSo2+cxObHCRIroj3DczUZno4askX/cY33Cnr9X3ZCAyYoaidULs4zDvjWG5q HWsQ== X-Gm-Message-State: AOJu0YzPXtp++3e1K2HJprAT0XD2wetQ4Ha7/IviCU34baV/Qf+X4Zjk Dzkx7MX6jbhacN+brn3VFV/xgmln1eeipQ== X-Google-Smtp-Source: AGHT+IGYfe7NWkxbLq7jWqpBFUnFJp4v7u5amqgadoEoXOeuWsVQTiTE2djdyuBvn6pBa/IZmI253w== X-Received: by 2002:a5d:650d:0:b0:336:3db7:6e3e with SMTP id x13-20020a5d650d000000b003363db76e3emr1586507wru.96.1702585372362; Thu, 14 Dec 2023 12:22:52 -0800 (PST) Received: from localhost ([2001:8a0:f923:4f00:2646:535c:5a04:e380]) by smtp.gmail.com with UTF8SMTPSA id t5-20020a5d4605000000b0033646bf3e50sm2770469wrq.102.2023.12.14.12.22.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Dec 2023 12:22:51 -0800 (PST) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 4/8] Step over thread exit, always delete the thread non-silently Date: Thu, 14 Dec 2023 20:22:34 +0000 Message-ID: <20231214202238.1065676-5-pedro@palves.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231214202238.1065676-1-pedro@palves.net> References: <20231214202238.1065676-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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 With AMD GPU debugging, I noticed that when stepping over a breakpoint placed on top of the s_endpgm instruction inline (displaced=off), GDB would behave differently -- it wouldn't print the wave exit. E.g: With displaced stepping, or no breakpoint at all: stepi [AMDGPU Wave 1:4:1:1 (0,0,0)/0 exited] Command aborted, thread exited. (gdb) With inline stepping: stepi Command aborted, thread exited. (gdb) In the cases we see the "exited" notification, handle_thread_exit is what first called delete_thread on the exiting thread, which is non-silent. With inline stepping, however, handle_thread_exit ends up in update_thread_list (via restart_threads) before any delete_thread call. Thus, amd_dbgapi_target::update_thread_list notices that the wave is gone and deletes it with delete_thread_silent. This commit fixes it, by making handle_thread_exited call set_thread_exited (with the default silent=false) early, which emits the user-visible notification. Change-Id: I22ab3145e18d07c99dace45576307b9f9d5d966f --- gdb/infrun.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 76693a30611..1d863896c40 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -5885,6 +5885,13 @@ handle_thread_exited (execution_control_state *ecs) update the thread list and delete the event thread. */ bool abort_cmd = (ecs->event_thread->thread_fsm () != nullptr); + /* Mark the thread exited right now, because finish_step_over may + update the thread list and that may delete the thread silently + (depending on target), while we always want to emit the "[Thread + ... exited]" notification. Don't actually delete the thread yet, + because we need to pass its pointer down to finish_step_over. */ + set_thread_exited (ecs->event_thread); + /* Maybe the thread was doing a step-over, if so release resources and start any further pending step-overs. @@ -5904,10 +5911,6 @@ handle_thread_exited (execution_control_state *ecs) event thread again, as finish_step_over may have switched threads. */ switch_to_thread (ecs->event_thread); - - /* Emit [Thread ... exited] notification. */ - delete_thread (ecs->event_thread); - ecs->event_thread = nullptr; return false; } -- 2.43.0