From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id tNKgH9AUtWAmPwAAWB0awg (envelope-from ) for ; Mon, 31 May 2021 12:54:40 -0400 Received: by simark.ca (Postfix, from userid 112) id 7366D1F163; Mon, 31 May 2021 12:54:40 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=FORGED_MUA_MOZILLA, FREEMAIL_FROM,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,URIBL_BLOCKED autolearn=no 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 01A3A1E54D for ; Mon, 31 May 2021 12:54:39 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 72717385783A; Mon, 31 May 2021 16:54:39 +0000 (GMT) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2036.outbound.protection.outlook.com [40.92.89.36]) by sourceware.org (Postfix) with ESMTPS id 7335F385783A for ; Mon, 31 May 2021 16:54:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7335F385783A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bernd.edlinger@hotmail.de ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lvYc46osHa4EbrdMCuykmuD7J4yWnaGE6A3bigo5zhGPZqY6+WW6HQi//mDcD3I3oMwYw2VRozoGh9IxAYQj0JVrJ2D3BkVDQd2hn9DUl7wwG2kcDij4Dks2jaDhAGBm4y7MEDLyrHUQ/VTssJ94eAVp6lRw1lX94+mVb4ODGtktHNgDGqo/QGMqx6i17mKc1/m4O7fnVcrEYGS/80YucUF5P9uuU75uWn22mmwORGUQweH6mvolE5e3OFKdVWk4XyzbUUBH8rl+tgFFXKmJNkmj43beqx3yl3b4R3Nw3+TVZu7AOwClXVyFKVoIMmnyz6ssQq9HHv1EXV4tNsZmtQ== 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-SenderADCheck; bh=otGeFoId29QeH8GermwIEFFdX9ZVfcun/yNsVNkYFmo=; b=Y2NHH6tAtPH83jxZXU2d42px13RdJ/gRNpIfp9VZa0Adp5OsY8SkPY11mXoVMH/36FTJfDjgqXYiDMmBbxF19fknz8WZhuiZRehgYazCaLIKN1DJ8cpk7IJn7NKsv/eQB+0IES7NJdr4Bvm/ZOU2tLQ/uRf2U6chfbeGIE1tdJKNUfrn32NGRC5d9ru9TzeLrJcWzmtLzLGMquqCh+vCAhjJLfMI1ZRprP2twYTVD54kmGnTFFVsr1VwFOP57ba40tw0zCdgyi85qNpY8MYEOPMrTQXhFB+OZ4zIswH9kZqCn4ry1WAJLe33NDJvq4f+YnlxR/C0HEFc2utKsWiAIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DB8EUR05FT055.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::45) by DB8EUR05HT242.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc0f::388) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.28; Mon, 31 May 2021 16:54:34 +0000 Received: from AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM (2a01:111:e400:fc0f::44) by DB8EUR05FT055.mail.protection.outlook.com (2a01:111:e400:fc0f::454) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.28 via Frontend Transport; Mon, 31 May 2021 16:54:34 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:109A78B0B8AB83A0317A43C931B3FCDF02FD48E610DBAB4CEF53F7B7A3B34565; UpperCasedChecksum:57EE1F8151B14B3FF736B57F9B17B74FB912B51FFBDAEA0D6CBF4A349D17AF78; SizeAsReceived:8745; Count:47 Received: from AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM ([fe80::ad12:6a2c:b949:f65d]) by AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM ([fe80::ad12:6a2c:b949:f65d%5]) with mapi id 15.20.4173.030; Mon, 31 May 2021 16:54:34 +0000 Subject: Re: [PATCH][gdb/symtab] Ignore cold clones To: Tom de Vries , Simon Marchi , gdb-patches@sourceware.org References: <20210531141512.GA3181@delia> <5af89971-6072-bfd3-2bc8-c0255770fd70@polymtl.ca> From: Bernd Edlinger Message-ID: Date: Mon, 31 May 2021 18:54:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TMN: [SBhCR3cT2ZeIkvI1aFn28VwwBsMi+kjB] X-ClientProxiedBy: PR3P189CA0075.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::20) To AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:364::23) X-Microsoft-Original-Message-ID: <9668d9b4-2677-3e8b-2518-48abba5a39da@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (84.57.61.94) by PR3P189CA0075.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Mon, 31 May 2021 16:54:33 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f76fdf6f-bc9b-4aa8-b848-08d92454c47a X-MS-TrafficTypeDiagnostic: DB8EUR05HT242: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8T1njVBcfxeUdBg5XSnWhFIXbmqswfGn3Wc4NMJyoD9HRFcPGg25msgQV6UcAw0Ukg1a+LQvNO/iDzA2vUuL4GQkARNxnVYIsPra4ZcLpFBXSPlDCGRedhtth+kvFSyJpMIYrWfqJ6gLJQEo6oSNBEecvw3XP5LSouBzOxMUc3hfhHi+KM5OjgWRtq85nCxt2XJDxTUTKfoPjsZMgrlgiFQcm/QKscxmQoYyzPq95zf9lw2IO+7WxMTRdrL/FcidVqgyRRpTWDeohXWrAQo2kbbr+A10hXZ7i/hjl/xWsXl6EJ+moyAJFSZe4H3KkCgxo3EXDRPSGkMGzU+J7PJZWRnpR7U2KsViCttPseyqZ8C2SBDZlg+vE6Oo8w1HLNyg1diCvZpUojhzdd/r12ItKHNkp2CulloK07Ep0tgou9KaOSZF20vbfbXmxcrWmW/gSsxqlO+q3MFLP6XxOUm9lw== X-MS-Exchange-AntiSpam-MessageData: RrcT4r8o63PbkQrk2G1aVO+58phcIylPkvpH5kZGdwYzsf3cL5wWF8t6g9zgPw++WxMdOyh693yE4PrmCLDUlj/Eps3dWqZPaEUqKdqEimRzvjTGwPgH05RA041pLgH2Eh597znm8cmd8KN8yBIbyQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f76fdf6f-bc9b-4aa8-b848-08d92454c47a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 16:54:34.5151 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DB8EUR05FT055.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8EUR05HT242 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 5/31/21 4:59 PM, Tom de Vries wrote: > On 5/31/21 4:26 PM, Simon Marchi wrote: >> 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 >> > > Yes, it looks like both attempt to fix the same PR, thanks for the pointer. > > At first glance, that one doesn't handle symbol > "_ZL9do_rpo_vnP8functionP8edge_defP11bitmap_headbb.cold.138". > Is this symbol from gcc? I never saw this kind of mangled symbol. TBH, I was not sure if I should handle foo$cold or __foo_cold. In theory there may be targets where the assembler does not like ".", then gcc would emit foo$cold If neither "." nor "$" is acceptable then gcc would emit __foo_cold but I was not sure if such targets do really exist. Bernd. > Another difference seems to be how the cold clone status is determined: > - this patch uses the demangled name, and treats finding the .cold > string (used in a specific way) as proof > - Bernd's patch uses the mangled name, and treats finding the .cold > string as a hint, and proceeds to find the corresponding function > entry symbol to proof it > > [ FWIW, that patch mentions it fixes 77f2120b200 ("Don't drop static > function bp locations w/o debug info"), but the PR did exist before that > commit, that commit just made it more frequent. ] > > Thanks, > - Tom >