From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 440653858D37 for ; Tue, 24 Oct 2023 12:34:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 440653858D37 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 440653858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.220.28 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698150882; cv=none; b=O3JB6WyTIql6vC01+7/k1CXcr3SB/+/tem6LyDIRfKEBRUn8yhoCnEvDUSzM0LSUvR+mCV2GmA7hvqbYSGQ2OD9lJ/tZAgOBREp5Z0AlQesoV3IrefgpkBYNDoed2Vw6qTmk7B1i5Ws113QGZSXA1fSj1EVsCp0lT8kxJyKxcQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698150882; c=relaxed/simple; bh=Q3AOp5yHUWEbFLJdIIOa6xFUmHQIM1aT/TIv/KeMAFU=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=FUzfEdCOlRQARx3htz+lpujvbqGf0+g1PE30FcuORIk4JEsjNCoG1HNfmVT93FcPLEZYTuLW/3UM1a+SqgpkprcP/LJlg2tVK4xoXpvkYJUxzSHUrXXuBOK+kichgP4WQCWDoUNeOPOYk71Xj1wsq4FtlbWgeXWOCPcNFuPNqIo= 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-out1.suse.de (Postfix) with ESMTPS id EF21E21BC9; Tue, 24 Oct 2023 12:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1698150879; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qCeBHVrMdGIS1mRRcyIBtuggorSdP3AJJ5Bu4fRkjS4=; b=JlkVNYSQ5UczE4dM0HAquCrt15P4CPy0SMhWWUgtEARmZqH5h8Q1IaJoBEHn/wIj+bzBC6 Sj7xHaobOMQvsPwqy9CL6QASZD9UqOa21qIhq0JMdlyQyG9g2iIS0PV0giCJuZY5rTzlc8 hk2SniifffLQ7LVFHP/93oNUqpe5XFo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1698150879; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qCeBHVrMdGIS1mRRcyIBtuggorSdP3AJJ5Bu4fRkjS4=; b=RQ4TE+twHs/Ev5oiuAEVg18EdBTdSB9bfSIzE66nu+ncWBpELqQeMJfq3riLVZE/CIUIJh zIAiHKC0uywVDfCw== 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 DB480134F5; Tue, 24 Oct 2023 12:34:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eIG+M9+5N2XUaAAAMHmgww (envelope-from ); Tue, 24 Oct 2023 12:34:39 +0000 Message-ID: Date: Tue, 24 Oct 2023 14:35:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 3/4] [gdb/cli] Allow source highlighting to be interrupted (continued) Content-Language: en-US To: Pedro Alves , gdb-patches@sourceware.org References: <20231018171151.25427-1-tdevries@suse.de> <20231018171151.25427-4-tdevries@suse.de> From: Tom de Vries In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -7.09 X-Spamd-Result: default: False [-7.09 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: On 10/20/23 21:16, Pedro Alves wrote: > On 2023-10-18 18:11, Tom de Vries wrote: >> 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. > > Hmm. This worries me. GDB is preparing to hand back control, but it isn't > yet done doing that. E.g., at the bottom of normal_stop, after notifying the > interpreters, we handle breakpoint auto delete. And then the caller of normal_stop > still has run control work to do which we better not skip. By switching to > the default_quit_handler in normal_stop, we risk a Ctrl-C running into a QUIT > and resulting in skipping all that code. Similarly, imagine if the MI "normal_stop" > observer runs into a QUIT and throws due to a Ctrl-C, and that makes GDB not print > the *stopped async record or some other bit of important info for the frontend. > That would leave the frontend out of sync. > > Also, overriding the overridden quit_handler is a bit of code smell. We can't > be sure that the right handler is the default_quit_handler. Better would be to force > the infrun_quit_handler override scoped_restore dtor (e.g., by wrapping that > scoped_restore in an optional, and passing down a reference to that so we could > clear the optional.) But that would likely look not-so-pretty. > > It just seems way safer to do this, to drop this patch. This means not using QUIT in > the next patch after all... I will reply to that patch next. Ack, dropped in v5 ( https://sourceware.org/pipermail/gdb-patches/2023-October/203505.html ). Thanks, - Tom