From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id N4srBvD5tGA0PAAAWB0awg (envelope-from ) for ; Mon, 31 May 2021 11:00:00 -0400 Received: by simark.ca (Postfix, from userid 112) id 0B8481F163; Mon, 31 May 2021 11:00:00 -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.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.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 1A5F51E940 for ; Mon, 31 May 2021 10:59:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A05ED3848018; Mon, 31 May 2021 14:59:58 +0000 (GMT) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 40CFF3848010 for ; Mon, 31 May 2021 14:59:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 40CFF3848010 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 47A5821918; Mon, 31 May 2021 14:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1622473195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VOR7QLuVfyeghpvdH617DqmhiykGc5s2vub5drlLliI=; b=laggeaOIDX/b79lX3rZc+m8vYyZoZVU7nJWcOH0VEHTNTLCka1WZe8o2KcVAE4lGOgcik3 unQROv2xWLmR6vDfmVin3wkXaQCEsN5fjw0rxSpi2eu0g+Db8wqYuplmvT7BCsAKKn4QUc GpIpb3h6nAmvZVsat6zmUIZkMsclitM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1622473195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VOR7QLuVfyeghpvdH617DqmhiykGc5s2vub5drlLliI=; b=5pK4KX26IJ/KS/U2RQDidguolRONOlufzVXY4KxmOEFjLcQA3J/H/FYSyMEBX+/hwvTY+0 qamzMtgk4jmtRhDA== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 16D45118DD; Mon, 31 May 2021 14:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1622473193; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VOR7QLuVfyeghpvdH617DqmhiykGc5s2vub5drlLliI=; b=jbtmXZZI1HeH3nI3h4Gd3uy8UvluHbkwM3yj3rmiDceS4jVJSac1Cy+8kYKW0g1g7b4yvW d9b1dIxD+dTsFM0KB4fkZduoGzv0lPhCGbX15eqBiVgoebELbG/ykbd3JVnCXwVsldPX3V J4wA96+dzg1YWPgXvakphZaF0BVkTZk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1622473193; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VOR7QLuVfyeghpvdH617DqmhiykGc5s2vub5drlLliI=; b=/xGNNuSbrX9UxzdCyKqk5+Co5BBfywOLo4OE6WKDXsSksLRIe+08LXVrE2CbXRyCaTpXX0 lfhiRkvnnmV/LBAA== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id K02YBOn5tGA/EAAALh3uQQ (envelope-from ); Mon, 31 May 2021 14:59:53 +0000 Subject: Re: [PATCH][gdb/symtab] Ignore cold clones To: Simon Marchi , gdb-patches@sourceware.org References: <20210531141512.GA3181@delia> <5af89971-6072-bfd3-2bc8-c0255770fd70@polymtl.ca> From: Tom de Vries Message-ID: Date: Mon, 31 May 2021 16:59:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <5af89971-6072-bfd3-2bc8-c0255770fd70@polymtl.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Authentication-Results: imap.suse.de; none X-Spamd-Result: default: False [-1.00 / 100.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_ENVRCPT(0.00)[hotmail.de]; SURBL_MULTI_FAIL(0.00)[sourceware.org:server fail]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; FREEMAIL_CC(0.00)[hotmail.de] 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: , Cc: Bernd Edlinger Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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". 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