From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iM69K829Rmp2wCIAWB0awg (envelope-from ) for ; Thu, 02 Jul 2026 15:36:45 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=LVbZWT2R; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9B9561E098; Thu, 02 Jul 2026 15:36:45 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 835A01E024 for ; Thu, 02 Jul 2026 15:36:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E6F304BA23D9 for ; Thu, 2 Jul 2026 19:36:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6F304BA23D9 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=LVbZWT2R Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id C8C8C4BA23FF for ; Thu, 2 Jul 2026 19:35:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8C8C4BA23FF Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C8C8C4BA23FF Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783020965; cv=none; b=jogGs0uCtZKBQ/sEP8RArTtcM1nWZR0a94RflOqmEQKtgD73OKfw9yDI/KywZu4gl2uwXlxXHvHe2VMu90+nroR1TskIIjcAbgweXQ2g+Ci50AS/Zwqlx6rFxBFufl/zrUUR8MbUWyRxqzvnre4Eo7U6HW26k6Zef5nfb0URj/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783020965; c=relaxed/simple; bh=icE0yh7Qk329+Hbqs8e4wgUK0ZYOxG1vNzgHziz8JyY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PPsV915FDdwCL2ZYm9NHj2+H7upn1EObbTY5tfHl0J9Yzj+T+IdqUXOnU6P6xr3c1D0sCqmaHkcS4KoP+SQrMAoK92cwq97hsftkaLCi8HSY/uQ51s1J985EOliejkFpNZ8hkhmX91qm+2gp07qNwrhUUMT9mYGN2si2msn9nuk= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=LVbZWT2R DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8C8C4BA23FF Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-48611ccd5aeso1174929b6e.2 for ; Thu, 02 Jul 2026 12:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1783020959; x=1783625759; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=upSrukjdoRbeOloKjhJFuJR/VlcM0uwUNAl05tl9sNc=; b=LVbZWT2R6fGU2jnxOAMToKZbUI6N3h7J1Hb154uYi85DpL2kb81tbUmvdgaFFQVbBe 5fLTK49EfJIo1MeOkDg9abqXns6LShaWghe9rbvU38EyhzMkaiiHYAxugtII2dBnNVHJ C47SNrFxRZZNlcDLrll7mIoDTDxUmxGmq4jt2fq3ly67C+oYpvZoqkZ5X8BJB8qRQKr7 kElENxcPUuqsnrx+vTmERYf6ODhuXhWhLE0KEYq9SYJVJ3hpAN37rZmp4R1PRfwYgmuG LJxG0BV65nWViuezYyf/qzM2h4OmozGUhwNZsTpJPWj9y5odKgZTWD88cGW2vyH3j/f8 Yf5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783020959; x=1783625759; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=upSrukjdoRbeOloKjhJFuJR/VlcM0uwUNAl05tl9sNc=; b=JOPbEF7hCjlD+CWcljzWgXaN3Rx4iSCYlb6rMmmHKnyIEppwK8JmZf86/J3yfHbDtd FgBIfqOMCl9aDJ3bKNHUfu0Dd0HuqeOeYCOF4Iq9lijyg3kH1xTpnXKVDOEL7//vbPjE 80+5oKzynbHZUIIqtEVnJoUJzWaHYPh3mFQEnDRxfqwXyvPn4Oc9lKlh7zSUZpS1ciDz n4Lv5hajO4gPMQHiu6F7JwkgeK1e/G5tLO+EM6YqWCWYeB8VjvnWQOgbquQiyjW0im7d wOBM3cjEQ0pKOVGf6cLYhOvRvAOmbscUtpJnzQFh80C65JOLYj3ar7thLgmpaGXhGgML 3lhg== X-Gm-Message-State: AOJu0Yw+Efj2ZqjpbEgZG8zAwuy0Umxkqx0SojWO5KjCrGLqid314ssb 9Yjeuw1s+dvVVaZ+bRtCHgom6DD6L+I3zLhRyxWzw8WRMXFfmfqaO4fyoz6/WUq9CWHDgbE6YWR LE1o= X-Gm-Gg: AfdE7cnn9M/ezo7G8JMCXhpeiofJcUyW86CEpiNALHNYJ7tHjW94XXDqCHI9KEOOBvA WYgG8I8xtCfD2f9wUEgMryl5AL7gIkSM6Sxai4pPBiXjbo3XIo6l1ZKNDaQWrXY4SoR2hQxPHTD +Gqvt8ou06sZjZtgEujyILoKMO7AtG+WHAHAvvhzHSo4KH/sLK2zm00ZDtLVvSJX55rX9CSgIvm /sujSkXrPh3rqAUj0AeLOQeTMG0c+tvgV2U+8sF8igIMX9EmwgOw4IPMR0U0z94ycn/xcSzFYC7 oRD7ryWgjCUZAYQopQH1tNMM35CkroN1JVk8BNVCcoeKZeepLDCL/UkSYhQ32uXaYFBJoXpSD+B oqmO2d5IKBDHizIKJbnVZY6Omjdb2o06xPqZaZarLLMCM64xEoHbNJxVILhdn25eNysMQ1tEqHZ toWhBNXgKloxqegeKSM2pvIXTfN1snDyNC X-Received: by 2002:a05:6808:f88:b0:487:28a2:9b8e with SMTP id 5614622812f47-4960ee8a296mr5147066b6e.13.1783020959098; Thu, 02 Jul 2026 12:35:59 -0700 (PDT) Received: from bapiya (75-166-225-82.hlrn.qwest.net. [75.166.225.82]) by smtp.gmail.com with ESMTPSA id 5614622812f47-497d1852d44sm2423232b6e.7.2026.07.02.12.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2026 12:35:58 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Document remote protocol pid and thread id sizes Date: Thu, 2 Jul 2026 13:35:56 -0600 Message-ID: <20260702193556.2668618-1-tromey@adacore.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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~public-inbox=simark.ca@sourceware.org The recent ptid work came from a bug where a problem was observed due to sign extension. That bug also suggested documenting the guaranteed range of thread- and process-ids in the remote protocol. This patch documents these as being 32-bit values at minimum. I also added static asserts to ensure this is true -- note that although 'int' may be 16 bit per the C standard, I doubt gdb would build on such a host. I didn't specify a maximum because it is host-dependent. This is perhaps something to change, and while I do have some work in this area, it's quite invasive. Also, while widening the range here would be good, it would also be incompatible in a sense, where a newer protocol implementation may end up using values not supported by older versions of gdb. Perhaps one idea would be to simply change these both to int32_t and move on. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33979 --- gdb/doc/gdb.texinfo | 11 +++++++---- gdbsupport/ptid.h | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index a698b2b8451..04d761c904c 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -43463,7 +43463,8 @@ Several packets and replies include a @var{thread-id} field to identify a thread. Normally these are positive numbers with a target-specific interpretation, formatted as big-endian hex strings. A @var{thread-id} can also be a literal @samp{-1} to indicate all threads, or @samp{0} to -pick any thread. +pick any thread. @value{GDBN} guarantees that values of up to 32 bits +will work here. In addition, the remote protocol supports a multiprocess feature in which the @var{thread-id} syntax is extended to optionally include both @@ -43475,9 +43476,11 @@ to indicate all processes or threads (respectively), or @samp{0} to indicate an arbitrary process or thread. Specifying just a process, as @samp{p@var{pid}}, is equivalent to @samp{p@var{pid}.-1}. It is an error to specify all processes but a specific thread, such as -@samp{p-1.@var{tid}}. Note that the @samp{p} prefix is @emph{not} used -for those packets and replies explicitly documented to include a process -ID, rather than a @var{thread-id}. +@samp{p-1.@var{tid}}. @value{GDBN} guarantees that values of up to 32 +bits will work for both @var{pid} and @var{tid}. Note that the +@samp{p} prefix is @emph{not} used for those packets and replies +explicitly documented to include a process ID, rather than a +@var{thread-id}. The multiprocess @var{thread-id} syntax extensions are only used if both @value{GDBN} and the stub report support for the @samp{multiprocess} diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h index ef6da77eb7e..6872f433880 100644 --- a/gdbsupport/ptid.h +++ b/gdbsupport/ptid.h @@ -44,6 +44,10 @@ class ptid_t using lwp_type = long; using tid_type = ULONGEST; + /* These limits are documented in the manual. */ + static_assert (sizeof (pid_type) >= 4); + static_assert (sizeof (lwp_type) >= 4); + /* Must have a trivial defaulted default constructor so that the type remains POD. */ ptid_t () noexcept = default; base-commit: d243fb0029e28738abb3f933afbf01e1d0617d74 -- 2.54.0