From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2077.outbound.protection.outlook.com [40.107.7.77]) by sourceware.org (Postfix) with ESMTPS id 8E1083882674 for ; Wed, 13 Sep 2023 10:22:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E1083882674 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=m5HP7YyIuuuW2z/DjhiFZcyKPJJF/w2MutVQQ3Mv1jM=; b=iZNKXIMyTahwyKCir50vaNZoamkvTl/7MPEkvACKwh1jVZulNk1z9hhyChIWxR/Pu57aGPnwEtHu9feIH7NhF9YG4j61HJmYgA8CmE26KxgjfxiymmhB4oqbPEIzyk9T2AOPfmSz0Jb/qE0czYijD0YQ0xDux/5yXupT4cork64= Received: from AM6P192CA0085.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::26) by AS4PR08MB7877.eurprd08.prod.outlook.com (2603:10a6:20b:51c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Wed, 13 Sep 2023 10:22:09 +0000 Received: from AM7EUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8d:cafe::a3) by AM6P192CA0085.outlook.office365.com (2603:10a6:209:8d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19 via Frontend Transport; Wed, 13 Sep 2023 10:22:09 +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 AM7EUR03FT060.mail.protection.outlook.com (100.127.140.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.19 via Frontend Transport; Wed, 13 Sep 2023 10:22:07 +0000 Received: ("Tessian outbound 1eb4e931b055:v175"); Wed, 13 Sep 2023 10:22:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9e298e5d84f2253d X-CR-MTA-TID: 64aa7808 Received: from f4e95a4d817c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 432CB426-CFC0-43E5-AADF-BB780B69BE19.1; Wed, 13 Sep 2023 10:18:30 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f4e95a4d817c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 13 Sep 2023 10:18:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H/CfpgTWjnr09boaTUWxrFFF37p2/hGyRWSrSjj33eR6StrbeR+JPSZ0BuAYYhsqYqRR1Cl3/+nQEcQZkojqcSCVuEKGHxurQ8xtBKlTFCoRAAhXvDZXSr6XnFyOa8MXvAuQqXu11G/5nMTPUdzLtAexBRFPNRwlp37qzaNQtn7UAf1Ifxp44Hb2KvnEUX2951LSWRc46/cLJst9PRPiR5G+Ry18vY6xE/yB8fYowVoofWIjNXgIYdFC66RMnSZz3uI/IquDsW9n/6TyiwjjA2OwW1Yo3XkYUEVdJriY2/NP2tK+AcnMAPxdtVytJv882Lo9HwSZa+5A2yQhdHHJRA== 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=m5HP7YyIuuuW2z/DjhiFZcyKPJJF/w2MutVQQ3Mv1jM=; b=mOwOiOvPqb5E+/TXpQEUhzilIPqp6clRxlmGvZWGvx/lOSr5KoFLseDP9X3b7h+mnCnbU7iw+CCKtad3B2RHusM5c48IZL09/j1QkNUrhQkftOGW21FCHNTIL8UXNwIXx51Ib+6uaiNRhaWIUhDabzkKp86iYk0voJ6mX7ayrFn15D3t3pJx7Zguri6fwLKMu7orHFMaG17ORlqoEs0izxp+9aBSwD21toaLD9XanhF28eLxSjlUKYGWWDsXBmkRsXxMU3kD+mdqrKKuKYK9VbkIX+OVAw99jo3azKUzTL8C/FmiQdTyyy2x2P6ak+nOriyrwDHNALcC2y3QUzKyjg== 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 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=m5HP7YyIuuuW2z/DjhiFZcyKPJJF/w2MutVQQ3Mv1jM=; b=iZNKXIMyTahwyKCir50vaNZoamkvTl/7MPEkvACKwh1jVZulNk1z9hhyChIWxR/Pu57aGPnwEtHu9feIH7NhF9YG4j61HJmYgA8CmE26KxgjfxiymmhB4oqbPEIzyk9T2AOPfmSz0Jb/qE0czYijD0YQ0xDux/5yXupT4cork64= Received: from AS4P189CA0016.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::8) by PAWPR08MB8909.eurprd08.prod.outlook.com (2603:10a6:102:33a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36; Wed, 13 Sep 2023 10:18:28 +0000 Received: from AM7EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:5db:cafe::e8) by AS4P189CA0016.outlook.office365.com (2603:10a6:20b:5db::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.36 via Frontend Transport; Wed, 13 Sep 2023 10:18:28 +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 AM7EUR03FT040.mail.protection.outlook.com (100.127.140.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.19 via Frontend Transport; Wed, 13 Sep 2023 10:18:28 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 13 Sep 2023 10:18:28 +0000 Received: from e129171.arm.com (10.57.66.200) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Wed, 13 Sep 2023 10:18:27 +0000 From: Luis Machado To: CC: , Subject: [PATCH v6 06/17] [gdbserver/generic] Convert tdesc's expedite_regs to a string vector Date: Wed, 13 Sep 2023 11:18:04 +0100 Message-ID: <20230913101815.178154-7-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230913101815.178154-1-luis.machado@arm.com> References: <20230913101815.178154-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT040:EE_|PAWPR08MB8909:EE_|AM7EUR03FT060:EE_|AS4PR08MB7877:EE_ X-MS-Office365-Filtering-Correlation-Id: 1021482c-e609-441d-e7e0-08dbb4434876 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: Gsz2K2TjldD3QwQfRtGYwc7pQ+N4ukugvD3kUZq4E0kgkbSfFF1jaMsf6nXlwIJwflW6Cx2Y96VoZMYnz23jUjy3rb0QCIGFp/7L6BsDuzqhWEVB0uktMCrGG5kKi2KdUk8cqGTdKJfdoSX2LncoVZnFecTjSevKydsm2oM50FgscgIadDvxCGd7aSkQOUifMJvFi0CAOMuTgOVLpWBOGeNQ20X7vfZ+2NfF5lZjPw3mk/+zjQJLKQE/W3zzeaX4nJiuQshK1Wfr0LxS3bIGlvChAUcSuIoUvJLreXxe64uMdsQ7kBC2lv1ji0djSlmyZzblDEjAk2C1RMAFI7rxLNwTHGR2L0KtGkWZIHK2MBoFH9YT9FxOxzcuD+zUSZWqq7vtp9oZrfU2fBtyNbSdu4DXOyVUQ3A8GcN39p2NnXKmxxW+CDMQqexF1SUvwtXWKmQHjLCEP3TKpnIB//gTb8ZcmN6DAKvZoSWjGXyOu96ZIiFAYwCy+lKDF3zIgbELTotPGXbBgKk+4M4zFNcFSg2dzf0byEMuwXzyaxg8s3ltoncndOSk/f81O7/jZ8Zry8c0AYea/2XV8kIPBsr1Byww57idgmtM6g9H47pFBoS1tC17/P4wLvJ605xtpQdhGNWjUrQtdMvqs6hWAeSJqmHfSRdQv2Bg5xW+Y9N3gSkKBLb9oPZmW/RdqupZOOSHMguXO/yQaOzELz4eosj68b9orTUihWIXmt+to60Mt3eiitw+9f2lM53phU3eeY+t77BF41uCt4/YKoDSuda2vjjRHbDiFu34mrhDBg1Zo7k= 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:(13230031)(4636009)(136003)(396003)(346002)(376002)(39860400002)(1800799009)(186009)(82310400011)(451199024)(40470700004)(46966006)(36840700001)(316002)(70586007)(70206006)(54906003)(336012)(6916009)(26005)(2616005)(1076003)(36756003)(83380400001)(7696005)(82740400003)(6666004)(356005)(86362001)(81166007)(36860700001)(47076005)(40480700001)(40460700003)(426003)(478600001)(2906002)(8676002)(4326008)(8936002)(41300700001)(44832011)(5660300002)(41533002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB8909 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b35012cf-2d4e-4cac-a395-08dbb442c602 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D0C6XBuchDYMOFP3d1kMYWMf+bbD1WKqrLgadSFWEK9zrE6o0+G9ScqnJ6wRPv5hc5Oo0jVAboiuMUXUo7bLX1PIxDSrKQ4Csuhm95AOtUlgXJJ67TheL+8MPL0aMWVAFsfKDYk6ubGCmKA0q/eJmDj3Lz1XGZJgh9ql5uqs183FFgiX7d0Fmz4i/oGDTKCI3CLrF5A0LnZOvx0BBJ0YR6wtEalvqq5RebSoWfGVEjX3Hx0/kXgw8VA0BdoJ1kdTHSNodz3TzSQ/M+uToXtMGLFKXM+Kxw2eyWvEFvRl4rVPPWWykmoNIIQUqvMLfxC8XZPl1XXx5NG9bxhf8YOU/gV1tALWVQA/uIZZRK7S0arGR2fsUdJQtPq2Hnbxhj3mmDrVsGmRiJwhITYnvd4jbdb9tF5SlzMca7rbSyd9TfuRgeUAWQleCnwGp2nrz8wPFEdE2JZ880g5SzqtQ9UhnfMGIY0rYPekynnjN4+HU9uGb7JF7QIlo2O3HjIaZrCwQMhSCR0BUff/zzPhrNbhvPmPJ1h0xp7ggdhilu4hMU3Z1iIBvIWX3PSR1pea7l5Pdlp9OplejPP8eL5JdyNJfbfSMlI2g2mA+3FUc0A4jiN/HWKtweN4roEbjRnKSKTYEXB96srucH67a/cs9/KtZnHXP+O4j9S+zEPQvjNDzcesJBYBq1S4op/1pOCaXsnMo139upUJ55i35odWs8s22FaKn4Tn2Gwco9cb1H+zE1NvLN8EIyt06zHdZok7XNW+tDtavVJlfV0sn8NIJ0mwMw== 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:(13230031)(4636009)(39860400002)(376002)(396003)(136003)(346002)(186009)(451199024)(1800799009)(82310400011)(40470700004)(46966006)(36840700001)(8936002)(316002)(5660300002)(6916009)(4326008)(54906003)(41300700001)(44832011)(8676002)(70206006)(70586007)(36756003)(47076005)(426003)(478600001)(81166007)(6666004)(26005)(83380400001)(86362001)(7696005)(336012)(107886003)(2906002)(1076003)(2616005)(40460700003)(40480700001)(82740400003)(36860700001)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 10:22:07.3992 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1021482c-e609-441d-e7e0-08dbb4434876 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: AM7EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7877 X-Spam-Status: No, score=-11.8 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 List-Id: Right now the list of expedited registers is stored as an array of char *, with a nullptr element at the end to signal its last element. Convert expedite_regs to a std::vector of std::string so it is easier to manage the elements and the storage is handled automatically. Eventually we might want to convert all the target functions so they pass a std::vector of std::string as well. Or maybe expose an interface that target can use to add expedited registers on-by-one depending on the target description discovery needs, as opposed to just a static list of char *. --- gdbserver/remote-utils.cc | 13 +++++-------- gdbserver/tdesc.cc | 23 ++++++++++++++--------- gdbserver/tdesc.h | 4 ++-- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc index 722915d30f2..fb5c38d4522 100644 --- a/gdbserver/remote-utils.cc +++ b/gdbserver/remote-utils.cc @@ -1068,7 +1068,6 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status) case TARGET_WAITKIND_SYSCALL_ENTRY: case TARGET_WAITKIND_SYSCALL_RETURN: { - const char **regp; struct regcache *regcache; char *buf_start = buf; @@ -1155,8 +1154,6 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status) switch_to_thread (the_target, ptid); - regp = current_target_desc ()->expedite_regs; - regcache = get_thread_regcache (current_thread, 1); if (the_target->stopped_by_watchpoint ()) @@ -1188,11 +1185,11 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status) buf += strlen (buf); } - while (*regp) - { - buf = outreg (regcache, find_regno (regcache->tdesc, *regp), buf); - regp ++; - } + /* Handle the expedited registers. */ + for (const std::string &expedited_reg : + current_target_desc ()->expedite_regs) + buf = outreg (regcache, find_regno (regcache->tdesc, + expedited_reg.c_str ()), buf); *buf = '\0'; /* Formerly, if the debugger had not used any thread features diff --git a/gdbserver/tdesc.cc b/gdbserver/tdesc.cc index 2c7257c458f..072b88481b2 100644 --- a/gdbserver/tdesc.cc +++ b/gdbserver/tdesc.cc @@ -32,14 +32,13 @@ bool target_desc::operator== (const target_desc &other) const if (reg_defs != other.reg_defs) return false; - /* Compare expedite_regs. */ - int i = 0; - for (; expedite_regs[i] != NULL; i++) - { - if (strcmp (expedite_regs[i], other.expedite_regs[i]) != 0) - return false; - } - if (other.expedite_regs[i] != NULL) + /* Compare the two vectors of expedited registers. They will only match + if the following conditions are met: + + - Both vectors have the same number of elements. + - Both vectors contain the same elements. + - The elements of both vectors appear in the same order. */ + if (expedite_regs != other.expedite_regs) return false; return true; @@ -89,7 +88,13 @@ init_target_desc (struct target_desc *tdesc, gdb_assert (2 * tdesc->registers_size + 32 <= PBUFSIZ); #ifndef IN_PROCESS_AGENT - tdesc->expedite_regs = expedite_regs; + /* Drop the contents of the previous vector, if any. */ + tdesc->expedite_regs.clear (); + + /* Initialize the vector with new expedite registers contents. */ + int expedite_count = 0; + while (expedite_regs[expedite_count] != nullptr) + tdesc->expedite_regs.push_back (expedite_regs[expedite_count++]); #endif } diff --git a/gdbserver/tdesc.h b/gdbserver/tdesc.h index 7fe7d0d8eb3..8a29fc6fe6d 100644 --- a/gdbserver/tdesc.h +++ b/gdbserver/tdesc.h @@ -40,9 +40,9 @@ struct target_desc final : tdesc_element std::vector features; #ifndef IN_PROCESS_AGENT - /* An array of register names. These are the "expedite" registers: + /* A vector of register names. These are the "expedite" registers: registers whose values are sent along with stop replies. */ - const char **expedite_regs = NULL; + std::vector expedite_regs; /* Defines what to return when looking for the "target.xml" file in response to qXfer:features:read. Its contents can either be -- 2.25.1