From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 2B25F3858C5E for ; Wed, 18 Oct 2023 17:11:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B25F3858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2B25F3858C5E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697649081; cv=none; b=EsQafsdYrM5PGMzbvalntaGoDtJ9fViGKugZY92cYyWiXZLyliMpY71AQbjkgVi5Oi5WlDyo0+y5aM5Q91+YoY9Yhxr5k7ADRw4SHkrab/jormSz0Lshbk47cimIz9B4s5ixCRvzMPuS6UDK+G0xZK+Qzv14C6lyaSbVM5etAVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697649081; c=relaxed/simple; bh=CX8XXtnLQVr4A4M07UvJrxO/smXWrH2Q+/1tstRyzko=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=jtrddaxey1MV4i+72KYrtdFvGgD9klI9ftzzvgpkivzHOu3X6im09AnQrvRJihZoW0FnrO3KeXWWWQddnK/KZDpDAMFvjKwgSNbv0SqjV3IPSG3MHVKlb/DLtXjokGYyFDlvJQ/xdSMXYM8DovoZ6bWNSTezkFWvF/pEDfBi5O4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D093E1FD80 for ; Wed, 18 Oct 2023 17:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1697649078; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VOdCo68PyBJeQIJkP37EM3+FkJ1W06sraevE/gwmzNk=; b=HOj/WzfcSncaWdkY8jL+7Z4PWOmaAzuuZNZbAgK6Jw5FGYdf2WpEGC7jDiHsvIFZHMb0hX cL671Ec1FUjDG5YlaE9vmyXdGzqbtWkgTtdsgH9QPJX5ACR6v+LgT/jCDgqXup96stmZkl dTHXRxX6Gse0WY/8LP8+7smw1zn8+v8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1697649078; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VOdCo68PyBJeQIJkP37EM3+FkJ1W06sraevE/gwmzNk=; b=kbZZDlD27RE+3pdYnJi5YZk0lPCfZpshuSFhBORdDt1uV5IS6St+s5NY4s4RN89klP0v/v 4AFpLpj3+qzMTxCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BD951139E0 for ; Wed, 18 Oct 2023 17:11:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KCwpLbYRMGXZLQAAMHmgww (envelope-from ) for ; Wed, 18 Oct 2023 17:11:18 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v4 3/4] [gdb/cli] Allow source highlighting to be interrupted (continued) Date: Wed, 18 Oct 2023 19:11:50 +0200 Message-Id: <20231018171151.25427-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231018171151.25427-1-tdevries@suse.de> References: <20231018171151.25427-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -0.73 X-Spamd-Result: default: False [-0.73 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-3.00)[-1.000]; TO_DN_NONE(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-1.63)[92.63%] X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: In PR cli/30934, a problem is reported where gdb becomes unresponsive for 2m13s because the GNU source-highlight library is taking a lot of time to annotate the source: ... $ gdb -q a.out -ex "b 56" Reading symbols from a.out... Breakpoint 1 at 0x400e2a: file test.cpp, line 56. (gdb) run Starting program: /data/vries/gdb/a.out Breakpoint 1, Solution::numOfSubarrays () at test.cpp:56 <... wait for it ...> 56 return (int) t; (gdb) ... This is due to a problem in the library [1], for which I've posted a patch [2], which brings down the annotation time to 3s. However, GDB should not become unresponsive due to such a problem. The previous patch allows us to interrupt a list command during highlighting by either SIGTERM or SIGINT. In this case, we can use SIGTERM to interrupt the run command, but not SIGINT. This is due to the fact that the infrun_quit_handler is still active. The purpose of infrun_quit_handler is to: - if !target_terminal::is_ours, pass ^C to the inferior, and - if target_terminal::is_ours, ignore ^C. If gdb is executing say a continue in the background, it generates events and we don't want to interrupt the handling of these events. In this case however, the reason target_terminal::is_ours is not because there's background execution, but because normal_stop has decided that we have stopped execution, and it's preparing to hand back control to GDB. Fix this by switching back to the default_quit_handler during notify_normal_stop. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30934 [1] https://savannah.gnu.org/bugs/?64747 [2] https://savannah.gnu.org/patch/index.php?10400 --- gdb/infrun.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 4fde96800fb..816a76a1b2c 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9063,12 +9063,23 @@ normal_stop () if (saved_context.changed ()) return true; - /* Notify observers about the stop. This is where the interpreters - print the stop event. */ - notify_normal_stop ((inferior_ptid != null_ptid - ? inferior_thread ()->control.stop_bpstat - : nullptr), - stop_print_frame); + { + /* If the current quit_handler is infrun_quit_handler, and + target_terminal::is_ours, pressing ^C is ignored by QUIT. See + infrun_quit_handler for an explanation. At this point, there's + no need for this behaviour anymore, and we want to be able to interrupt + notify_normal_stop, so install the default_quit_handler. */ + scoped_restore restore_quit_handler + = make_scoped_restore (&quit_handler, default_quit_handler); + + /* Notify observers about the stop. This is where the interpreters + print the stop event. */ + notify_normal_stop ((inferior_ptid != null_ptid + ? inferior_thread ()->control.stop_bpstat + : nullptr), + stop_print_frame); + } + annotate_stopped (); if (target_has_execution ()) -- 2.35.3