From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684178874; 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=BL3zQbqTiqBqWMYiIwAhYXq+f4hw9Mce9MnChoQq6Jw=; b=VF/74WaycvsItMaRTYl0OmEjVLIHO4QsdABw6NIep/7Yk/coleUe+D8GmM8MznLhmF/lYi 9Ci1iqwMwVR5Iyouhl9uTfkY10kLw4yBzO8gXNTDqBx6xSdGFfhWeEGc9NrCaqd8rQVCSC t/S0xB6c/p75jf20dgZfK+GWI6IcQ9o= 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) From: Andrew Burgess 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-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: 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