From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by sourceware.org (Postfix) with ESMTPS id 999A93858D28 for ; Thu, 21 Mar 2024 18:38:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 999A93858D28 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 999A93858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711046321; cv=none; b=NlU92rkw0XRRc9fF2DZT3SqCy1nzX43TSg1+FiqBwO9Rg4t/a+Yzamn66rG1doJ9oiDOniRh5bzXSHDTZ1txR1zqLlL2dmdst+s0K2rvrCKSSlDnCMN+E2XfECoJiblbF0zZL8bbzKF0QUleOrpBqPXFg2xhQLgt42iRzunOHZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711046321; c=relaxed/simple; bh=qIRVqZjE2mPYaKoP0Wk9TRmvp9QGPPmbdAvM8BmrSu4=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=kyrJvysiMrypdf/zQOujUaWsrSpi+bzw6WtJayd4nNK5B0lAonynZut6tb7u8dF1cIIubbDiBJm4hnmGCShIZ/f7BJgCiWwt/11Hq88e32MVLV0GWD9g1+NSJSMwVkNxlCFAp1XftbsGDBJrRzmVOHlXhtn2g2JSCoCo4XtJYww= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-41478162b64so2551605e9.3 for ; Thu, 21 Mar 2024 11:38:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711046318; x=1711651118; h=content-transfer-encoding:in-reply-to:from:references:cc: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=Lv8W9rMkMu7NW1JZfBHx2egc7N378kC8rMTwPCJDLEc=; b=inYV/M7rjIgwWNkN9xtb0SA/eeV98JbuG88nbXdnxinamN4KPZL5tfUmv+24xn7Usm b9Usc3DnqMJPkAtlc0BlkNuNswpAl936+p9Zq2FWJjK11ficODKYC4eT7SGMv47fXxTM I2CcBuUWMIXxRh5rkfzxH9qgFu42nQVI+QniAh6swVvQmeHiQBNL6Bl19qxUt1RWKSFk VmVv0oGNUfYw/IA8AdOL3PIDaCJSRv0fG3Y58f/6fBob2AdmI1JXBVpX+bZGrbyj06/9 5sUMl1CPkisMqgFcNqUMpxxsXdKX5hVr1yJ5Tsjzjd/Zs4lk9jIX52/hKvQt54VcZUYa v/+A== X-Gm-Message-State: AOJu0Yw3pM/xncbvnu7rW6RO6XzOSVXCvtNvh3olwCUmf95i1yU0k5UY yfMxGennYl0VlaXhDnIi67dHU7LK48w269dOUEg7q/SbekTUwmY+ X-Google-Smtp-Source: AGHT+IEFm1MwznWfqJOUQx8Dc4sFbfhM5VGi81pfKDhF3Tjzduf1QjZC72nWmAbICK7Mh+mi2+KglA== X-Received: by 2002:a05:600c:4ed1:b0:413:f7a2:55e0 with SMTP id g17-20020a05600c4ed100b00413f7a255e0mr7213246wmq.30.1711046318193; Thu, 21 Mar 2024 11:38:38 -0700 (PDT) Received: from ?IPV6:2001:8a0:f918:ab00:5ea7:1bb:7941:5784? ([2001:8a0:f918:ab00:5ea7:1bb:7941:5784]) by smtp.gmail.com with ESMTPSA id je20-20020a05600c1f9400b0041462a42c82sm546731wmb.17.2024.03.21.11.38.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Mar 2024 11:38:37 -0700 (PDT) Message-ID: Date: Thu, 21 Mar 2024 18:38:35 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Fix setting watchpoints when current thread is running (PR gdb/31521) Content-Language: en-US To: Eli Zaretskii Cc: gdb-patches@sourceware.org References: <20240321164331.967577-1-pedro@palves.net> <86o7b71pe0.fsf@gnu.org> From: Pedro Alves In-Reply-To: <86o7b71pe0.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 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 2024-03-21 17:11, Eli Zaretskii wrote: >> From: Pedro Alves >> Date: Thu, 21 Mar 2024 16:43:31 +0000 >> >> Currently, when the current thread is running, you can print global >> variables. However, if you try to set a watchpoint on the same >> globals, GDB errors out, complaining that the selected thread is >> running. Like so: >> >> (gdb) c& >> Continuing. >> (gdb) p global >> $1 = 1098377287 >> (gdb) watch global >> Selected thread is running. >> >> This patch makes setting the watchpoint work. The problem is that >> update_watchpoint calls get_selected_frame unconditionally. We can >> skip it if the watchpoint expression is only watching globals. > > What does this mean in practice? E.g., suppose GDB sets the > watchpoint when the selected thread is changing the variable to be > watched -- will the thread stop or won't it? IOW, I don't understand > what happens with programming the debug registers while some thread is > running. GDB very briefly temporarily pauses all threads to program the debug registers, and immediately resumes them. But that is not user visible. That part actually always worked -- we needed to make that work for when the current thread you have selected is stopped, but there are other threads in the program that are running -- we need to arm the debug registers of those running threads too, so the target backend needs to know to pause any running thread. We just never reached that code when the _selected_ thread is running because very early in the "watch" code, we tried to get information about the current frame, while when the thread is running, there is no frame object to consult, thus GDB threw an error. > >> New NEWS blurb added. I don't think we need to change anything in the >> manual. > > If this is deemed a bugfix, then we don't need to say anything in > NEWS, either, IMO. OK, I was actually borderline with calling it a bug fix or a new feature. I will just drop NEWS then. Thanks! Pedro Alves