From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2064.outbound.protection.outlook.com [40.107.92.64]) by sourceware.org (Postfix) with ESMTPS id 56F7F385735A for ; Thu, 19 Oct 2023 11:09:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 56F7F385735A Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 56F7F385735A Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.92.64 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697713746; cv=pass; b=hqe0u0dSDmD0gNI5vTp4eB0o9xyYJ4paZloxHN8xmzA0W94b0JdUdKJP/zIdNer5a6wjyvjH5qphorjuee4euwJA881AM+LN+TbP5CZSpVKsF3ogKVUG5XzgHsOUMvwdjKPsiHq/PpZLS4y0neW+7NvjY54XVxaIYfT7oIN+JGg= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697713746; c=relaxed/simple; bh=ypNv6o0hJerqTiLc4b0ApTg+YvZ+MfYZ/NQTM+BRmBQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=IRmUEx0qsmDZa6UKsgTvxRaA9S/8PlkHpsDNbcxDE+iCGlQIN+b/JzhQp2Gaas0uyvxaGBTJXcq+SfnQVlCtCRHtWfFoI3D54v5i68hvkf4HLVMLxYVL9ysXzuEmyscdQjcXyexd7gYiD2G9QjdHVB0E33doqDrIfWkJme8b+NQ= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kU/20ILeuneLITFz2FboEklnXIWpPnqRbUR91+C2P/AddnEfKo5UWl3k+TPMM1mJSwfw75tk02SmHm/Qb5+ZCSmZGU6PqNLqlau7BUm1WFrExNJcpKaiIqxc/AZDMpRVMYEoCHDk1SaVubWVznx9GtuMlMBEuRqcwFHoIDvSM5C5UCDjSoaaDPK9Nrn+MaU7EQdcSzOv0w2/au4qubZQKRlE2wp6hBGpxhxHSjdwEicg5ypYk+Zvv2e3E8tjLMOAcd8DvJZ9A7AeWqy0rHmByAaCk0hyl4XMVg72FLUUfRmOXndX4VqqDP1+p708/V6Cstn5uUfy3vJ1HaWFzpnmzQ== 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=0wsBGjenKtmdG1TIOylEpFGXcqUD/fN/kAHbCYbFAnc=; b=Um/L52ijC8oefl7O9GSK6oVjQ46RHIhJInL5dkfNGKe5Y43YfEEdt2oFCeSuzafheYJs7GxG9VYCgJi18jWMYUGG4JuYMEmBddXeIMrK1c/nYjt5QKRr6oDVN2Ax894MpkWDHSr6dSCjGmgZZvonhAMtL75aoDETYDV4n0/au/nfgWi77gdm5Z2RKfFQosaezpW4mwvir0Q1A7qYh+zGHx8CPexYq4yBJMEP4mm1INK09DOKWhQAtpIUFjZvF7Fu4/4Cei6KrSDsPoxguOz+LX775DD1M2bzYDkZBhb2raZOPjrskouaEpf4VW/WRJP37nNPDIKewmUevxUAHB9TxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=efficios.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0wsBGjenKtmdG1TIOylEpFGXcqUD/fN/kAHbCYbFAnc=; b=A5YI3pjeA0H8b3YBCQuYkCEpetYSVj67UPyIEwnwIpipEDwvpBA/oHQeDQqh70ev9aOrKI22QgMW9M3j18qI+VIHllrP5EHSzo3g3iiNjQcVEUpV21/k8+GrUpOK/wDeWZ80N5gCfbY1wCJWYReGy1YQtp/mpukx5Lr3wtJfSXE= Received: from DS7PR05CA0051.namprd05.prod.outlook.com (2603:10b6:8:2f::12) by CH3PR12MB7547.namprd12.prod.outlook.com (2603:10b6:610:147::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23; Thu, 19 Oct 2023 11:09:01 +0000 Received: from DS2PEPF00003442.namprd04.prod.outlook.com (2603:10b6:8:2f:cafe::23) by DS7PR05CA0051.outlook.office365.com (2603:10b6:8:2f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.8 via Frontend Transport; Thu, 19 Oct 2023 11:09:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003442.mail.protection.outlook.com (10.167.17.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.21 via Frontend Transport; Thu, 19 Oct 2023 11:09:01 +0000 Received: from khazad-dum (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 19 Oct 2023 06:09:00 -0500 Date: Thu, 19 Oct 2023 12:08:53 +0100 From: Lancelot SIX To: Simon Marchi CC: Subject: Re: [PATCH 12/24] gdb: make solib-svr4 not use so_list internally Message-ID: <20231019110853.476ixbcgbml6xwgy@khazad-dum> References: <20231010204213.111285-1-simon.marchi@efficios.com> <20231010204213.111285-13-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20231010204213.111285-13-simon.marchi@efficios.com> X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003442:EE_|CH3PR12MB7547:EE_ X-MS-Office365-Filtering-Correlation-Id: eb615f85-9abd-4baf-9cbc-08dbd093ccce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7wzLdOiVs/1xsFZOzwSFaHISa+9IVuf2MZIOekCtWm5Of34gJWl9FwFI15y/RftCsXGAehBxNXg77PkS9AZjGB3AMl3xEz6AUT0kwlkx5j3fPpCh6JdOMwZRm5wGdpZn9yXrBI4yjLRyyVeaTyR0OJmw3cB4DgJFPApdLeRIRGnwhsKsUHQL+zJApnRb0vFzct6nnn0dFrlD1CkztNvcxeO4PKonjHWf5ZVXIxqKwshsxqJaWguiBGdUsoylB882frDXFuV4lPDUDv0YJyiyDoemECDXGnoi4Zia4L/d2h/NP09ZPRAfIJy8ylFhnMHJlJXVTzis7/5Os+YPGnLUR1m1TC5pDFHUl3ZhIYnsFR0NIJD/trd6lucA+KGIeFemcKVWjZvlpjSkiK7EheC/ewvoRkNbevvIkjAYr7QS1rWjuKjVsC6i4bS0XsmJk/i+CDb0O8kvcRqZDbhpTtbRyEi01MvxOepwIOzjJOhBRaqpTwIX0CW+hZqYGqKspitYJTam6yZKJ+DIyXN+U8eaSQlO4rxZu12uwq9TLTzd/8+pqPvr3D20I0JyhmO2PlGEWlrEpZ4HXAdvv8i5JDgOiComwpDUXb+KXq4rlYYk8zXIDYW+pqp9A+ajAMYT8dIwc8caGLP7o3H9bokkyXQaEn7F4ztyPdBrG54hRhXWS+5KthCoSIDCiRKRB48aAOAn5mJQUt5PYZrq2zfpWsAjFyhfvVblsFoP3rBM1jlfs2MINS1YJPHJCOh4jMMU+vkRQdvwSVI27NRMpindUxvexw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(39860400002)(376002)(346002)(136003)(230922051799003)(451199024)(82310400011)(186009)(1800799009)(64100799003)(40470700004)(46966006)(36840700001)(33716001)(84970400001)(40460700003)(55016003)(81166007)(36860700001)(30864003)(2906002)(356005)(16526019)(8936002)(4326008)(86362001)(8676002)(83380400001)(426003)(82740400003)(1076003)(336012)(26005)(47076005)(5660300002)(40480700001)(316002)(478600001)(6916009)(9686003)(41300700001)(6666004)(70206006)(70586007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 11:09:01.6982 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb615f85-9abd-4baf-9cbc-08dbd093ccce X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003442.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7547 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP 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: Hi Simon, > @@ -1050,48 +1034,25 @@ library_list_start_library (struct gdb_xml_parser *parser, > ULONGEST *l_ldp > = (ULONGEST *) xml_find_attribute (attributes, "l_ld")->value.get (); > > - so_list *new_elem = new so_list; > - lm_info_svr4 *li = new lm_info_svr4; > - new_elem->lm_info = li; > + lm_info_svr4_up li = gdb::make_unique (); > li->lm_addr = *lmp; > li->l_addr_inferior = *l_addrp; > li->l_ld = *l_ldp; Just a thought for future changes to continue the c++-ification, adding a proper ctor (or ctors) to lm_info_svr4 would probably make things cleaner. Otherwise, things looks reasonable to me. Best, Lancelot. > > - strncpy (new_elem->so_name, name, sizeof (new_elem->so_name) - 1); > - new_elem->so_name[sizeof (new_elem->so_name) - 1] = 0; > - strcpy (new_elem->so_original_name, new_elem->so_name); > + std::vector *solist; > > /* Older versions did not supply lmid. Put the element into the flat > list of the special namespace zero in that case. */ > gdb_xml_value *at_lmid = xml_find_attribute (attributes, "lmid"); > if (at_lmid == nullptr) > - { > - *list->tailp = new_elem; > - list->tailp = &new_elem->next; > - } > + solist = list->cur_list; > else > { > ULONGEST lmid = *(ULONGEST *) at_lmid->value.get (); > - > - /* Ensure that the element is actually initialized. */ > - if (list->solib_lists.find (lmid) == list->solib_lists.end ()) > - list->solib_lists[lmid] = nullptr; > - > - so_list **psolist = &list->solib_lists[lmid]; > - so_list **pnext = psolist; > - > - /* Walk to the end of the list if we have one. */ > - so_list *solist = *psolist; > - if (solist != nullptr) > - { > - for (; solist->next != nullptr; solist = solist->next) > - /* Nothing. */; > - > - pnext = &solist->next; > - } > - > - *pnext = new_elem; > + solist = &list->solib_lists[lmid]; > } > + > + solist->emplace_back (name, std::move (li)); > } > > /* Handle the start of a element. */ > @@ -1117,9 +1078,7 @@ svr4_library_list_start_list (struct gdb_xml_parser *parser, > > /* Older gdbserver do not support namespaces. We use the special > namespace zero for a linear list of libraries. */ > - so_list **solist = &list->solib_lists[0]; > - *solist = nullptr; > - list->tailp = solist; > + list->cur_list = &list->solib_lists[0]; > } > > /* The allowed elements and attributes for an XML library list. > @@ -1169,13 +1128,9 @@ static int > svr4_parse_libraries (const char *document, struct svr4_library_list *list) > { > auto cleanup = make_scope_exit ([list] () > - { > - for (const std::pair tuple > - : list->solib_lists) > - svr4_free_library_list (tuple.second); > - }); > + { list->solib_lists.clear (); }); > > - list->tailp = nullptr; > + list->cur_list = nullptr; > list->main_lm = 0; > list->solib_lists.clear (); > if (gdb_xml_parse_quick (_("target library list"), "library-list-svr4.dtd", > @@ -1253,25 +1208,21 @@ svr4_default_sos (svr4_info *info) > > /* Read the whole inferior libraries chain starting at address LM. > Expect the first entry in the chain's previous entry to be PREV_LM. > - Add the entries to the tail referenced by LINK_PTR_PTR. Ignore the > - first entry if IGNORE_FIRST and set global MAIN_LM_ADDR according > - to it. Returns nonzero upon success. If zero is returned the > - entries stored to LINK_PTR_PTR are still valid although they may > + Add the entries to SOS. Ignore the first entry if IGNORE_FIRST and set > + global MAIN_LM_ADDR according to it. Returns nonzero upon success. If zero > + is returned the entries stored to LINK_PTR_PTR are still valid although they may > represent only part of the inferior library list. */ > > static int > svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, > - struct so_list ***link_ptr_ptr, int ignore_first) > + std::vector &sos, int ignore_first) > { > CORE_ADDR first_l_name = 0; > CORE_ADDR next_lm; > > for (; lm != 0; prev_lm = lm, lm = next_lm) > { > - so_list_up newobj (new so_list); > - > - lm_info_svr4 *li = lm_info_read (lm).release (); > - newobj->lm_info = li; > + lm_info_svr4_up li = lm_info_read (lm); > if (li == NULL) > return 0; > > @@ -1298,9 +1249,9 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, > } > > /* Extract this shared object's name. */ > - gdb::unique_xmalloc_ptr buffer > + gdb::unique_xmalloc_ptr name > = target_read_string (li->l_name, SO_NAME_MAX_PATH_SIZE - 1); > - if (buffer == nullptr) > + if (name == nullptr) > { > /* If this entry's l_name address matches that of the > inferior executable, then this is not a normal shared > @@ -1311,19 +1262,12 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, > continue; > } > > - strncpy (newobj->so_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1); > - newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; > - strcpy (newobj->so_original_name, newobj->so_name); > - > /* If this entry has no name, or its name matches the name > for the main executable, don't include it in the list. */ > - if (! newobj->so_name[0] || match_main (newobj->so_name)) > + if (*name == '\0' || match_main (name.get ())) > continue; > > - newobj->next = 0; > - /* Don't free it now. */ > - **link_ptr_ptr = newobj.release (); > - *link_ptr_ptr = &(**link_ptr_ptr)->next; > + sos.emplace_back (name.get (), std::move (li)); > } > > return 1; > @@ -1342,7 +1286,7 @@ svr4_current_sos_direct (struct svr4_info *info) > struct svr4_library_list library_list; > > /* Remove any old libraries. We're going to read them back in again. */ > - free_solib_lists (info); > + info->solib_lists.clear (); > > /* Fall back to manual examination of the target if the packet is not > supported or gdbserver failed to find DT_DEBUG. gdb.server/solib-list.exp > @@ -1362,10 +1306,10 @@ svr4_current_sos_direct (struct svr4_info *info) > /* Remove an empty special zero namespace so we know that when there > is one, it is actually used, and we have a flat list without > namespace information. */ > - if ((library_list.solib_lists.find (0) > - != library_list.solib_lists.end ()) > - && (library_list.solib_lists[0] == nullptr)) > - library_list.solib_lists.erase (0); > + auto it_0 = library_list.solib_lists.find (0); > + if (it_0 != library_list.solib_lists.end () > + && it_0->second.empty ()) > + library_list.solib_lists.erase (it_0); > > /* Replace the (empty) solib_lists in INFO with the one generated > from the target. We don't want to copy it on assignment and then > @@ -1391,9 +1335,7 @@ svr4_current_sos_direct (struct svr4_info *info) > ignore_first = true; > > auto cleanup = make_scope_exit ([info] () > - { > - free_solib_lists (info); > - }); > + { info->solib_lists.clear (); }); > > /* Collect the sos in each namespace. */ > CORE_ADDR debug_base = info->debug_base; > @@ -1403,12 +1345,8 @@ svr4_current_sos_direct (struct svr4_info *info) > /* Walk the inferior's link map list, and build our so_list list. */ > lm = solib_svr4_r_map (debug_base); > if (lm != 0) > - { > - so_list **sos = &info->solib_lists[debug_base]; > - *sos = nullptr; > - > - svr4_read_so_list (info, lm, 0, &sos, ignore_first); > - } > + svr4_read_so_list (info, lm, 0, info->solib_lists[debug_base], > + ignore_first); > } > > /* On Solaris, the dynamic linker is not in the normal list of > @@ -1425,11 +1363,8 @@ svr4_current_sos_direct (struct svr4_info *info) > { > /* Add the dynamic linker's namespace unless we already did. */ > if (info->solib_lists.find (debug_base) == info->solib_lists.end ()) > - { > - so_list **sos = &info->solib_lists[debug_base]; > - *sos = nullptr; > - svr4_read_so_list (info, debug_base, 0, &sos, 0); > - } > + svr4_read_so_list (info, debug_base, 0, info->solib_lists[debug_base], > + 0); > } > > cleanup.release (); > @@ -1440,19 +1375,18 @@ svr4_current_sos_direct (struct svr4_info *info) > static so_list * > svr4_collect_probes_sos (svr4_info *info) > { > - so_list *sos = nullptr; > - so_list **pnext = &sos; > + so_list *res = nullptr; > + so_list **pnext = &res; > > - for (const std::pair tuple > - : info->solib_lists) > + for (const auto &tuple : info->solib_lists) > { > - so_list *solist = tuple.second; > + const std::vector &sos = tuple.second; > > /* Allow the linker to report empty namespaces. */ > - if (solist == nullptr) > + if (sos.empty ()) > continue; > > - *pnext = svr4_copy_library_list (solist); > + *pnext = so_list_from_svr4_sos (sos); > > /* Update PNEXT to point to the next member of the last element. */ > gdb_assert (*pnext != nullptr); > @@ -1466,7 +1400,7 @@ svr4_collect_probes_sos (svr4_info *info) > } > } > > - return sos; > + return res; > } > > /* Implement the main part of the "current_sos" target_so_ops > @@ -1853,16 +1787,10 @@ solist_update_incremental (svr4_info *info, CORE_ADDR debug_base, > if (info->solib_lists.find (0) != info->solib_lists.end ()) > return 0; > > - /* Ensure that the element is actually initialized. */ > - if (info->solib_lists.find (debug_base) == info->solib_lists.end ()) > - info->solib_lists[debug_base] = nullptr; > - > - so_list **psolist = &info->solib_lists[debug_base]; > - so_list **pnext = nullptr; > - so_list *solist = *psolist; > + std::vector &solist = info->solib_lists[debug_base]; > CORE_ADDR prev_lm; > > - if (solist == nullptr) > + if (solist.empty ()) > { > /* svr4_current_sos_direct contains logic to handle a number of > special cases relating to the first elements of the list in > @@ -1872,18 +1800,9 @@ solist_update_incremental (svr4_info *info, CORE_ADDR debug_base, > return 0; > > prev_lm = 0; > - pnext = psolist; > } > else > - { > - /* Walk to the end of the list. */ > - for (; solist->next != nullptr; solist = solist->next) > - /* Nothing. */; > - > - auto *li = gdb::checked_static_cast (solist->lm_info); > - prev_lm = li->lm_addr; > - pnext = &solist->next; > - } > + prev_lm = solist.back ().lm_info->lm_addr; > > /* Read the new objects. */ > if (info->using_xfer) > @@ -1905,24 +1824,23 @@ solist_update_incremental (svr4_info *info, CORE_ADDR debug_base, > > We expect gdbserver to provide updates for the namespace that > contains LM, which would be this namespace... */ > - so_list *sos = nullptr; > - if (library_list.solib_lists.find (debug_base) > - != library_list.solib_lists.end ()) > - std::swap (sos, library_list.solib_lists[debug_base]); > - if (sos == nullptr) > + std::vector sos; > + auto it_debug_base = library_list.solib_lists.find (debug_base); > + if (it_debug_base != library_list.solib_lists.end ()) > + std::swap (sos, it_debug_base->second); > + else > { > /* ...or for the special zero namespace for earlier versions... */ > - if (library_list.solib_lists.find (0) > - != library_list.solib_lists.end ()) > - std::swap (sos, library_list.solib_lists[0]); > + auto it_0 = library_list.solib_lists.find (0); > + if (it_0 != library_list.solib_lists.end ()) > + std::swap (sos, it_0->second); > } > > /* ...but nothing else. */ > - for (const std::pair tuple > - : library_list.solib_lists) > - gdb_assert (tuple.second == nullptr); > + for (const auto &tuple : library_list.solib_lists) > + gdb_assert (tuple.second.empty ()); > > - *pnext = sos; > + std::move (sos.begin (), sos.end (), std::back_inserter (solist)); > } > else > { > @@ -1930,7 +1848,7 @@ solist_update_incremental (svr4_info *info, CORE_ADDR debug_base, > above check and deferral to solist_update_full ensures > that this call to svr4_read_so_list will never see the > first element. */ > - if (!svr4_read_so_list (info, lm, prev_lm, &pnext, 0)) > + if (!svr4_read_so_list (info, lm, prev_lm, solist, 0)) > return 0; > } > > @@ -1948,7 +1866,7 @@ disable_probes_interface (svr4_info *info) > "Reverting to original interface.")); > > free_probes_table (info); > - free_solib_lists (info); > + info->solib_lists.clear (); > } > > /* Update the solib list as appropriate when using the > @@ -3145,7 +3063,7 @@ svr4_solib_create_inferior_hook (int from_tty) > > /* Clear the probes-based interface's state. */ > free_probes_table (info); > - free_solib_lists (info); > + info->solib_lists.clear (); > > /* Relocate the main executable if necessary. */ > svr4_relocate_main_executable (); > @@ -3373,14 +3291,17 @@ find_debug_base_for_solib (so_list *solib) > > svr4_info *info = get_svr4_info (current_program_space); > gdb_assert (info != nullptr); > - for (const std::pair tuple > - : info->solib_lists) > + > + const lm_info_svr4 *lm_info = (const lm_info_svr4 *) solib->lm_info; > + > + for (const auto &tuple : info->solib_lists) > { > CORE_ADDR debug_base = tuple.first; > - so_list *solist = tuple.second; > + const std::vector &sos = tuple.second; > > - for (; solist != nullptr; solist = solist->next) > - if (svr4_same (*solib, *solist)) > + for (const svr4_so &so : sos) > + if (svr4_same (solib->so_original_name, so.name.c_str (), > + *lm_info, *so.lm_info)) > return debug_base; > } > > diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h > index 1aff3b59da8c..7cb6cabb109f 100644 > --- a/gdb/solib-svr4.h > +++ b/gdb/solib-svr4.h > @@ -48,6 +48,8 @@ struct lm_info_svr4 final : public lm_info > CORE_ADDR l_ld = 0, l_next = 0, l_prev = 0, l_name = 0; > }; > > +using lm_info_svr4_up = std::unique_ptr; > + > /* Critical offsets and sizes which describe struct r_debug and > struct link_map on SVR4-like targets. All offsets and sizes are > in bytes unless otherwise specified. */ > > -- > 2.42.0 >