From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6AQ4CNGHYmTWHwsAWB0awg (envelope-from ) for ; Mon, 15 May 2023 15:28:17 -0400 Received: by simark.ca (Postfix, from userid 112) id 1D2201E11E; Mon, 15 May 2023 15:28:17 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=WNM3oaf0; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BE1851E0D6 for ; Mon, 15 May 2023 15:28:16 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92B243857010 for ; Mon, 15 May 2023 19:28:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92B243857010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684178895; bh=BL3zQbqTiqBqWMYiIwAhYXq+f4hw9Mce9MnChoQq6Jw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=WNM3oaf0eOE6n7dS9qCm160gnNw0LpU4Q/rs8NQ9Otlkr36he9ejTIAvaJTCg3owJ +UA4plW8aVX2P/n/UtLmrJw0wuItH+5NU+ngXlpmuTJ7wdZnntAViK2GrePaoQ0P5k OFd2lpdXJBJJavhkDmQIJct0Z0vq1jSjwfULUQZw= 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 79E0A3858D37 for ; Mon, 15 May 2023 19:27:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79E0A3858D37 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-290-e5s4Jj6SMdWP7HcR6Qu5xQ-1; Mon, 15 May 2023 15:27:52 -0400 X-MC-Unique: e5s4Jj6SMdWP7HcR6Qu5xQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-306362a1607so8207610f8f.1 for ; Mon, 15 May 2023 12:27:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684178871; x=1686770871; 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=BL3zQbqTiqBqWMYiIwAhYXq+f4hw9Mce9MnChoQq6Jw=; b=Df4+F0MfAl7SQxq2Y+WSnEmb2iWTGzm6aejf0p1Lnt9rUobiscPjKqB/bb3St35F6u HqYsRyUtegovc6IVNv7AZi8mHHECr4FCtA8HCSgDOsi/NIwswX1oOgwD9+nFE4ZEg9rJ bM/XKIoYBUL0T7hcczUmPq9DQeUFkCQDbtVzm3262i1DTrPsp7hGofOmFaIjNbZ5s8EN //5isElO0817RyCAtkvJrrnxnNaXhJey2AdcnMHwELuomG20bf2OlTDkRmISpcdsIZII sw6y1LoAVcyo0zUsfp5MDX2fvSm1HczcLoH5Wnkm4tTmVKYIu65Li1OmVCH3ne+wZDO7 xdNQ== X-Gm-Message-State: AC+VfDwghTEd98C3hop+ByOf1R3Z025XVmQyrrR6abT02CufG7biV3io NySc+YWstjEVrC5zv4vHWvAglHC26JUl/gpCwBrRcz13jpV3K3POGv4B7lfgE0iJyz6xulQZgl9 6Pbs6zk5ZimyJXZbHpEPsYZ+v8Ls/THf2dFh9boqKtg0keIB1bLOC5ZpoGS/wHb0QAmc3kiCDou EUGiZUqg== X-Received: by 2002:a5d:510a:0:b0:304:79c1:725d with SMTP id s10-20020a5d510a000000b0030479c1725dmr24252726wrt.45.1684178871467; Mon, 15 May 2023 12:27:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ayNwtPzv7IN83aBxmpLrtSZW59dnmRh6hdfzdG9W/sT05etLR6X5b7RXFaZC1BQ4aHnb6XQ== X-Received: by 2002:a5d:510a:0:b0:304:79c1:725d with SMTP id s10-20020a5d510a000000b0030479c1725dmr24252713wrt.45.1684178871106; Mon, 15 May 2023 12:27:51 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id a3-20020adfeec3000000b0030649242b72sm45921wrp.113.2023.05.15.12.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 12:27:50 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 1/9] gdb: create_breakpoint: assert for a valid thread-id Date: Mon, 15 May 2023 20:27:37 +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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Add an assert into create_breakpoint (breakpoint.c) that the thread argument is a valid thread-id; either a value greater than zero, or -1 to indicate any thread. The thread is ignored if parse_extra is true though, so take that into account too. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 4 ++++ gdb/breakpoint.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index fdb184ae81f..31448e0a895 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9027,6 +9027,10 @@ create_breakpoint (struct gdbarch *gdbarch, gdb_assert (ops != NULL); + /* If PARSE_EXTRA is true then the thread-id will be parsed from + EXTRA_STRING, otherwise, ensure THREAD is valid. */ + gdb_assert (parse_extra || thread == -1 || thread > 0); + /* If extra_string isn't useful, set it to NULL. */ if (extra_string != NULL && *extra_string == '\0') extra_string = NULL; diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 7c5cf3f2bef..e57dc2523fb 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1530,6 +1530,12 @@ enum breakpoint_create_flags the FORCE_CONDITION parameter is ignored and the corresponding argument is parsed from EXTRA_STRING. + The THREAD should be a global thread number, the created breakpoint will + only apply for that thread. If the breakpoint should apply for all + threads then pass -1. However, if PARSE_EXTRA is non-zero then the + THREAD parameter is ignored and an optional thread number will be parsed + from EXTRA_STRING. + If INTERNAL is non-zero, the breakpoint number will be allocated from the internal breakpoint count. -- 2.25.4