From patchwork Mon Dec 12 20:30:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 61839 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 ED10F3871F98 for ; Mon, 12 Dec 2022 20:33:38 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by sourceware.org (Postfix) with ESMTPS id 8DA27384DDA5 for ; Mon, 12 Dec 2022 20:31:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8DA27384DDA5 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f45.google.com with SMTP id f18so13445354wrj.5 for ; Mon, 12 Dec 2022 12:31:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UWxvFkKJThDFhqfBHQyrPjr/hXSQYGTRT8pAE4ZHQpQ=; b=PrGu7gSwuZcKo8/Aip+mA/loWP/3pbRVFKoyaOXHhy0VjZodUeuPzoXij1fYQkZe57 ynUtr9tr9xeHzarlF1ap4RnJhvB9NvRLwzVRnjzCkBSWi9MoUTgIuKZOkUn+UZMyl3k1 r3ohm5IcKx1REccxU5BGD5A9bHVKSPPifuwfVFeOJSkHPWuVLFWXNAvLJN6Xa7dcmRVT XG1KKCgtzwMuMZvmySGFweM4WcyBMDIxYyOlghXgYqHpcjFnqGCiBleDiOoRIpMB1Ksz U1wMIdkJEVwShWEHe1WlzEUOcKYgmZFNMprZMEuJ2VvIMmcWlQO1QlcgSkCPpsHhAVdI HuZA== X-Gm-Message-State: ANoB5plpwDpLAwSQVRd7wtXWaxNfrak0uNEaPTaM05U37O9LPlliHfaE P4L4QR6Uc+t650sPmSw73bCZTHl0par4pw== X-Google-Smtp-Source: AA0mqf5+SamwE2owYZw1AzWlWBsnpDqgs9qrlwswG0SRC3yCEknmeNTOxCW+yDuJpcRJcf/NLi8Jmg== X-Received: by 2002:a5d:4d91:0:b0:242:1926:783c with SMTP id b17-20020a5d4d91000000b002421926783cmr10374638wru.58.1670877070407; Mon, 12 Dec 2022 12:31:10 -0800 (PST) Received: from localhost ([2001:8a0:f912:6700:afd9:8b6d:223f:6170]) by smtp.gmail.com with ESMTPSA id e17-20020a5d5951000000b0024278304ef6sm9697703wri.13.2022.12.12.12.31.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Dec 2022 12:31:10 -0800 (PST) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 09/31] Thread options & clone events (native Linux) Date: Mon, 12 Dec 2022 20:30:39 +0000 Message-Id: <20221212203101.1034916-10-pedro@palves.net> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20221212203101.1034916-1-pedro@palves.net> References: <20221212203101.1034916-1-pedro@palves.net> MIME-Version: 1.0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 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 Sender: "Gdb-patches" This commit teaches the native Linux target about the GDB_THREAD_OPTION_CLONE thread option. It's actually simpler to just continue reporting all clone events unconditionally to the core. There's never any harm in reporting a clone event when the option is disabled. All we need to do is to report support for the option, otherwise GDB falls back to use target_thread_events(). Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19675 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27830 Change-Id: If90316e2dcd0c61d0fefa0d463c046011698acf9 Reviewed-By: Andrew Burgess --- gdb/linux-nat.c | 7 +++++++ gdb/linux-nat.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index f3d02b740e8..5fadc82deb0 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -4468,6 +4468,13 @@ linux_nat_target::thread_events (int enable) report_thread_events = enable; } +bool +linux_nat_target::supports_set_thread_options (gdb_thread_options options) +{ + constexpr gdb_thread_options supported_options = GDB_THREAD_OPTION_CLONE; + return ((options & supported_options) == options); +} + linux_nat_target::linux_nat_target () { /* We don't change the stratum; this target will sit at diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 3ed25cc5ba4..258041b8271 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -82,6 +82,8 @@ class linux_nat_target : public inf_ptrace_target void thread_events (int) override; + bool supports_set_thread_options (gdb_thread_options options) override; + bool can_async_p () override; bool supports_non_stop () override;