From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QDNVFB7ytGDSOgAAWB0awg (envelope-from ) for ; Mon, 31 May 2021 10:26:38 -0400 Received: by simark.ca (Postfix, from userid 112) id 5118B1F163; Mon, 31 May 2021 10:26:38 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 86AD91E940 for ; Mon, 31 May 2021 10:26:37 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DD001384BC11; Mon, 31 May 2021 14:26:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD001384BC11 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1622471196; bh=UWeTR5GLPyAgC/sPAntfIPIT3D0XkxhWIDYNpSBLK0A=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=taSI7XsEj+A1KsKC+v0XoVSD09IeHvMEtNVEoWI9YUqcQQv7b+USo5I94wIJU32VX F/bDVCNYvPHfoX/2FkdE8GGt+qRTRivrei7BTOk1U8xUtlUxSS+5fZZw9lfVTVG/2M zyRt351A4YZmxaHgz+yZLsi6cT5vl2kvYhJRZzqw= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 46DE1386545E for ; Mon, 31 May 2021 14:26:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 46DE1386545E Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 14VEQSc9028824 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 May 2021 10:26:33 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 14VEQSc9028824 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id A386D1E940; Mon, 31 May 2021 10:26:28 -0400 (EDT) Subject: Re: [PATCH][gdb/symtab] Ignore cold clones To: Tom de Vries , gdb-patches@sourceware.org References: <20210531141512.GA3181@delia> Message-ID: <5af89971-6072-bfd3-2bc8-c0255770fd70@polymtl.ca> Date: Mon, 31 May 2021 10:26:28 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210531141512.GA3181@delia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 31 May 2021 14:26:28 +0000 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2021-05-31 10:15 a.m., Tom de Vries wrote: > Hi, > > Consider the test-case contained in this patch, compiled for c using gcc-10: > ... > $ gcc-10 -x c src/gdb/testsuite/gdb.cp/cold-clone.cc -O2 -g -Wall -Wextra > ... > > When setting a breakpoint on foo, we get one breakpoint location: > ... > $ gdb -q -batch a.out -ex "b foo" > Breakpoint 1 at 0x400560: file cold-clone.cc, line 28. > ... > > However, when we compile for c++ instead, we get two breakpoint locations: > ... > $ gdb -q -batch a.out -ex "b foo" -ex "info break" > Breakpoint 1 at 0x400430: foo. (2 locations) > Num Type Disp Enb Address What > 1 breakpoint keep y > 1.1 y 0x0000000000400430 in foo() at cold-clone.cc:30 > 1.2 y 0x0000000000400560 in foo() at cold-clone.cc:28 > ... > > The additional breakpoint location at 0x400430 corresponds to the cold clone: > ... > $ nm a.out | grep foo > 0000000000400560 t _ZL3foov > 0000000000400430 t _ZL3foov.cold > ... > which demangled looks like this: > ... > $ nm -C a.out | grep foo > 0000000000400560 t foo() > 0000000000400430 t foo() [clone .cold] > ... > > [ Or, in the case of the cc1 mentioned in PR23710: > ... > $ nm cc1 | grep do_rpo_vn.*cold > 000000000058659d t \ > _ZL9do_rpo_vnP8functionP8edge_defP11bitmap_headbb.cold.138 > $ nm -C cc1 | grep do_rpo_vn.*cold > 000000000058659d t \ > do_rpo_vn(function*, edge_def*, bitmap_head*, bool, bool) [clone .cold.138] > ... ] > > The cold clone is a part of the function that is split off from the rest of > the function because it's considered cold (not frequently executed). So while > the symbol points to code that is part of a function, it doesn't point to a > function entry, so the desirable behaviour for "break foo" is to ignore this > symbol. > > When compiling for c, the symbol "foo.cold" is entered as minimal symbol > with the search name "foo.cold", and the lookup using "foo" fails to find that > symbol. > > But when compiling for c++, the symbol "foo.cold" is entered as minimal symbol > with both the mangled and demangled name, and for the demangled name > "foo() [clone .cold]" we get the search name "foo" (because > cp_search_name_hash stops hashing at '('), and the lookup using "foo" succeeds. > > Fix this by recognizing the cold clone suffix and returning false for such a > minimal symbol in msymbol_is_function. > > Tested on x86_64-linux. > > Any comments? Is this related to https://sourceware.org/pipermail/gdb-patches/2021-May/179371.html ? Simon