From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id A62393858D3C for ; Wed, 1 Jun 2022 17:07:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A62393858D3C Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 251Go1WU008004; Wed, 1 Jun 2022 17:07:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gebyvrag7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Jun 2022 17:07:53 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 251GtgTW030597; Wed, 1 Jun 2022 17:07:52 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gebyvrafe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Jun 2022 17:07:52 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 251H59dk031818; Wed, 1 Jun 2022 17:07:50 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3gbc7h5x0c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Jun 2022 17:07:50 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 251H7kFB19136820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Jun 2022 17:07:46 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB30E4C040; Wed, 1 Jun 2022 17:07:45 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EB4C4C044; Wed, 1 Jun 2022 17:07:45 +0000 (GMT) Received: from heavy.ibmuc.com (unknown [9.171.42.87]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 1 Jun 2022 17:07:45 +0000 (GMT) From: Ilya Leoshkevich To: Tom Tromey , Andrew Burgess Cc: Ulrich Weigand , Andreas Arnez , Pedro Alves , gdb-patches@sourceware.org, Ilya Leoshkevich Subject: [PATCH v4] gdb: Do not add empty sections to the section map Date: Wed, 1 Jun 2022 19:07:44 +0200 Message-Id: <20220601170744.2884144-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.35.3 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 9kbHEUp4J3QRH2pf0YO-HrX3KhOqqto7 X-Proofpoint-GUID: xAhTBlNwWASmHVv5FC3TH-Lr6bzwpzfW Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-01_05,2022-06-01_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 clxscore=1015 spamscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 phishscore=0 bulkscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206010075 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Wed, 01 Jun 2022 17:07:57 -0000 From: Ulrich Weigand build_objfile_section_table () creates four synthetic sections per objfile, which are collected by update_section_map () and passed to std::sort (). When there are a lot of objfiles, for example, when debugging JITs, the presence of these sections slows down the sorting significantly. The output of update_section_map () is used by find_pc_section (), which can never return any of these sections: their size is 0, so they cannot be accepted by bsearch_cmp (). Filter them (and all the other empty sections) out in insert_section_p (), which is used only by update_section_map (). --- v3: https://sourceware.org/pipermail/gdb-patches/2022-June/189692.html v3 -> v4: Use whether a section is empty or not as the filtering criteria (Pedro). v2: https://sourceware.org/pipermail/gdb-patches/2022-May/189154.html v2 -> v3: Fix comments and commit message (Andrew). v1: https://sourceware.org/pipermail/binutils/2022-May/120863.html v1 -> v2: Fix code style, post to the correct mailing list (Andrew). gdb/objfiles.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 60d8aa5cb78..4fc859f185a 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -986,7 +986,7 @@ preferred_obj_section (struct obj_section *a, struct obj_section *b) } /* Return 1 if SECTION should be inserted into the section map. - We want to insert only non-overlay and non-TLS section. */ + We want to insert only non-overlay non-TLS non-empty sections. */ static int insert_section_p (const struct bfd *abfd, @@ -1003,6 +1003,12 @@ insert_section_p (const struct bfd *abfd, if ((bfd_section_flags (section) & SEC_THREAD_LOCAL) != 0) /* This is a TLS section. */ return 0; + if (bfd_section_size (section) == 0) + { + /* This is an empty section. It has no PCs for find_pc_section (), so + there is no reason to insert it into the section map. */ + return 0; + } return 1; } -- 2.35.3