From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by sourceware.org (Postfix) with ESMTPS id 70ED238618EF for ; Fri, 20 Oct 2023 19:16:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70ED238618EF 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 70ED238618EF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697829394; cv=none; b=t4ah31q0u1IWaQZDD1/CkutgTkV06fEW0/nk+QMOJbJETmM4IvWJDWvYBmmZ/lGzQLjaZYLg5pvICxWeFoTh0bLt4k3BojHD3wjm5UJB9og1C+2Z+9BxB6rmvaQsEZYDdNFR6MbGBZaHEU5tdRhiZ3mhw5eqHxHdndcRXb82rFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697829394; c=relaxed/simple; bh=4PvmDnpTg0ZVQRz9uUyUoy2jwa5n9h10wkhaZb541hg=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=m7zi1vJFNdC4O5FjD/6DvUZkCIWLRodI9D3eih4d2Nk4xnwOeMz8gEgGeTNAK7Gh7tAe7KhrJX+kf4ZIQVhExzCYWC4dfkqztY1s2iN8j9mfzN5DnGLX6jlqOH1fOGYBlHZ6j103/LIHNg/FHrdu9K1/uTVkkmHm7M7IFQFL9iE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-40836ea8cbaso8814255e9.0 for ; Fri, 20 Oct 2023 12:16:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697829392; x=1698434192; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LK2SHnvsvs8NWmNZ0DuL9NYt4k4Hz5kwzUj8pMXjA/I=; b=Bltsw6wO3LMKZgAs9BGBHREE10xbXVARKutr+h2Fkic7zZI6jfOtGTbzhilmttGa8k POqU1LypNkbUF6vMkJaiatzLxHYRVzsa/af/DwqCdGQNv1sdNmJ3UdDe5Xh2sqqlbJBq qwbJFEtEAqO5JPK/2Wn59rxKLJ1TRS75cyuOKRR/5pWAUxAZQNqxPEEcoNTtnDSNHcgS W7v8hQgZ2xPUKd+cQ7so2WjITUBjOt2hJq9q/W1hBMOjBpm42gxihXhOYNjTOx/jfZ1B Ztm2CyjcN9TCaHEpcMoEp6/PSX6mosGPksTeL9k2ERS/X8gVBfrS1Hw0nHTzXOkjY3bu KZ9Q== X-Gm-Message-State: AOJu0YxMYN7IVuUPzaUCopdOfbafPUqHuK6wPMq4zvbr3nYgtqDhkP2C aUbB1AyujBjHGaL8yvXlRa0= X-Google-Smtp-Source: AGHT+IEtQIji1CGc+3to/55TtYgn3cFXxhkXrFshDB3bWiRG7i8d0GAdPZKG1cuSMrqGFWWU2I5Slw== X-Received: by 2002:a05:600c:a01:b0:405:7400:1e3d with SMTP id z1-20020a05600c0a0100b0040574001e3dmr2078782wmp.32.1697829391830; Fri, 20 Oct 2023 12:16:31 -0700 (PDT) Received: from ?IPV6:2001:8a0:f939:d200:ee35:b4ad:7014:7dd5? ([2001:8a0:f939:d200:ee35:b4ad:7014:7dd5]) by smtp.gmail.com with ESMTPSA id q11-20020a056000136b00b0032dc74c093dsm2257545wrz.103.2023.10.20.12.16.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Oct 2023 12:16:31 -0700 (PDT) Message-ID: Date: Fri, 20 Oct 2023 20:16:24 +0100 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: Tom de Vries , gdb-patches@sourceware.org References: <20231018171151.25427-1-tdevries@suse.de> <20231018171151.25427-4-tdevries@suse.de> From: Pedro Alves In-Reply-To: <20231018171151.25427-4-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no 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 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. Pedro Alves