From patchwork Fri Dec 29 09:26:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 56554 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 D3F603858C50 for ; Fri, 29 Dec 2023 09:29:03 +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.133.124]) by sourceware.org (Postfix) with ESMTPS id 1770E3858C50 for ; Fri, 29 Dec 2023 09:27:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1770E3858C50 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 1770E3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703842039; cv=none; b=Sx+E2CE3JttmkObQkcV11MwQCwJKE1SQ8l/lKw1Rp7MEw8PR9kXve7z2Q6+yP6YVBEH/2+4xlHlbSREFKsrCEGYG75Iv1UhWlaDendU9UGpLda8GG2ERk5MRTNis3NrVGuCQHiiNUTANwU7ENn8IvOX3viUFTW9mmlbDjBYBZVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703842039; c=relaxed/simple; bh=XDJmwHvQZXyfb3iyDp1dQYJDcJKz4Ku48GeHBlOc2vo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Z01VZD9x+2PYI5PHMW1mtXWAUobQ6Loxnhq/LkfJb03XsU3mmqt03XZ57PJ4NoRH/CHywm2NfBg/ibX6XP+hH0nF2pRXRaAnd2+u+PgOWfPrWrGU64fE+Qw1kybdA4qqq+DiPCdyWPsxqnx53zwq5VpP9MTthPbeTZGLygMpZWo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703842036; 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=1ryjUTLcsacOe/2vUPV2uDNPxJvEl3NiVsmR3WqxvNU=; b=XKgqu2gqQ3zmRMRrM3m3Eil85NrEhrzlxcmawEMfRKO5KSFl9bA7qv0FKUXkxt3ruAGhRD M4v7s8N+/xatN2e3GDfK1qSNayAHTVjROiGbd6Hp3Ds9sREAgC3auOFMisqBTFe8pPHomS 0k5OHDUxJjev7PG5EapBTq1y/5++PI8= 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-538-CgdrkehYNIamYLZrYy2YXg-1; Fri, 29 Dec 2023 04:27:14 -0500 X-MC-Unique: CgdrkehYNIamYLZrYy2YXg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40d27ea0165so63411765e9.1 for ; Fri, 29 Dec 2023 01:27:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703842032; x=1704446832; 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=1ryjUTLcsacOe/2vUPV2uDNPxJvEl3NiVsmR3WqxvNU=; b=QNbntN6bfjhKTdB2g7aDac27T5MzwNZYWGf/Pe5XVlEQ/Fe/diJ472G5nUtlyl7zl7 sx2WGJQ6s+2SuqFqd4lZLMJTTKiEaFUUrj+uYvjMmww6dk4n9yiZqtbNKAFHMA5qw9lL aySTCQ6mjLBFDsrFLKlNM7Pvqjgx2cl4OxyuMK0YK3JXECHTGw20/ijaVqgizN4wTpZU Vv3PuAUdspAEIxupOIl/fCu00Aws1zFPW5dyRPqVFt6lYULgVrRKaAxV6FkDg3B49R84 SV37uAGVBFG779nfa+FGRZcdxIzPZDAvdE9Gy6tDz6OG0sAB8BYShThOsfoMyCcL+VY8 wWjw== X-Gm-Message-State: AOJu0YxB6R65+0B/Gk0uWqpIivUXS42w+MgqAk5Pic+7AKZOu3sk3qRA jzlEHE+UiMj0608jva06+Sf/fRpYec9/seuahjSn0U2PgEVgsoFQ824AR3xIQxQqZ4r8fSeSbrN 58sCOlmL6q7ZKdfthQNMRqIC3DO9fmASCDVE/em0Dl/q3pKvt7DgwVglzppTZOXypNK3UYH4eeh yOUWg+Jo3H9shN4g== X-Received: by 2002:a7b:cb8b:0:b0:40d:70c5:af16 with SMTP id m11-20020a7bcb8b000000b0040d70c5af16mr953536wmi.170.1703842031936; Fri, 29 Dec 2023 01:27:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCHCaRloUQBJUr7Z+KjtTc0UYRSEAx2cynXhdFaIhNI9UjC4mLPjWTB75eUVRAqNtrUJPVew== X-Received: by 2002:a7b:cb8b:0:b0:40d:70c5:af16 with SMTP id m11-20020a7bcb8b000000b0040d70c5af16mr953530wmi.170.1703842031520; Fri, 29 Dec 2023 01:27:11 -0800 (PST) Received: from localhost ([2a00:23c7:c696:e701:85a5:8a0c:1403:2dc]) by smtp.gmail.com with ESMTPSA id fm13-20020a05600c0c0d00b0040b37f107c4sm30631440wmb.16.2023.12.29.01.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:27:11 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv8 00/14] thread-specific breakpoints in just some inferiors Date: Fri, 29 Dec 2023 09:26:55 +0000 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=-6.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 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 (14): gdb: create_breakpoint: add asserts and additional comments gdb: create_breakpoint: asserts relating to extra_string/parse_extra gdb: change 'if' to gdb_assert in update_dprintf_command_list gdb: the extra_string in a dprintf breakpoint is never nullptr gdb: build dprintf commands just once in code_breakpoint constructor gdb: don't display inferior list for pending breakpoints gdb: remove breakpoint_re_set_one gdb: remove tracepoint_probe_create_sals_from_location_spec 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 | 701 ++++++++++++++++ gdb/break-cond-parse.h | 52 ++ gdb/breakpoint.c | 773 ++++++++---------- gdb/breakpoint.h | 109 ++- gdb/testsuite/gdb.ada/tasks.exp | 6 +- gdb/testsuite/gdb.base/condbreak.exp | 57 +- gdb/testsuite/gdb.base/pending.exp | 23 +- gdb/testsuite/gdb.linespec/explicit.exp | 4 +- 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 | 4 +- .../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-lib.c | 22 + gdb/testsuite/gdb.multi/pending-bp.c | 66 ++ gdb/testsuite/gdb.multi/pending-bp.exp | 332 ++++++++ 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 | 108 +++ gdb/tid-parse.c | 82 +- gdb/tid-parse.h | 8 + gdbsupport/common-utils.h | 10 + 32 files changed, 2279 insertions(+), 506 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.multi/pending-bp-lib.c create mode 100644 gdb/testsuite/gdb.multi/pending-bp.c create mode 100644 gdb/testsuite/gdb.multi/pending-bp.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: 90827b4eefb06f6e0ab6cbac9eb94922e2cc8aee