From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2066.outbound.protection.outlook.com [40.107.21.66]) by sourceware.org (Postfix) with ESMTPS id 249DF3858D38 for ; Wed, 1 Feb 2023 09:07:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 249DF3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ijr8368yMb1wpW2o/+QK4cQTgCsnO7XSHf9IXuptuyc=; b=HIKUjA79bIYpA6N6QB3kNIOq9nzvqZrHL44lWrqc8N9ghLhXX2eDq0ogYNqJCDvGzgDTdWOq0qscotmDh65OMdkGRsJInEOoLkln8aeiTlhYhaMXZgoVYQZuUMHXTzljL6JFcmU5U/6UEpzniu+0gmHAkNe+VknPJOGbbnCoH7k= Received: from AS9PR06CA0315.eurprd06.prod.outlook.com (2603:10a6:20b:45b::26) by AS8PR08MB7717.eurprd08.prod.outlook.com (2603:10a6:20b:525::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Wed, 1 Feb 2023 09:07:39 +0000 Received: from AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45b:cafe::ad) by AS9PR06CA0315.outlook.office365.com (2603:10a6:20b:45b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22 via Frontend Transport; Wed, 1 Feb 2023 09:07:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT004.mail.protection.outlook.com (100.127.140.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22 via Frontend Transport; Wed, 1 Feb 2023 09:07:39 +0000 Received: ("Tessian outbound 333ca28169fa:v132"); Wed, 01 Feb 2023 09:07:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 877d816cbc1ee629 X-CR-MTA-TID: 64aa7808 Received: from 854be6fbf8b8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2C7305E2-4FE4-40C9-974E-2079575A57D2.1; Wed, 01 Feb 2023 09:07:32 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 854be6fbf8b8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 01 Feb 2023 09:07:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fwx3BVh1mqXzVhF6eTMWHIsswlQeKuipCB6894BQ5PPoi9Kq+VX9mJxlqpAyFgYVZjEaHa8MaXy7/5Tt5Zz6jFzR2HmKAhgXpoD0FIXqd1aczuRnwmavfSAOBaRaW+tCz5N93LNcyrbuGnsxLpIgDIRR1fhMK+GcwKyIGcfvEl7t7WtActJCk/qJJxR91EYr2CqYm0YcNFItejMhGg2a3z8AUn7QDj3RTmUnWtDIiSBUA5L9KAFjrqKPZaLcCD/9ee/VEStrbhMteodLTu8kSmfjCdK3bjpMmJcLJROBEvl+FVYNvuIPqRVCqoE0piyC3DOu2OM30SUWO1jC124v4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ijr8368yMb1wpW2o/+QK4cQTgCsnO7XSHf9IXuptuyc=; b=cvOtuNhVQdG7QFYqwo0Tq4XP6pueac4FDalTaomK/xYO1XeSCPUe+n98vonjfZJ801LPKP9nZMIjusQU884dGt/8hEf6Dw4KkER0u5xzCk4Unb22U1tY6HFfrNjacHCUWDldRVZZuPSeZaY4EdAaquUtgYqqONNONXzIChk5JsA6tJR/aFDoeiR4f32F7kbVs37U6bkvKGjgZ1Zz5b4G6sLOx+f9fmqWNlggKuM5dreDP2NnnYIgwbJoXzdQ9S+sJG6DbRQ4XEQ7czoC+mTimIwaWW/dtS7Lqmy7AqVf222CIDPyqZhIY+kbFh/RkhWcVfwoi9kt5DyeVESFO3WvfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ijr8368yMb1wpW2o/+QK4cQTgCsnO7XSHf9IXuptuyc=; b=HIKUjA79bIYpA6N6QB3kNIOq9nzvqZrHL44lWrqc8N9ghLhXX2eDq0ogYNqJCDvGzgDTdWOq0qscotmDh65OMdkGRsJInEOoLkln8aeiTlhYhaMXZgoVYQZuUMHXTzljL6JFcmU5U/6UEpzniu+0gmHAkNe+VknPJOGbbnCoH7k= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by DU0PR08MB8493.eurprd08.prod.outlook.com (2603:10a6:10:406::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.24; Wed, 1 Feb 2023 09:07:29 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::bced:32a3:b77e:90a6]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::bced:32a3:b77e:90a6%3]) with mapi id 15.20.6043.036; Wed, 1 Feb 2023 09:07:29 +0000 Message-ID: <69401ff2-1066-8497-a99f-745a26809214@arm.com> Date: Wed, 1 Feb 2023 09:07:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v3 2/8] gdbserver: Add PID parameter to linux_get_auxv and linux_get_hwcap Content-Language: en-US To: Thiago Jung Bauermann , gdb-patches@sourceware.org Cc: Simon Marchi References: <20230130044518.3322695-1-thiago.bauermann@linaro.org> <20230130044518.3322695-3-thiago.bauermann@linaro.org> From: Luis Machado In-Reply-To: <20230130044518.3322695-3-thiago.bauermann@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SA9PR13CA0069.namprd13.prod.outlook.com (2603:10b6:806:23::14) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|DU0PR08MB8493:EE_|AM7EUR03FT004:EE_|AS8PR08MB7717:EE_ X-MS-Office365-Filtering-Correlation-Id: 83d33cec-4a9e-4c57-f212-08db0433c514 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xIq6TnQ8wasazRrc9qlLL4FBWFSiOjdMCYC7NQ4JOLnKzw4cQS8Pms6g4JCRkGgdmvz5hcQ7L52SJaCH8nfhKDhC97s//ud+Pqw+rmPXptDAH3Lj/o1AD53eYArBMTNiYpy60p2fXSLa2/IPgQCl9l70DIhGX/w9Il3ISI2iDk0a296JGzRJl+ZJ2vvd6jhxEcw3TqMWLFFQQ7i4yPEuPtlcQn+tIp1AElHRdUe3WkcABuDmwtjzf7qpk9Ktzhmhr8kOWxRsI9p1Fd1DYHVzNAezN6j0GtGzX3CuW6RbrqZc1Va+8duWDtG/f8JYvVg9ihj/3ngZR6j9ARVu39hMoKDbonPSY27yKmAOHzwmgquYS2+uEbWsumrVROB0k5wPPdo6T8cd4jTW7JInttPKMcPUGfWMcfxpFG9aP/sir2wCBfLW+E/ymqATdJ9X2+5lKcSDUxims5bnNTLq18uY0BVBbfMPr/ZcmcBt1zLzJg4XHSWDVrPbTPTXYv9s5q4xi7/lGRWo0W86LBMDgDq1yx67+NNv1IaHJU6cibar8bthbnnXRjqF2o6tqrxyFvjl17Chxk9c7I4HFhSqRbfo1cDSTK4O/18RpWecAcJh0awrAqtZLn6UupEb4GC7KWCp1NnisCUm1dr304DWZ11zmHxDjxtj27LA1DzpUJ+s3K75I2N30TzTd3Nc2qEL0bYJUD+Wym9QAI6AycbBIRc2HIYvCbFlxYMmtHuPl0g58WM= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB3919.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(39860400002)(396003)(136003)(346002)(366004)(451199018)(31686004)(6666004)(316002)(2616005)(83380400001)(36756003)(44832011)(2906002)(38100700002)(53546011)(66556008)(66476007)(8676002)(66946007)(4326008)(6486002)(26005)(186003)(478600001)(6512007)(6506007)(31696002)(41300700001)(86362001)(30864003)(8936002)(5660300002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8493 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 34842603-21ab-4dde-3e9f-08db0433be8f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FddNjJVFGQ7qifqYhs8+mQfCn42v2nnUvms/V+ECJiVdEjwzsXP/N0LmRRw6fVoLhTtHKKuxdF8xBNLOQPwFV/mCp816C57nZUb733+r0P8YlTkTY4CjRU1jMUzC2wuTosYLxjbOAmrWbxm6y3aCzOGBQLsZQEM3yD9Q3Sv3VXxN/d+2PqZgfeZfdGOmb5L67Ro/+Z339/LuIdcEf4SvoJoTMft0zr58JBgzYWUpCHKU+FM40F06Ctzj/Rwf6l+ZR9P4FnmxEvOtKaLXHIlcQ491aw1n1AMl9ioj8mbbK1RS/Hik1AvE7gju9hMSIt8KEzZBeekCq02KAdOKjNxGgKuw57KsER2RRrOsATDioVQdgbyI30tlnG5UVnvP28WFtU3RV3F6FAjlAxb2ROcqiSvHlewOIPH0U0ZcGMZmxNVpzRpm4SUwKrAWGKBnoQxqFVXEgejQ9xc91S84J4uBjBJPmhQR29uh/6StQeAqvbr1gtnYRE364o2Pv1rTWUd3mqIzQdbSflRztKQPkuMcSOzv7M7mb4DnC8Os//cU/5LTGLewtAe8Y1W1Y+xE8ISo6L/kD2pIXGvbUuW3k5drqbQO2Mj7tJv+miucg960rXr21dzIlKk/Bjd1DWym0D/EN6pmDrMvVNGutyWnGsm6NSlTpl7qitbEn0FYxVSWfb0DNT1JtGi3Bn1V6QMfKk9+aKXcX5pb9hqNKrI4FIgsI0VCsgGiNrPIBaIbfCPElfQ= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199018)(36840700001)(40470700004)(46966006)(40460700003)(36756003)(6512007)(2616005)(478600001)(6666004)(316002)(30864003)(44832011)(107886003)(53546011)(6486002)(5660300002)(2906002)(41300700001)(70586007)(70206006)(6506007)(4326008)(8936002)(82740400003)(186003)(8676002)(36860700001)(82310400005)(31696002)(40480700001)(86362001)(81166007)(26005)(47076005)(336012)(356005)(83380400001)(31686004)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 09:07:39.8447 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83d33cec-4a9e-4c57-f212-08db0433c514 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7717 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY 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: On 1/30/23 04:45, Thiago Jung Bauermann via Gdb-patches wrote: > This patch doesn't change gdbserver behaviour, but after later changes are > made it avoids a null pointer dereference when HWCAP needs to be obtained > for a specific process while current_thread is nullptr. > > Fixing linux_read_auxv, linux_get_hwcap and linux_get_hwcap2 to take a PID > parameter seems more correct than setting current_thread in one particular > code path. > > Changes are propagated to allow passing the new parameter through the call > chain. > > Approved-By: Simon Marchi > --- > gdbserver/linux-aarch64-low.cc | 7 ++++--- > gdbserver/linux-arm-low.cc | 2 +- > gdbserver/linux-low.cc | 18 +++++++++--------- > gdbserver/linux-low.h | 9 ++++----- > gdbserver/linux-ppc-low.cc | 6 +++--- > gdbserver/linux-s390-low.cc | 2 +- > gdbserver/netbsd-low.cc | 4 +--- > gdbserver/netbsd-low.h | 2 +- > gdbserver/server.cc | 3 ++- > gdbserver/target.cc | 4 ++-- > gdbserver/target.h | 4 ++-- > 11 files changed, 30 insertions(+), 31 deletions(-) > > diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc > index 3c09e086afee..2ed6e95562c5 100644 > --- a/gdbserver/linux-aarch64-low.cc > +++ b/gdbserver/linux-aarch64-low.cc > @@ -846,12 +846,13 @@ aarch64_target::low_arch_setup () > if (is_elf64) > { > struct aarch64_features features; > + int pid = current_thread->id.pid (); > > features.vq = aarch64_sve_get_vq (tid); > /* A-profile PAC is 64-bit only. */ > - features.pauth = linux_get_hwcap (8) & AARCH64_HWCAP_PACA; > + features.pauth = linux_get_hwcap (pid, 8) & AARCH64_HWCAP_PACA; > /* A-profile MTE is 64-bit only. */ > - features.mte = linux_get_hwcap2 (8) & HWCAP2_MTE; > + features.mte = linux_get_hwcap2 (pid, 8) & HWCAP2_MTE; > features.tls = aarch64_tls_register_count (tid); > > current_process ()->tdesc = aarch64_linux_read_description (features); > @@ -3322,7 +3323,7 @@ aarch64_target::supports_memory_tagging () > #endif > } > > - return (linux_get_hwcap2 (8) & HWCAP2_MTE) != 0; > + return (linux_get_hwcap2 (current_thread->id.pid (), 8) & HWCAP2_MTE) != 0; > } > > bool > diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc > index 98ba0e02524b..5975b44af0ae 100644 > --- a/gdbserver/linux-arm-low.cc > +++ b/gdbserver/linux-arm-low.cc > @@ -958,7 +958,7 @@ get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self) > static const struct target_desc * > arm_read_description (void) > { > - unsigned long arm_hwcap = linux_get_hwcap (4); > + unsigned long arm_hwcap = linux_get_hwcap (current_thread->id.pid (), 4); > > if (arm_hwcap & HWCAP_IWMMXT) > return arm_linux_read_description (ARM_FP_TYPE_IWMMXT); > diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc > index 7e1de3978933..5cd22824e470 100644 > --- a/gdbserver/linux-low.cc > +++ b/gdbserver/linux-low.cc > @@ -5483,12 +5483,11 @@ linux_process_target::supports_read_auxv () > to debugger memory starting at MYADDR. */ > > int > -linux_process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr, > - unsigned int len) > +linux_process_target::read_auxv (int pid, CORE_ADDR offset, > + unsigned char *myaddr, unsigned int len) > { > char filename[PATH_MAX]; > int fd, n; > - int pid = lwpid_of (current_thread); > > xsnprintf (filename, sizeof filename, "/proc/%d/auxv", pid); > > @@ -6982,14 +6981,15 @@ linux_get_pc_64bit (struct regcache *regcache) > /* See linux-low.h. */ > > int > -linux_get_auxv (int wordsize, CORE_ADDR match, CORE_ADDR *valp) > +linux_get_auxv (int pid, int wordsize, CORE_ADDR match, CORE_ADDR *valp) > { > gdb_byte *data = (gdb_byte *) alloca (2 * wordsize); > int offset = 0; > > gdb_assert (wordsize == 4 || wordsize == 8); > > - while (the_target->read_auxv (offset, data, 2 * wordsize) == 2 * wordsize) > + while (the_target->read_auxv (pid, offset, data, 2 * wordsize) > + == 2 * wordsize) > { > if (wordsize == 4) > { > @@ -7019,20 +7019,20 @@ linux_get_auxv (int wordsize, CORE_ADDR match, CORE_ADDR *valp) > /* See linux-low.h. */ > > CORE_ADDR > -linux_get_hwcap (int wordsize) > +linux_get_hwcap (int pid, int wordsize) > { > CORE_ADDR hwcap = 0; > - linux_get_auxv (wordsize, AT_HWCAP, &hwcap); > + linux_get_auxv (pid, wordsize, AT_HWCAP, &hwcap); > return hwcap; > } > > /* See linux-low.h. */ > > CORE_ADDR > -linux_get_hwcap2 (int wordsize) > +linux_get_hwcap2 (int pid, int wordsize) > { > CORE_ADDR hwcap2 = 0; > - linux_get_auxv (wordsize, AT_HWCAP2, &hwcap2); > + linux_get_auxv (pid, wordsize, AT_HWCAP2, &hwcap2); > return hwcap2; > } > > diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h > index aebfe05707e5..221de85aa2ee 100644 > --- a/gdbserver/linux-low.h > +++ b/gdbserver/linux-low.h > @@ -178,7 +178,7 @@ class linux_process_target : public process_stratum_target > > bool supports_read_auxv () override; > > - int read_auxv (CORE_ADDR offset, unsigned char *myaddr, > + int read_auxv (int pid, CORE_ADDR offset, unsigned char *myaddr, > unsigned int len) override; > > int insert_point (enum raw_bkpt_type type, CORE_ADDR addr, > @@ -946,17 +946,16 @@ extern int have_ptrace_getregset; > *VALP and return 1. If not found or if there is an error, return > 0. */ > > -int linux_get_auxv (int wordsize, CORE_ADDR match, > - CORE_ADDR *valp); > +int linux_get_auxv (int pid, int wordsize, CORE_ADDR match, CORE_ADDR *valp); > > /* Fetch the AT_HWCAP entry from the auxv vector, where entries are length > WORDSIZE. If no entry was found, return zero. */ > > -CORE_ADDR linux_get_hwcap (int wordsize); > +CORE_ADDR linux_get_hwcap (int pid, int wordsize); > > /* Fetch the AT_HWCAP2 entry from the auxv vector, where entries are length > WORDSIZE. If no entry was found, return zero. */ > > -CORE_ADDR linux_get_hwcap2 (int wordsize); > +CORE_ADDR linux_get_hwcap2 (int pid, int wordsize); > > #endif /* GDBSERVER_LINUX_LOW_H */ > diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc > index fdf74727e392..f8dd770b8eb3 100644 > --- a/gdbserver/linux-ppc-low.cc > +++ b/gdbserver/linux-ppc-low.cc > @@ -894,8 +894,8 @@ ppc_target::low_arch_setup () > > /* The value of current_process ()->tdesc needs to be set for this > call. */ > - ppc_hwcap = linux_get_hwcap (features.wordsize); > - ppc_hwcap2 = linux_get_hwcap2 (features.wordsize); > + ppc_hwcap = linux_get_hwcap (current_thread->id.pid (), features.wordsize); > + ppc_hwcap2 = linux_get_hwcap2 (current_thread->id.pid (), features.wordsize); > > features.isa205 = ppc_linux_has_isa205 (ppc_hwcap); > > @@ -1097,7 +1097,7 @@ is_elfv2_inferior (void) > const struct target_desc *tdesc = current_process ()->tdesc; > int wordsize = register_size (tdesc, 0); > > - if (!linux_get_auxv (wordsize, AT_PHDR, &phdr)) > + if (!linux_get_auxv (current_thread->id.pid (), wordsize, AT_PHDR, &phdr)) > return def_res; > > /* Assume ELF header is at the beginning of the page where program headers > diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc > index b3ccdff3e57f..48f64ef7bb3b 100644 > --- a/gdbserver/linux-s390-low.cc > +++ b/gdbserver/linux-s390-low.cc > @@ -592,7 +592,7 @@ s390_target::low_arch_setup () > /* Determine word size and HWCAP. */ > int pid = pid_of (current_thread); > int wordsize = s390_get_wordsize (pid); > - unsigned long hwcap = linux_get_hwcap (wordsize); > + unsigned long hwcap = linux_get_hwcap (pid, wordsize); > > /* Check whether the kernel supports extra register sets. */ > int have_regset_last_break > diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc > index 15afa36d1152..4defd79eee47 100644 > --- a/gdbserver/netbsd-low.cc > +++ b/gdbserver/netbsd-low.cc > @@ -581,11 +581,9 @@ netbsd_read_auxv(pid_t pid, void *offs, void *addr, size_t len) > to debugger memory starting at MYADDR. */ > > int > -netbsd_process_target::read_auxv (CORE_ADDR offset, > +netbsd_process_target::read_auxv (int pid, CORE_ADDR offset, > unsigned char *myaddr, unsigned int len) > { > - pid_t pid = pid_of (current_thread); > - > return netbsd_read_auxv (pid, (void *) (intptr_t) offset, myaddr, len); > } > > diff --git a/gdbserver/netbsd-low.h b/gdbserver/netbsd-low.h > index daefc302785e..050b43fc54f4 100644 > --- a/gdbserver/netbsd-low.h > +++ b/gdbserver/netbsd-low.h > @@ -77,7 +77,7 @@ class netbsd_process_target : public process_stratum_target > > bool supports_read_auxv () override; > > - int read_auxv (CORE_ADDR offset, unsigned char *myaddr, > + int read_auxv (int pid, CORE_ADDR offset, unsigned char *myaddr, > unsigned int len) override; > > bool supports_hardware_single_step () override; > diff --git a/gdbserver/server.cc b/gdbserver/server.cc > index d802e8b4a341..21fb51a45d16 100644 > --- a/gdbserver/server.cc > +++ b/gdbserver/server.cc > @@ -1443,7 +1443,8 @@ handle_qxfer_auxv (const char *annex, > if (annex[0] != '\0' || current_thread == NULL) > return -1; > > - return the_target->read_auxv (offset, readbuf, len); > + return the_target->read_auxv (current_thread->id.pid (), offset, readbuf, > + len); > } > > /* Handle qXfer:exec-file:read. */ > diff --git a/gdbserver/target.cc b/gdbserver/target.cc > index 24b8e2160138..b4f8e9f1efb6 100644 > --- a/gdbserver/target.cc > +++ b/gdbserver/target.cc > @@ -344,8 +344,8 @@ process_stratum_target::supports_read_auxv () > } > > int > -process_stratum_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr, > - unsigned int len) > +process_stratum_target::read_auxv (int pid, CORE_ADDR offset, > + unsigned char *myaddr, unsigned int len) > { > gdb_assert_not_reached ("target op read_auxv not supported"); > } > diff --git a/gdbserver/target.h b/gdbserver/target.h > index eea651c30b4b..1b0caa98c56a 100644 > --- a/gdbserver/target.h > +++ b/gdbserver/target.h > @@ -172,10 +172,10 @@ class process_stratum_target > /* Return true if the read_auxv target op is supported. */ > virtual bool supports_read_auxv (); > > - /* Read auxiliary vector data from the inferior process. > + /* Read auxiliary vector data from the process with pid PID. > > Read LEN bytes at OFFSET into a buffer at MYADDR. */ > - virtual int read_auxv (CORE_ADDR offset, unsigned char *myaddr, > + virtual int read_auxv (int pid, CORE_ADDR offset, unsigned char *myaddr, > unsigned int len); > > /* Returns true if GDB Z breakpoint type TYPE is supported, false I don't have comments on this patch. Look sane to me.