From patchwork Fri Sep 6 09:10:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 57427 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6E94384A49C for ; Fri, 6 Sep 2024 09:11:49 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 1D86E3858408 for ; Fri, 6 Sep 2024 09:11:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1D86E3858408 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1D86E3858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725613877; cv=none; b=YJJasWv+fI5UwJJOTwI9hYUPMCCHDkloeI3v5W2ZLoeobppdD/NIoC03R4N3zAAWnqneSRcTU+V8RoBffT1KjdHNSVyfiMdwLwjLaL8ujZzdfK/7TZ8HdeMfwQA2WVfsoOSfiFMQvYuW85s3ERPWUtAy+fABsyL3CTRFPoQxo68= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725613877; c=relaxed/simple; bh=K9tU5sI7hkd27fw7+A/Iz0OggULQSJ3UTkKA/5Z0bCk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=rTbKrvxt3irg284UFiDXh6zbUl9Ds6DTq794yJlGJL+5wI4HlavWcyLCXTMEWqfZLyOZTn7vZ1+dR0da5ZDBhj1VsOB27LAOGBN6kMLK90OG5STlA1eWSuJYmeLPwNt56/BdNTdkjsFEFpJ7khx2u+NX2+y7yE5qVnXQkdWBpXc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725613872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ExWPNcgLNrYw68/vF7BRhEaNdObnOFvIv88NcEbtjTE=; b=O9StpHCuLE+AwvGGXEJGgc+RxuRBQRnhWBnTMsp+MZd9iedatk+D36huafTT46u1Qx5Bgb IgcfXLkiQGX4N65nnCuCBLc0fW2BLr72XtIcwZuG5odB5ZyjWk64714MT3fZiYgSTNvuZS VrcTQUwo9wX2TRKfG3zR71zL5w5tcLo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-WWVXPCWxOjq722XxvVuaXg-1; Fri, 06 Sep 2024 05:11:09 -0400 X-MC-Unique: WWVXPCWxOjq722XxvVuaXg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42c82d3c7e5so14674755e9.2 for ; Fri, 06 Sep 2024 02:11:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725613868; x=1726218668; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ExWPNcgLNrYw68/vF7BRhEaNdObnOFvIv88NcEbtjTE=; b=o5pxZvJ+SCPS54hEuAK3cAMbD0deT+D5LIEVMqXNgaWZOPDeujyzHItN7AqoIP+nhu mX6oqYXQtX47z3fCB5tHe5h9ghTrhNRgUVZz5ZiBgPFpFxKe+5IfQGeebJ4+RiAKZEZK MFbQ5hlC5So2xVcFtL8k1/QzTz58oF0e7DFB+t6ahrO51Okdm+7QyA5VSIgtk35Dj2rp 6RkeWRfxzG/9pw7pdp5OVpmDHWml4U6QQj4Nf1Tvg9U39VEu9RD+VUkMZEc9d1+cSok+ T6t2N2IgH+dT4GcVvbjv4kr/iQZxIflZSgzHJVLQeJJN1z9MxbNupC8wAS4JNB8zfP1/ pyFw== X-Gm-Message-State: AOJu0Yx2fi+dooA8t4ZmPuU4Zn5cDttJYvPw3r0gBlKluoGgc2uhHlzG 2Wv+/l6pWTd0p0P3dmFOh4OUOhBJ+JBirPEjCb6zOhzb9l/xAunaWlMj/tBZ1dktvTAAG9llWg8 aT/YfWtXBudQ/g86dCqpZ05LUiiYOV84Ev6ReTCIYQvadJGAPFwxb/WsrhgKrpQVOHJI+CR8koe mx4lI5/JcNVJ383MtzuoaGvecf8Jup5HjqvWujhB8HbeQ= X-Received: by 2002:a05:600c:19d2:b0:426:6f1e:ce93 with SMTP id 5b1f17b1804b1-42c9f9dd28bmr10592455e9.33.1725613867610; Fri, 06 Sep 2024 02:11:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuTCdxj3xw60tQakxe+yR6Ay1Ylq7gLrtddINDtRJT4nh9G7/tQTsT/fjWl8ahayMeEx2E7A== X-Received: by 2002:a05:600c:19d2:b0:426:6f1e:ce93 with SMTP id 5b1f17b1804b1-42c9f9dd28bmr10591845e9.33.1725613866233; Fri, 06 Sep 2024 02:11:06 -0700 (PDT) Received: from localhost (178.126.90.146.dyn.plus.net. [146.90.126.178]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ca3a3cc31sm7518845e9.24.2024.09.06.02.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 02:11:05 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv13 0/6] thread-specific breakpoints in just some inferiors Date: Fri, 6 Sep 2024 10:10:57 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TVD_PH_BODY_ACCOUNTS_PRE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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~patchwork=sourceware.org@sourceware.org I'm planning to merge the rest of this series once my testing has completed unless someone asks me not too. Obviously I'll address anything that crops up after committing. --- In v13: - Rebased to current HEAD of master. Resolved some minor merge conflicts in breakpoint.{c,h} for the last patch, and updated the patch to take account of catchpoint::re_set() which was added recently. - Moved the NEWS entries now that GDB 15 has been released. In v12: - First 3 patches from previous version have now been merged, - Rebased to current master and retested. Few minor testsuite changes to account for other changes in the master branch, nothing major though. In v11: - Rebased on to current upstream master. No significant merge issues found. Retested, no issues found. In v10: - I merged the first 5 patches. These were mostly just adding extra asserts, or minor refactoring and cleanup that didn't change GDB's behaviour. Patch #2 did have a minor behaviour change, but this was just removing some (I think) unintended behaviour, - Rebased onto current upstream/master branch, - No other changes since v9. In v9: - Rebased onto current upstream/master branch, - Minor testsuite fix to account for updated output from GDB, - No other changes since v8. In v8: - Rebased onto current upstream/master branch. - Reordered the patches a little. Patches 0 to 8 are unchanged from previous. If there's no objections then I'm planning to merge these some point soon as I think these are all good cleanup patches. - Patches 9, 10, and 11 are new. These are also refactoring commits, but are all tied pretty tightly to what is now patch 12. - Patch 12 is the most important patch. This has had a complete rewrite since V7 in order to address Tom's feedback. The general idea is unchanged; the breakpoint condition string is parsed first forwards, and then backwards, but we now have a two phase analysis, rather than immediately parsing things like the thread-id as we find them. This resolves this problem: (gdb) break some_function if ( 3 == thread ) Previous GDB would try to match 'thread )' as a thread-id and give an error that ')' as invalid. Now GDB correctly understands that the 'thread )' is likely part of the 'if' condition, and parses it as such. - Patches 13 and 14 are unchanged from V7. These patches depend on the changes in patch 12 so can't be merged without that patch. In v7: - Addressed all the issues except one that Baris pointed out, this includes typos, some minor testsuite cleanups, and reformatting an assert (but not changing the meaning). - As requested, switched to use std::string_view in break-parse-cond.c file instead of a custom class, I agree that this is an improvement. - I've not changed the handling of -force-condition flag. I replied to the review email with my thoughts, TLDR: fixing this would be a bigger task which I'd rather leave for ... the future. - Rebased and retested. In v6: - Rebased to current master, one minor fix due to the C++17 changes, nothing major. Retested. In v5: - Updates after Lancelot's feedback, including, -force-condition can no longer be abbreviated to '-', and can't be used immediately after the breakpoint condition. - More tests to check some of the edge cases. In v4: - Big update, this series now handles thread-specific and inferior-specific breakpoints. In v3: - Rebased on to current upstream/master, this includes all Simon's recent breakpoint changes. Retested with no regressions seen. In v2: - Rebased on current upstream/master and retested, - No changes to code or docs. --- Andrew Burgess (6): gdb: make breakpoint_debug_printf global gdb: add another overload of startswith gdb: create new is_thread_id helper function gdb: parse pending breakpoint thread/task immediately gdb: don't set breakpoint::pspace in create_breakpoint gdb: only insert thread-specific breakpoints in the relevant inferior gdb/Makefile.in | 2 + gdb/NEWS | 11 + gdb/ada-lang.c | 6 +- gdb/break-catch-throw.c | 6 +- gdb/break-cond-parse.c | 702 ++++++++++++++++++ gdb/break-cond-parse.h | 52 ++ gdb/breakpoint.c | 671 ++++++++--------- gdb/breakpoint.h | 63 +- gdb/testsuite/gdb.ada/tasks.exp | 6 +- gdb/testsuite/gdb.base/condbreak.exp | 57 +- gdb/testsuite/gdb.base/pending.exp | 30 +- gdb/testsuite/gdb.linespec/explicit.exp | 14 +- gdb/testsuite/gdb.linespec/keywords.exp | 8 +- gdb/testsuite/gdb.mi/mi-dprintf-pending.exp | 3 +- gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp | 8 +- .../gdb.mi/user-selected-context-sync.exp | 14 +- .../gdb.multi/bp-thread-specific.exp | 7 +- .../gdb.multi/inferior-specific-bp.exp | 16 +- .../gdb.multi/multi-target-continue.exp | 2 +- .../gdb.multi/multi-target-ping-pong-next.exp | 4 +- .../gdb.multi/pending-bp-del-inferior.c | 28 + .../gdb.multi/pending-bp-del-inferior.exp | 214 ++++++ gdb/testsuite/gdb.multi/pending-bp.exp | 206 +++++ gdb/testsuite/gdb.multi/tids.exp | 6 +- .../gdb.threads/del-pending-thread-bp-lib.c | 22 + .../gdb.threads/del-pending-thread-bp.c | 85 +++ .../gdb.threads/del-pending-thread-bp.exp | 98 +++ gdb/tid-parse.c | 82 +- gdb/tid-parse.h | 8 + gdbsupport/common-utils.h | 10 + 30 files changed, 1994 insertions(+), 447 deletions(-) create mode 100644 gdb/break-cond-parse.c create mode 100644 gdb/break-cond-parse.h create mode 100644 gdb/testsuite/gdb.multi/pending-bp-del-inferior.c create mode 100644 gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp create mode 100644 gdb/testsuite/gdb.threads/del-pending-thread-bp-lib.c create mode 100644 gdb/testsuite/gdb.threads/del-pending-thread-bp.c create mode 100644 gdb/testsuite/gdb.threads/del-pending-thread-bp.exp base-commit: 237df762d73a7fdf910277b0644df58688d2d87a