From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ORD2JTk21mgUIhQAWB0awg (envelope-from ) for ; Fri, 26 Sep 2025 02:44:09 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YbLRG+Ef; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 94AE81E0BA; Fri, 26 Sep 2025 02:44:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=unavailable autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 3AB3C1E047 for ; Fri, 26 Sep 2025 02:44:08 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1E48385840E for ; Fri, 26 Sep 2025 06:44:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1E48385840E Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YbLRG+Ef Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by sourceware.org (Postfix) with ESMTPS id 78AAF3858D21 for ; Fri, 26 Sep 2025 06:43:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78AAF3858D21 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 78AAF3858D21 Authentication-Results: server2.sourceware.org; arc=fail smtp.remote-ip=192.198.163.7 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1758869005; cv=fail; b=Cx9hEP25WLehnwm38KHlFVS9hcYn9Xclu98BK2xzh3/gEhbbr5G66SLwyKAm3bQtlN7UvADaHal0cS4LKXxLzyA7jl4D73OFCq2KhL48xbgoj7BMMiO2rA/1aQ46pSA78Mmyw7opuw7Vesr+Q0vTUAGPhdn8JT/cL46NXk6LhhQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1758869005; c=relaxed/simple; bh=MXR+ARuWPZylEVntweFaj+IxngIcKngVJ1U0Hr+a/Os=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KWMxSj0MnXpitLRXJyemMhGYLScgUpVntcvEhNAK2nWLvck7RcRTQn0VFYVXypEF2RsY1L48AhVTwljKSrkWRRGuNNZ8vEqNbYYsv+QP0zeFPX1xCCOA7dGc+gfzgvXxN1m62LmWEDGnWmbS1qUb8G2VK76HZN5qsVEm3wksLJ8= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78AAF3858D21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1758869006; x=1790405006; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version:content-transfer-encoding; bh=MXR+ARuWPZylEVntweFaj+IxngIcKngVJ1U0Hr+a/Os=; b=YbLRG+EfoMKWRQBdOOWDzK7Sk7CmsQysaJkTVtpXFNSbd5JrLQBieHGm LaEGt1Oq0wytpZxUkChtrcr7zusW9oTEh9nnl0Rbmwz9r0EkUjjY7uvbu FmqLPe4e2gTBaaFF0lpUBgyNGw6xx3ynvJTZhMA/+W3IjB6vtQb4dAavC ipPIzJ9xVNyX6xUfCWmTtg2XNF2Nc0/dRK6+iCXEApDmgJgUfaKe6N0zd o027QUvtjyygwdnq7wZwAtAxzsYcX7AakEsbCtTCiU/HCtcM2rM/wLh+Q Ba2CyN08WlP3GSTRaTvd1EAXnBhJThT2cChD0/7WO7tXPdrnZrQ0RtXXd A==; X-CSE-ConnectionGUID: XRYw4R6ZQyqxmGxZeA+6lA== X-CSE-MsgGUID: OBtD6RCzRRKwCtoYDPqD9A== X-IronPort-AV: E=McAfee;i="6800,10657,11564"; a="86641677" X-IronPort-AV: E=Sophos;i="6.18,294,1751266800"; d="scan'208";a="86641677" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2025 23:43:24 -0700 X-CSE-ConnectionGUID: LF456nCiQoi2/f7sTYVueQ== X-CSE-MsgGUID: dvp2LMnxS52f52H5BxRIUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,294,1751266800"; d="scan'208";a="182692069" Received: from fmsmsx903.amr.corp.intel.com ([10.18.126.92]) by orviesa005.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2025 23:43:24 -0700 Received: from FMSMSX903.amr.corp.intel.com (10.18.126.92) by fmsmsx903.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.27; Thu, 25 Sep 2025 23:43:23 -0700 Received: from fmsedg902.ED.cps.intel.com (10.1.192.144) by FMSMSX903.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.27 via Frontend Transport; Thu, 25 Sep 2025 23:43:23 -0700 Received: from CH5PR02CU005.outbound.protection.outlook.com (40.107.200.20) by edgegateway.intel.com (192.55.55.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.27; Thu, 25 Sep 2025 23:43:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ya9gqQRveR2gcCFH1qGK0yaBsc5ING6CGzBmYcPav9v0T+J0dbeo+YbLI9VKY2cxL8KzNM2WE4sJM/tcO4RV2AhF53Vj4rIl6lyNBSkT/BORYN25ZGhA6vb4VsQ89XRtfvhX6dqg7Kl7ZlyYt3tGhNiSt9yKvG5EBuXf0Xn7f4xbnNq1S22s2yWRKyi4WI4Nx3GFNf5+0+1QYLWjiPnfr8QWMK9Jff654luC4NoJAFrZQqm+bh6NYPxh/QtbTK5hi97zcpsaWkPzEcV5ecIKUEBfX8m+p5KzCdhnrTJ+Kqlnkvlnos5plduGkYZhhy121zMvFa6NcJLiDzIakLczpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ijuCciyEYeHkstHQ3uNEt3rhcadBER4kFY3cMY3n3TM=; b=id3Rwb9Hll+BdxuLTvGKs29+TTLwiaoR2LmlDH7My9e853n88WXyZP76jUS7v+2KOOP34fnQI2vlDy9Zvj3oaZbihf5Sb83p8hOEAy41LID7zOLWCbQe2Y6drm74FLNDagNuVaS2qCyXrGd85UcBF1dV3+rFVzTveOAL04pgluuXKTntjnAeIDxUrRIGg/rFKZflZo9LkZF/qWLlNWBvv/ODZeE6U1dOKrXLcddCVVamXwJFafy/rNWht/OeIJrHn51ICqVjyfYTUyFsXr4nJzh9hJxymKO6eiVv4Txf5kfCxX+jdjOg9hebMcLG6Hv7chEswkJYlUY4asKFGIqOwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM8PR11MB5749.namprd11.prod.outlook.com (2603:10b6:8:10::15) by PH8PR11MB6856.namprd11.prod.outlook.com (2603:10b6:510:22b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9160.10; Fri, 26 Sep 2025 06:43:21 +0000 Received: from DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::d0bb:6f87:88ed:6368]) by DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::d0bb:6f87:88ed:6368%3]) with mapi id 15.20.9160.010; Fri, 26 Sep 2025 06:43:21 +0000 From: "Metzger, Markus T" To: Tom Tromey CC: Simon Marchi , Thiago Jung Bauermann , "gdb-patches@sourceware.org" Subject: RE: [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids Thread-Topic: [PATCH 1/2] gdbserver, read_ptid: handle '0' and '-1' thread ids Thread-Index: AQHcBdlG/SsaDrNrtEGD6+PKCQKNA7Rhjb/JgAEd2wCAPMv9AIAB7A+SgADhBnCAAw3dsA== Date: Fri, 26 Sep 2025 06:43:20 +0000 Message-ID: References: <20250805071914.3832823-1-markus.t.metzger@intel.com> <87wm76zi98.fsf@linaro.org> <4bc68b3a-d8a5-45b1-aa94-0b6af488d8bc@simark.ca> <87segdc9e9.fsf@tromey.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM8PR11MB5749:EE_|PH8PR11MB6856:EE_ x-ms-office365-filtering-correlation-id: 6ec1e034-6ebb-4106-bae2-08ddfcc7fbb7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|1800799024|376014|38070700021; x-microsoft-antispam-message-info: =?us-ascii?Q?lEPaiizammeu1aGqDW0l/MCt1Xujm8cFrI66VBKFm8vAlW4RfroiNyu6zGN8?= =?us-ascii?Q?NFlk7C9M6lAsCQfB4n5Ik94YEeESmF0lUYodVwmY74kF/MlwdJeVqWrdZ/8W?= =?us-ascii?Q?kxxo9Dqv1vcACJDJTZpYYbG3TimofOMz+GcdXFyfId9PKjTniV3MozLJ9kkE?= =?us-ascii?Q?m1oIlG5dts0VLO7pdqXKhi3qjPgGMjEr1KjF4GSJ0dlekmoigrJB0z/cK41J?= =?us-ascii?Q?Vus0AMV3Qv7OD3ImmWLkr0QN+z5CfuJQzTwM3izW7bebLk0xM9+pCjjnSQol?= =?us-ascii?Q?gekOXiAe6JeuApeiYbClwqbuCO4nwY92PG5MLma5wtHGHd2oopJPCl646cxH?= =?us-ascii?Q?azAxrCC3VCBSLIhoh9dSxye6/pXXbOt4FRxd0TunDDt1+n9KGs7daeABjuZa?= =?us-ascii?Q?529xjeiT3T2akGQJFzKkvHffGJI+O4+45SP4D5ovPxVD3e2G2UVzBSsTA0mH?= =?us-ascii?Q?zozXjq8fzR6rOfIjsEdcaMT70Hv303uYKf68zegXp3ytz1GB8Z3iOL3nuvhC?= =?us-ascii?Q?xe9Ig80MkCXLlGHZh8/6CIFTAkHmE/hV9NrpOmDVnN7lvoh/R93pEathIVtR?= =?us-ascii?Q?vbznztIrvA2r+cWjoMMaEdDZ2cLyssJABA9ezOgjRUwHW6+sFT7xYKTF/5lZ?= =?us-ascii?Q?SsqDxv7pEdcak3qYPnSNIL/FuGS3h4XNdA+QKbXxBBAU2jJVAXQ5iql67wQM?= =?us-ascii?Q?JbZLYaoMI75D+VTN2VZ2S4M337DoZ1ys+Dvz7MPILD3O40sCARwk9JupgKgz?= =?us-ascii?Q?Z50zq+SQvywa/PTZI12fZTOOZIM0mn34N8fXYyUghsgFv/EUAujtuaL/6mf/?= =?us-ascii?Q?qYCcpfbtNsCWUHWz3Gqr62Y+PQQMcKw/PUlp9ka2vK5x/yLQ96yPaq0kEMT8?= =?us-ascii?Q?RrykP0xZPQ7Touy2qP04DD2kSoAm8kIhcKzDBgxT7YTLjvJuT1foKNat4qJq?= =?us-ascii?Q?h1VnPd95eQy88d8Sww31OkFDFk3P+NAO6hjezLtUb3jYrQHkKZF/S9VfcboB?= =?us-ascii?Q?X2Ft9jElUngQ9O+v1E3Ue6P1AltT0MCa2NyLzkAR+IAeuBSJK6IFtLRMOMco?= =?us-ascii?Q?WGix6mCE1EfNzeOpQq247VGzhsgL3serJtbasviYZcn3AZxmlsCcy5/f9iku?= =?us-ascii?Q?Z9nf3+sYUfRojFSTOoj3xlI3OhjFuDFgDUo9ssN2m0u1SuGtd5nFSICMVFvr?= =?us-ascii?Q?zybiRcPV8T6Xa88GDhj00eKngXKrg7BnEoGgWdtCjFBOMDCqVk+sx978d6qd?= =?us-ascii?Q?lzo6/hLKqV04espTlVhOsD89/sDfRoLPCqXVrqHE3RzIqadp9UtkdNHuEOKE?= =?us-ascii?Q?xxiOIvhtc1fS+j7qIP4cSZKZKiGz0kjDjDzrle41+841BdK9GV54Q0KaY1Yx?= =?us-ascii?Q?ti20mb0RgQxlmaMSUQTmG5dJjizf7vr+NxcDlqnH2X3qLhDuG0aDCfHJ/M7I?= =?us-ascii?Q?7SpdH+lQx2568wm7lI58djST+vmofOIXZGI1qy3UBcwXvEHN4Oo5vg=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM8PR11MB5749.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(38070700021); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?S04pwaKvPQtWWruzbKLSkvvjms3nLoO8TiX+SVUhRSgbIiUImENabL018RxD?= =?us-ascii?Q?mdrWvJKs3vYYdiBeQ6Y9KVzHOe/4D/8xyZfevC2Vzq+HSWevTEMuoSdRTLO5?= =?us-ascii?Q?RcKzW8tno08ARGwQX1SBIr0BLMxEEiZIHjdpLQZ9dymi9Pk030c3/H5ocV37?= =?us-ascii?Q?Bc0TkA4itT6Xnfv4oWyCPkGfLhmBRShMtPVfehXxuoX1PqpdAGuKdQnjdaUs?= =?us-ascii?Q?D2o/4vUZGRZnnb5To0c+X4goROxu6U6OfbWW4oH74qnUl63kwRk6c/O2ccFz?= =?us-ascii?Q?25YuR5gw6z2IosU3U3VCTQIU/a3V0RwcZMd1ECgWFeqfv/BcN2KzAwUcJ+6T?= =?us-ascii?Q?Q1zgNtmmNJxjFhHYrrPG6lQEQetyh817rnGCQoTdAhJFsyIFV8COMY/Fb+rP?= =?us-ascii?Q?VQBi1QOQ3WXKpAfkr6CBDDyAQuI25+vtJdR4RMMHLUBZi4VWBaaXOF8klS0P?= =?us-ascii?Q?Ud7xD1IlehGvjspZzLJvYjWOLW9IIuGTfkKG5xTNzN2jyqXEcdcYVUk+pHYs?= =?us-ascii?Q?lo9dZkJqQMc4hj5S40PmVzPUQt1gbyxTnwfeja/ohtOr3cvOiZTOmxJjHZSc?= =?us-ascii?Q?3ikhoeOBYVfDQ7JMGfstkMI9oE4OW6IJHVs+HC07qw5hvihk2WOiF1qP+rjB?= =?us-ascii?Q?IVXaUKC5e6FOFxJe0kTHDud2DCZcne3wCBvFnSwiQ7CdoA91p+ndNCW+Nr2p?= =?us-ascii?Q?6atYErj/yDvN5ezZyp1tNnEHXqemIT10uQxA2Hz3QXdz7UOrfo0Lwzb8Ujlp?= =?us-ascii?Q?DQ5r8ocYE0ZGncuNW8FLgK5TYfY/b95mZNY9oPOhg3yzJwE3GOVKRBiNzljB?= =?us-ascii?Q?oY+BetBdIwBVNXEVjvIm1MiC8on0MJCNbg16bMB7jR9aIFnhMsT9ThjVbLCX?= =?us-ascii?Q?k250/SR5H2DUgOALAw5W8mvuajDfi9DnvS2WUj5yofERre38iI3Nbfh/1v6B?= =?us-ascii?Q?3sE426Id/NQMhf9PUVawmegvw/5oEFX0IUyoGuOgrznyKjcImy3zZk403kyP?= =?us-ascii?Q?bcBx/Zz3znutsZ+W+aqZpg9lpdVhqy/HovIFJtDN8M4V3COfXN1r9aLpvZOK?= =?us-ascii?Q?7Oq/Mvw3FQxuTv+3BOlsk5L+f/VUjY8w8wmdpDR8Pgit3f27GtXxulxtVo8S?= =?us-ascii?Q?9nwvYx+4okvLg0kZwzfGU7cNRfprk4mOrj4M2YvUG/kITx4Imt86wrPi+sbk?= =?us-ascii?Q?o4XDnLt1PLDrkzCFgwwBJe+ke/wmTZQSMhxfZzr3ECvvyrSfoU8pnVYt26po?= =?us-ascii?Q?4uJaNI9sKQQ5q1yCZfrXs7q1WImnIEXO48+1RENLd0BiwxT7W8Po7rrR/K6U?= =?us-ascii?Q?tZ5IIZcDkLgnsuLInejEjHxHt85Xg6jxRdnmM5VhWPYzyJ9k5oy2ivle4yAD?= =?us-ascii?Q?87aPaHypVLQQfP10waPXx3J/xbFtolFB8rvMEpSe5m3CeQ1tM6FB+phtEfIc?= =?us-ascii?Q?DyDL23QToqIYimKhUmLJjZDa9Vw4E8yuU39/jYWcDsvs1/Ts9PuRtrFqMK3K?= =?us-ascii?Q?+2mb26szgN3h0/FQ3N29mhJBNnZC2QcW38hby2AFvu0BFPAFO6OjsQ2yv2rH?= =?us-ascii?Q?o6TGnqsQE7t3+TpeEt4peg8vQwxQ6gJxVVvf2dIJ?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8PR11MB5749.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ec1e034-6ebb-4106-bae2-08ddfcc7fbb7 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2025 06:43:20.7940 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: La1Sxk+Tft9A2Hh8AOfSMpR+otz07vOOZI0TSDZ5UDovFjFE/bM7O8nd2aAeIwblXsXJoFmQusI5XZt9TxkSpkiRTuU1CkKt8u5PNZVtPlY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB6856 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable 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 Hello Tom, >In general, read_ptid() and write_ptid() don't seem to care about >types and conversions; read_ptid(), for example, reads everything >into ULONGEST and then constructs a ptid without checking for >overflows. > >I could add a fix to this series, but, as with the other patches, this >would be solely based on reviewing the code without an actual bug >(I cannot test this zephyr target) nor a test. Here's the patch. I'll add it to v2 of this series. I tested this on ubuntu 22.04 running on x86-64. Is it just me or is everybody seeing lots of sporadic fails that appear and disappear between runs? I'm running tests with FORCE_PARALLEL=3D1 for each patch in a series plus a few upstream patches in front and then filter out fails that appear and disappear manually. Regards, Markus. --- commit b6ec4c40ec46fdba710369e2541699d2d704c828 Author: Markus Metzger Date: Wed Sep 24 12:08:55 2025 +0000 gdb, gdbserver: fix read/write_ptid types = In write_ptid(), a ptid's LWP member, which is declared long, is stored= in an int local variable before printing, potentially truncating it. Fix = it. = In read_ptid(), both PID and LWP are read as ULONGEST and then cast to their respective type without checking for overflows. Fix it. = In read_ptid(), an empty component is treated as zero. Diagnose that as an error, instead. = CC: Tom Tromey diff --git a/gdb/remote.c b/gdb/remote.c index 961322f398b..6d609ced02b 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -3464,7 +3464,8 @@ static int remote_newthread_step (threadref *ref, voi= d *context); char * remote_target::write_ptid (char *buf, const char *endbuf, ptid_t ptid) { - int pid, tid; + ptid_t::pid_type pid; + ptid_t::lwp_type lwp; = if (m_features.remote_multi_process_p ()) { @@ -3474,11 +3475,11 @@ remote_target::write_ptid (char *buf, const char *e= ndbuf, ptid_t ptid) else buf +=3D xsnprintf (buf, endbuf - buf, "p%x.", pid); } - tid =3D ptid.lwp (); - if (tid < 0) - buf +=3D xsnprintf (buf, endbuf - buf, "-%x", -tid); + lwp =3D ptid.lwp (); + if (lwp < 0) + buf +=3D xsnprintf (buf, endbuf - buf, "-%lx", -lwp); else - buf +=3D xsnprintf (buf, endbuf - buf, "%x", tid); + buf +=3D xsnprintf (buf, endbuf - buf, "%lx", lwp); = return buf; } @@ -3492,24 +3493,38 @@ read_ptid (const char *buf, const char **obuf) { const char *p =3D buf; const char *pp; - ULONGEST pid =3D 0, tid =3D 0; + ptid_t::pid_type pid =3D 0; + ptid_t::lwp_type lwp =3D 0; + ULONGEST hex; = if (*p =3D=3D 'p') { /* Multi-process ptid. */ - pp =3D unpack_varlen_hex (p + 1, &pid); - if (*pp !=3D '.') - error (_("invalid remote ptid: %s"), p); + pp =3D unpack_varlen_hex (p + 1, &hex); + if ((pp =3D=3D (p + 1)) || (*pp !=3D '.')) + error (_("invalid remote ptid: %s"), buf); + + pid =3D (ptid_t::pid_type) (LONGEST) hex; + if (hex !=3D ((ULONGEST) pid)) + error (_("invalid remote ptid: %s"), buf); + + p =3D pp + 1; + pp =3D unpack_varlen_hex (p, &hex); + if (pp =3D=3D p) + error (_("invalid remote ptid: %s"), buf); + + lwp =3D (ptid_t::lwp_type) (LONGEST) hex; + if (hex !=3D ((ULONGEST) lwp)) + error (_("invalid remote ptid: %s"), buf); = - p =3D pp; - pp =3D unpack_varlen_hex (p + 1, &tid); if (obuf) *obuf =3D pp; - return ptid_t (pid, tid); + + return ptid_t (pid, lwp); } = - /* No multi-process. Just a tid. */ - pp =3D unpack_varlen_hex (p, &tid); + /* No multi-process. Just a thread id. */ + pp =3D unpack_varlen_hex (p, &hex); = /* Return null_ptid when no thread id is found. */ if (p =3D=3D pp) @@ -3519,6 +3534,10 @@ read_ptid (const char *buf, const char **obuf) return null_ptid; } = + lwp =3D (ptid_t::lwp_type) (LONGEST) hex; + if (hex !=3D ((ULONGEST) lwp)) + error (_("invalid remote ptid: %s"), buf); + /* Since the stub is not sending a process id, default to what's current_inferior, unless it doesn't have a PID yet. If so, then since there's no way to know the pid of the reported @@ -3531,7 +3550,8 @@ read_ptid (const char *buf, const char **obuf) = if (obuf) *obuf =3D pp; - return ptid_t (pid, tid); + + return ptid_t (pid, lwp); } = static int diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc index f5d70c546d3..fe2b6acb4e9 100644 --- a/gdbserver/remote-utils.cc +++ b/gdbserver/remote-utils.cc @@ -519,7 +519,8 @@ char * write_ptid (char *buf, ptid_t ptid) { client_state &cs =3D get_client_state (); - int pid, tid; + ptid_t::pid_type pid; + ptid_t::lwp_type lwp; = if (cs.multi_process) { @@ -529,11 +530,11 @@ write_ptid (char *buf, ptid_t ptid) else buf +=3D sprintf (buf, "p%x.", pid); } - tid =3D ptid.lwp (); - if (tid < 0) - buf +=3D sprintf (buf, "-%x", -tid); + lwp =3D ptid.lwp (); + if (lwp < 0) + buf +=3D sprintf (buf, "-%lx", -lwp); else - buf +=3D sprintf (buf, "%x", tid); + buf +=3D sprintf (buf, "%lx", lwp); = return buf; } @@ -564,45 +565,59 @@ read_ptid (const char *buf, const char **obuf) { const char *p =3D buf; const char *pp; + ptid_t::pid_type pid =3D 0; + ptid_t::lwp_type lwp =3D 0; + ULONGEST hex; = if (*p =3D=3D 'p') { - ULONGEST pid; - /* Multi-process ptid. */ - pp =3D unpack_varlen_hex (p + 1, &pid); - if (*pp !=3D '.') - error ("invalid remote ptid: %s\n", p); + pp =3D unpack_varlen_hex (p + 1, &hex); + if ((pp =3D=3D (p + 1)) || (*pp !=3D '.')) + error ("invalid remote ptid: %s\n", buf); + + pid =3D (ptid_t::pid_type) (LONGEST) hex; + if (hex !=3D ((ULONGEST) pid)) + error (_("invalid remote ptid: %s"), buf); = p =3D pp + 1; + hex =3D hex_or_minus_one (p, &pp); + if (pp =3D=3D p) + error ("invalid remote ptid: %s\n", buf); = - ULONGEST tid =3D hex_or_minus_one (p, &pp); + lwp =3D (ptid_t::lwp_type) (LONGEST) hex; + if (hex !=3D ((ULONGEST) lwp)) + error (_("invalid remote ptid: %s"), buf); = if (obuf) *obuf =3D pp; = - return ptid_t (pid, tid); + return ptid_t (pid, lwp); } = - /* No multi-process. Just a tid. */ - ULONGEST tid =3D hex_or_minus_one (p, &pp); + /* No multi-process. Just a thread id. */ + hex =3D hex_or_minus_one (p, &pp); = /* Handle special thread ids. */ - if (tid =3D=3D (ULONGEST) -1) + if (hex =3D=3D (ULONGEST) -1) return minus_one_ptid; = - if (tid =3D=3D 0) + if (hex =3D=3D 0) return null_ptid; = + lwp =3D (ptid_t::lwp_type) (LONGEST) hex; + if (hex !=3D ((ULONGEST) lwp)) + error (_("invalid remote ptid: %s"), buf); + /* Since GDB is not sending a process id (multi-process extensions are off), then there's only one process. Default to the first in the list. */ - int pid =3D get_first_process ()->pid; + pid =3D get_first_process ()->pid; = if (obuf) *obuf =3D pp; = - return ptid_t (pid, tid); + return ptid_t (pid, lwp); } = /* Write COUNT bytes in BUF to the client. Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928