From patchwork Tue Sep 20 12:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 57804 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77EE23858297 for ; Tue, 20 Sep 2022 12:29:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77EE23858297 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663676954; bh=3zOHFZwqCcIrw7awWEAZ6xfKb/C95AnprW+kuyyolEU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=v/41Y9VI+VclSy5P/Pr5UvpFDrTCxbLFQzx6+AZTs93xdqFMca3F4ODF8UTE3EaGo YhSEPj6bVMaT71cPOz+C1oGhVf4X/aknuz0dyGYtEXhMnJlw4A7PMZCwh7EY3t980V whulq5+E5ZR2TcLuYBYPP3KlstS/LH+Qzhw4dXic= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2067.outbound.protection.outlook.com [40.107.20.67]) by sourceware.org (Postfix) with ESMTPS id 5BA633858D28 for ; Tue, 20 Sep 2022 12:28:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5BA633858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Xwgrq+oQfoRdMBZlf3PLR6S8dCAAUIXGNnCFJhL7+qHOar/7TxPB6WyU9GNGGPbZkeqZRt4YLvVV2Zg3/Vj0MfVbe2NWp7SbzgzDE662aN1AlOrtUnkeqgqXjvifx75wHDZeiBkA7+K8Gkz8uYDSjGnVI8BoAU+jocBtyYemLrXz9AukVHogxFrDhJ1qPTYKglDHLtT62IDbL+TuPbdxt7R2QRYD+W6iUZciov97+olrwWuMLFH6hbggXOBHOiaPEUlH8UUwNpQOAYgWZGk2R8+t6TFHh5g5oN6miBq3wZlrGI+pX7EXD5Hk+XZOBChLqhbgD/5n23L5P+ZW3Q8e6Q== ARC-Message-Signature: i=2; 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=3zOHFZwqCcIrw7awWEAZ6xfKb/C95AnprW+kuyyolEU=; b=cYv3jC28Vf9b89aQieDkZV++Nh/cqnHuDhBL1aj2nTpPfIvQfDEny/w0C3LGMwcU+hXXM/Q4RDFrfJCo3R8yR+qP82qPiN6i1CJ6gmvzfCGoiF2FBDTG7HbPxDDGwRCmYkWTFgDmzHG6JsC3hJuZp75MGdM48rAVHfD1arpeEG9s4/E6VDYAS9FBcaRw0aC1tgfJW1pVwRp6JLzyVK7PCpRn4njKTgK4gqUWbEjJFYxVRJk6ynycqtKvG7B1DQ3dViBz5N9l5AsUQQ/F/ez6vSJ3+1SXmBr2oZSc/3MM1LRHihZDqa6PTAZtba5aslf+j0xilYRBtFpWDsFOtSNwOA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1, 1, smtp.mailfrom=arm.com] dmarc=[1, 1, header.from=arm.com]) Received: from AS9PR0301CA0009.eurprd03.prod.outlook.com (2603:10a6:20b:468::16) by DU0PR08MB8561.eurprd08.prod.outlook.com (2603:10a6:10:406::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21; Tue, 20 Sep 2022 12:28:46 +0000 Received: from AM7EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:468:cafe::f1) by AS9PR0301CA0009.outlook.office365.com (2603:10a6:20b:468::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21 via Frontend Transport; Tue, 20 Sep 2022 12:28:46 +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 AM7EUR03FT026.mail.protection.outlook.com (100.127.140.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.12 via Frontend Transport; Tue, 20 Sep 2022 12:28:46 +0000 Received: ("Tessian outbound fc2405f9ecaf:v124"); Tue, 20 Sep 2022 12:28:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6bb45ea8dfc0607f X-CR-MTA-TID: 64aa7808 Received: from 34238e57dd4b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B672120D-8C9E-4ABE-A8E9-66C9F6EDA47F.1; Tue, 20 Sep 2022 12:28:38 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 34238e57dd4b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 20 Sep 2022 12:28:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQDXbRfRKf8r7NAOb9pKb9LSFcUqEdbGIjO4ESIRIfM/ugMAbcjO3VAJRxi3Wbv5vDIIrvID92yIRogcxncLARXrsRel2e6Ay9c/NM8PQv6pISEtZDN60nrRJFqb2mHnaY9LiAKFJy0IM/6B/TBUi50TLISiqxy/hF1TVFBZ/WHNhqLKfrcSNFQ5XC5VwmSP2cVnFDlobima+oByzascPGbMJFkbgcijHy6h6Ra2uRsG744gq+0c74YrYtz3mykSkl2Rb1TOYouzllFr/jUZWM15s9AzA+Awq3zjjbveSbht1vGu456vGwnNBxFEJir2U2AyNXPb9fYoncnB3swfbw== 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=3zOHFZwqCcIrw7awWEAZ6xfKb/C95AnprW+kuyyolEU=; b=HXZI8dHTQbDwb7MIp85C1q9/ae8EmBX6uIb3VLPdv4hhQM3fJSlXWgEaOkehFgrKoGEPB5LRG5kskkv6AwMPPmzGCWFJyZaokGudjDFfyoEiSFQfBsgcLu8c1bNzFI+CxawmK1mgkRZ4mFZHUDCSn8Up37XKqCvfO5WyeomC/orhRIVqViYl1NfhOHo2Pidc7nb87lTpgT7js3fUh5L/SC5GJjXkJ7xsoALThx3ZQvQXdIEF8u1a481hIBEr3Q/ikKSIWtPiF4v0gRnvlScxStqXWW8ly57sf+jj8ioul5OS1htIm1Er29Giwb6suYLTmYDJoQJFazFffkC5M/lgLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from DB8P191CA0027.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::37) by GV2PR08MB8073.eurprd08.prod.outlook.com (2603:10a6:150:75::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.16; Tue, 20 Sep 2022 12:28:35 +0000 Received: from DBAEUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:130:cafe::2a) by DB8P191CA0027.outlook.office365.com (2603:10a6:10:130::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Tue, 20 Sep 2022 12:28:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT011.mail.protection.outlook.com (100.127.142.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5632.12 via Frontend Transport; Tue, 20 Sep 2022 12:28:35 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2507.9; Tue, 20 Sep 2022 12:28:35 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.9; Tue, 20 Sep 2022 12:28:34 +0000 Received: from e129171.arm.com (10.57.17.20) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.9 via Frontend Transport; Tue, 20 Sep 2022 12:28:34 +0000 To: Subject: [PATCH] Invalidate auxv cache before creating a core target Date: Tue, 20 Sep 2022 13:28:28 +0100 Message-ID: <20220920122828.188190-1-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220719144542.1478037-1-luis.machado@arm.com> References: <20220719144542.1478037-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT011:EE_|GV2PR08MB8073:EE_|AM7EUR03FT026:EE_|DU0PR08MB8561:EE_ X-MS-Office365-Filtering-Correlation-Id: 5cb2d09d-1d44-4842-db7e-08da9b03a9b5 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: 62HBB9a8gb4tR4BwR/UzBJMOAllYBxwWzL9WnebOCfFAzUNbSw4PuQPwoy083bKG3aTYai0hgm296qppUegAdN8mZmywuLy07Cn0MsjkHS8FGYiH7d4YYbT+wMtgZERvLhdelCSBuFrVbLA+gyADCquzzq/C0t6jhQOHPe3ZaKIM09Ok09AQmihPS3QfW86F05WgSlb10QaHmBbaECvlyMXnm5yQyw/QlsWMKwkTJg6gcNsTXVbWgGuZdIAZhvIPh/OPHopp0hfGOxCSjFOeq1f8PIaDcmCkxlGH7qPeHzhi0KPfCcni8/teO84Xzq96zg9BSJll8AylF9heLrlfuqHvr0GUoQsiCg03w6lvZWf9bLm2JKHmGKrOciI/IkE/Z6hBeeHlJTItXJfSJG5ejZr553p5HczY/++Uaad2w9m1J7lwsuJWMqoM8aIg64l1lgOqlQJvBSJbVYJltc+xwfmdh+5qZHEZBsJgPM0HY92HVJ1N4SX9mRyI9JnzcEf9kJAkwQLdSvsD1UmR1QjUmaX9hRACotTfOS0Q/o3rvEl5aIV4azkUKEqilgBBq+d2tl7xa1HkF35J6Fxct0ScgH2rKpiH3bpYKZNDidpwY6C/kk10+X+j6A4kieikm+SkhtdhID6QDRY0O68wcdPMz3sJrhtWnBD7ILLb/I3Vd8Ljq/bgOwMTtK1wkroBfqMp9OMPpAo1PRFZKVPeYTWerKZt3KMTdhFR0C42MYnltG4Pu5l9q1WwF84OEPA9oxRLWNA7G672CpD4Xlyz1txxrDaqoaE9BAJyLMG/wcqJU48pAWJ7z2G/Sel7LnbRF8np X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(136003)(39860400002)(376002)(346002)(396003)(451199015)(46966006)(40470700004)(36840700001)(82310400005)(478600001)(83380400001)(6916009)(86362001)(316002)(41300700001)(336012)(8676002)(26005)(36756003)(4326008)(36860700001)(40480700001)(70586007)(40460700003)(356005)(7696005)(1076003)(44832011)(6666004)(47076005)(2616005)(426003)(70206006)(5660300002)(82740400003)(2906002)(8936002)(81166007)(186003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8073 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ea4f8caf-6f87-488d-2aa5-08da9b03a34b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ol5nlFH/TYDzehV4dg0T6dPqvQuLg3ur360kYuNetuDZO4Rck7baMdT3Ib8lwtXaQN5Xlvg/Y2hlWaCUlhzBzVpi0tcB4MKuqj4nAtbX2Drp7U4JbdG1x1ahhEwJBeOyEJIhgXdoDMV9odCXE67q5AmYbFbLZNe2mMHMdBAsvlvgakHct/XShjmhb6wtg6d0n2gxLN6erISNxNE+Q/c5cFtVeo6gd3NfPgvNsiJnA30PItAWlwO/qaV+npBq7exsFzujXig/RHRUGHzmOs0Rv/Dvygf83qITa/9p/LOSqZxdr8ojRlSidEX7miQC5a7BDe69VApywq77+rIbj2D8s6YXcer2rWRKMzOY4fJVSlAVJO5BW7r0SYV0X3lZKXyi3t0mPox+Q8zFlsGA+MH5axGALDX/Q//mm7QiUS1JECab4V/MsaInpDSDcdnY30erSaa3Wsgm5VlDaAT5xsMHcpgHAEwfhZLykOnxW6N0yBeTP/yYNTMCCPCeHhHwkNfRwe66nxJs7ZPL4UP8Tn4M+imiFTL03sx+NAg6uQGU9rUNEoqeZOQpmyADLx4PlcmagnJiCmp5QnDX5gBVeTFU1Alt7ehQs1LydAReioAo0/Q0a92b0NSKhFShnJC+wI/LMhIzNkPcrWa+yzWFjHO9PrOw9NqHPvljUuFS1FZRSVgI79/6o52OH4bZXoMPpin9d8435h24AWw3D9ldI1P9oaIHdVd3Z3VZE5TH8mZUhPCXix9ZxRkRDBgwIVvZ4ktLa8v+HiBdKlDnngcDpslfiQ== 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:(13230022)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199015)(46966006)(40470700004)(36840700001)(36756003)(478600001)(41300700001)(107886003)(6666004)(36860700001)(82310400005)(40480700001)(81166007)(86362001)(70586007)(5660300002)(4326008)(8676002)(70206006)(40460700003)(8936002)(82740400003)(6916009)(2906002)(44832011)(316002)(1076003)(186003)(2616005)(26005)(426003)(83380400001)(336012)(7696005)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2022 12:28:46.0352 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5cb2d09d-1d44-4842-db7e-08da9b03a9b5 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: AM7EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8561 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, 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 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: , X-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" While adding support for MTE corefiles and running the MTE corefile tests, I noticed a strange situation where loading the symbol file + core file through the command line has a different behavior compared to firing up GDB, loading the symbol file with the "file" command and then loading the core file with the "core" command. I tracked this down to gdb/auxv.c:get_auxv_inferior_data returning empty auxv data for pid 0, which gets cached. This is triggered by attempting to read auxv data for the exec target. In the early stages of reading the core file, we're still using inferior pid 0, so when we attempt to read auxv to determine corefile features, we get the cached empty data vector again. This breaks core_gdbarch setup. To overcome this, make sure we invalidate the auxv data when creating a new core target. --- gdb/auxv.c | 4 ++-- gdb/auxv.h | 2 ++ gdb/corelow.c | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gdb/auxv.c b/gdb/auxv.c index 6154988f6dd..2423f51f224 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -342,9 +342,9 @@ invalidate_auxv_cache_inf (struct inferior *inf) auxv_inferior_data.clear (inf); } -/* Invalidate current inferior's auxv cache. */ +/* See auxv.h */ -static void +void invalidate_auxv_cache (void) { invalidate_auxv_cache_inf (current_inferior ()); diff --git a/gdb/auxv.h b/gdb/auxv.h index a4801c34d2f..242bc2eff00 100644 --- a/gdb/auxv.h +++ b/gdb/auxv.h @@ -79,5 +79,7 @@ extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops); extern target_xfer_partial_ftype memory_xfer_auxv; +/* Invalidate current inferior's auxv cache. */ +void invalidate_auxv_cache (void); #endif diff --git a/gdb/corelow.c b/gdb/corelow.c index 293bc8d4f59..1c30c7d011c 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -53,6 +53,7 @@ #include "gdbcmd.h" #include "xml-tdesc.h" #include "memtag.h" +#include "auxv.h" #ifndef O_LARGEFILE #define O_LARGEFILE 0 @@ -515,6 +516,20 @@ core_target_open (const char *arg, int from_tty) current_program_space->cbfd = std::move (temp_bfd); + /* Some architectures identify features using the hwcap bits that + come from the auxv. Before creating a new core target, make sure we + invalidate the auxv cache so we can get fresh data. + + This is required when we have an exec target before loading the core + file. Under such conditions the pid is 0, and the exec target may + attempt to fetch and cache the auxv. This results in GDB caching + empty contents as the exec target doesn't have auxv data. + + Given we haven't determined the pid yet (we will read it later), it can + still be 0 and simply fetching the auxv may return the cached empty + data. This ultimately results in problems coming up with the proper + gdbarch data. */ + invalidate_auxv_cache (); core_target *target = new core_target (); /* Own the target until it is successfully pushed. */