From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2058.outbound.protection.outlook.com [40.107.20.58]) by sourceware.org (Postfix) with ESMTPS id CFF593857724 for ; Mon, 18 Sep 2023 21:27:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CFF593857724 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=ZNSz36M2+AE+x9ujWcDhDu94gh0A7q2m79rI4JTM1S8=; b=wguQlroqEbKkzTiY9hw5DmBQZkKD0FwP5NyYJmECaxNGshr9rA53MPJKT+gdYqdedt4r/croejOuS6gWcxcz2xuVqZ//ubdYsZRNMesjsWpMLCJF2nbIIW26iViscTa74ow+Zljj3FLoyoisW3V5mbxrGJqnjiWSjO9ilMiDrPI= Received: from AS9PR04CA0160.eurprd04.prod.outlook.com (2603:10a6:20b:530::28) by AS2PR08MB8806.eurprd08.prod.outlook.com (2603:10a6:20b:5f2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20; Mon, 18 Sep 2023 21:27:14 +0000 Received: from AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:530:cafe::1b) by AS9PR04CA0160.outlook.office365.com (2603:10a6:20b:530::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:14 +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 AM7EUR03FT036.mail.protection.outlook.com (100.127.140.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:13 +0000 Received: ("Tessian outbound 0b7d6027328f:v175"); Mon, 18 Sep 2023 21:27:13 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 55d4df9221705917 X-CR-MTA-TID: 64aa7808 Received: from 41dff4dd77a0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C5CADACA-5CAA-41F5-9D9D-3F178B0EB38C.1; Mon, 18 Sep 2023 21:27:07 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 41dff4dd77a0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 Sep 2023 21:27:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZrmEzhUxuJL+Frfp1QcR/vLJmoLiQsuTCHrJEZXy4IdFcEV2NR8xziwoDEeOIXhtAOdZqfK3uUocrLAsbtPYh9r84/J3TVijTSVQJ7naRyf3dYRIlMMrJvv5iCbXMmIKo9ACSBEfHkJI7Bq93IbQuTFkFwFFih+rqbUHHvRLiJ/yINrF+UAcX/BBTG5olT8ifUMiceZo4FecyYlICSE/uuR9D3WB8H4QmO1ICa1XNwqaUbkcn+AKX0vBGgJTSPEYfuBWmSM0F88+U/n/sy1D4orlgmH10zWmoIOdnUxreXeQh/OFJahrgNkegEHDCi7/mmKQcyGGkPYBhu5zENhVYA== 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=ZNSz36M2+AE+x9ujWcDhDu94gh0A7q2m79rI4JTM1S8=; b=hb6NBCphGtOXCEzytqFJ139qD4lLvBGe2uXVUt6X7Uce7QDpb5Bm3CZ4vWFun8HeC2BdlSynmO2b0KxpX73JbuXC4+9eX3koVGgL9FsJ0g7MKWk44iNlzXeIpQRnCqq+T5u102uEXXyk+58UarkMpjksrSzxA9rrdN83WsW4GPsiZOXuO8tsreb5dcpxFKF/lpQqfc4d8dNSOIW8mUEypi29XOoIoHlk5vvmB4eLuXNI7A+QMRoL0P/2BVKAd06vLDhz+TV5VJnjGNPnWR63KyGYJKq1s8hbsyQ+DBIKz7Y+E4upFYYBIOfZxFLntWNA/F6Gbb3UneY88Gd4IGT2FQ== 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=ZNSz36M2+AE+x9ujWcDhDu94gh0A7q2m79rI4JTM1S8=; b=wguQlroqEbKkzTiY9hw5DmBQZkKD0FwP5NyYJmECaxNGshr9rA53MPJKT+gdYqdedt4r/croejOuS6gWcxcz2xuVqZ//ubdYsZRNMesjsWpMLCJF2nbIIW26iViscTa74ow+Zljj3FLoyoisW3V5mbxrGJqnjiWSjO9ilMiDrPI= Received: from AM6P193CA0127.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::32) by PAVPR08MB10331.eurprd08.prod.outlook.com (2603:10a6:102:32a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 21:27:04 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:85:cafe::14) by AM6P193CA0127.outlook.office365.com (2603:10a6:209:85::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:04 +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 AM7EUR03FT009.mail.protection.outlook.com (100.127.140.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6813.16 via Frontend Transport; Mon, 18 Sep 2023 21:27:04 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 18 Sep 2023 21:27:03 +0000 Received: from e129171.arm.com (10.57.64.238) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Mon, 18 Sep 2023 21:27:03 +0000 From: Luis Machado To: CC: , Subject: [PATCH v7 06/18] [gdbserver/generic] Convert tdesc's expedite_regs to a string vector Date: Mon, 18 Sep 2023 22:26:39 +0100 Message-ID: <20230918212651.660141-7-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230918212651.660141-1-luis.machado@arm.com> References: <20230918212651.660141-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT009:EE_|PAVPR08MB10331:EE_|AM7EUR03FT036:EE_|AS2PR08MB8806:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a1fbeef-3c11-4cb6-852e-08dbb88e06b6 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: 6apj1FCwP/dhW8e3g99A0uOvHikt8y1zmMShJCC4mQn0Z5gsXaX65e10wTOjyrVkff0MuNrVJi5MMKvwDpKn1DHzi5H6k96arY8/3iNyiNRZXF+Kz2MHiTMzXmdPwSTbtU7j8S/WYfGY1247f7Jm1cj2K9q0kkNF1HBOFvPcdny4TVhN4+S8pDFxU6xfjyjWTtEP9NKc8YhaPt0tSkjV7IRTWQzomdnxLOlZaeuckUvPpXC/NAC9VSC5YF3O8Mzqg5RUF0M6+ej5cXZIqKVnFwKgwmiCJwmgMF+jndwY4dSVK/8UKF1vjc9BE25fEwKGgtmqPU4RMde4Lz8Eo3qJI0+/xOFwzPjBJnLkbI+KN6CIjy0ppWmS/d5g3aEXNi3DpR/PvQ/2QPX4x5mFCKEYNCuN3UvYU+mM/cuRo5gj3Rwd6selCL7Hf9+qpsor6F6/u3thg7oyD8ythAeQpl64cjg3NeEB09OBwI0rpkHav76Sf7Fy48gi4Hv2wFWDnXyL4OPQGgEgj3cUD2xHylu/d9Sbwpzjtlc+avdFwFgh4QAhqz4qi7jbfnU69XEfoiIOqqC5cpvJ4pTiJlDRlnHfQl0m+AKfPsNujBRSFC7zNTtqWb9mNXxm/i48K/kfW5GPif3nv/553EyaUV5o6wUwjIJDt7EierkahsPgyztHLam0vnATPfkXKaVhJ6ifJn1yNw5N3QC8736mEDsSyKzM9mM0D+4ZFGtVXMD0Kqa5l/ZfbQ/+elMbTtyooYOqcnmxQq1tkEGHX/bRLtNJQZsW1yMzUe1uVG3WvVkApkXtY+E= 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)(346002)(396003)(376002)(136003)(39860400002)(451199024)(186009)(82310400011)(1800799009)(46966006)(40470700004)(36840700001)(478600001)(316002)(6916009)(44832011)(5660300002)(83380400001)(41300700001)(40480700001)(6666004)(2906002)(8936002)(8676002)(4326008)(70206006)(54906003)(70586007)(7696005)(26005)(40460700003)(1076003)(2616005)(426003)(336012)(36860700001)(47076005)(36756003)(356005)(81166007)(86362001)(82740400003)(41533002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB10331 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: e637214e-41fe-44fd-4fbe-08dbb88e0139 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RxzS6CxnR9Qqc/JIFeZKqbFD01XFQo0vEiWwWGX2rtvj6JZ9BEuul2ApJme+6SZAOGcmUTHK41kZgaUQzGU4O+48hoOWiTaMZphssiUg5e65JeW3y3aEI0vnXdz8hWdLCQpmxGFBi4zxeUNfot4gQ2cks4pl8pufawGKuDUq36x9VbUSFDLSJRR4GRxP+M4QhMGyRRnChSUm/NFUuJMYAi4V8wXxibLLDJ/UP0xpox+ZJ8iUiYmGMv6H6miP5Vtvjv+UnLyMzVThyLupRodDSWF5f78HZ3zDi7J+hsWu4aXM7jfhtw5glYVV082P5xlmRqn4z8czqTCrCpZQfXn+1yX2mfSOUuFoitED6v6P6EvFrFIS7fKzSonnvavmcMhbjnX3Tw4xHHwJWa3WH9kb/uGTuBeUH1H27HkxRt/Dr/zyUM6FWN1iT3AlEUtvhOolPYvhMb2SZruMYk4v0g08wjQAnfKCjSt8ymg7oYJ7y0HSGsMWOE7OPpk5FDs70yxBPLoFC5YX/w/antWx72QRVZ1MLQHUWW/fMhLiaFTv/qN11YwZjQoTsS1mFkOpC2g3NYZKOcFl2VGEOosFqXhEv5XBseP51aSrLx7DJxI/1fK0Sw2v1UgbOfnqOf3mPIaiywtewpxvUO3e8Aajgi+K4kE2ZW2dHj7Jn9AHwB6cL0xzYlHbva2fY8gOh9sZKf2CNzGvuW+uEXr/5ji5HYvkvKB4lW2LY5AWE86XsKiHFa+kzAd+hAgobgixwIV6r9KvH5gf7JEO1yj99baDxzBl+g== 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)(136003)(346002)(376002)(396003)(39860400002)(1800799009)(82310400011)(186009)(451199024)(40470700004)(36840700001)(46966006)(26005)(40480700001)(40460700003)(316002)(2906002)(36860700001)(6666004)(47076005)(83380400001)(81166007)(6916009)(82740400003)(44832011)(5660300002)(4326008)(70206006)(54906003)(7696005)(426003)(336012)(41300700001)(8936002)(8676002)(107886003)(70586007)(2616005)(1076003)(478600001)(36756003)(86362001)(41533002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 21:27:13.9923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a1fbeef-3c11-4cb6-852e-08dbb88e06b6 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: AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8806 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 *. Reviewed-by: Thiago Jung Bauermann Approved-By: Tom Tromey --- 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