From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id BYnLCVS3QGd0GTsAWB0awg (envelope-from ) for ; Fri, 22 Nov 2024 11:54:44 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dCM5P+To; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E7B9D1E25F; Fri, 22 Nov 2024 11:54:43 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D56281E1CC for ; Fri, 22 Nov 2024 11:54:42 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 738AF385694F for ; Fri, 22 Nov 2024 16:54:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 738AF385694F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dCM5P+To Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 6847B385AC08 for ; Fri, 22 Nov 2024 16:53:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6847B385AC08 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6847B385AC08 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732294429; cv=none; b=K8RVy4enCdq/kA33sDa0v3h0f69Xx1QhSu+Nawde8vs201sBzrTFApttsnPWQAL+ExcaTkugj+AkNAaT5JftzpJbIaddZjKPoUgEGfoz88VR7wq/qUwm4lEvrSF3MNHTQb8ASUfHQVkUjx92/DHC7gQhqln/W7kJHXoxiJ/Ycu4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732294429; c=relaxed/simple; bh=5OYqvh8mP7VhpUz/fqdTfnm2AnT2au/nbAAv9o/VXtw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=o6FPatuXv6xS4mocmDQxZ6WoktPJrID7f5IoIHdEHEEDvIpECIqfy3P4xMoB1bE52pI5jCVO91bPI7M57LwLEjfwCwvNnMSWOXizfC8ysli59acCRqgOBz/JGL/jrthtb/4aIip29mq2fejL68fSFtQmciNv07yt8g/+MeJJ7ik= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6847B385AC08 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732294429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=w7gWFPFku3QLT8XlXtgoiQQkUicIsKGEIVInaWJdYww=; b=dCM5P+Tod/pZOKjJn7aClS0l2+riHuYtjWxS4m4yHv5l0sys9zkDCIiejdruXJN7u6hk58 9h6mP0MDRw2HY///IZimxMS0giSXjXHjO0JSaQD4bkMGARB1/+mSvra9smDhLghjPIDVMf k+gbpYXyRVf77pwNd/wOGWjTdKsrq/w= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-LE3bJlDgOaezpPUYZMTDZQ-1; Fri, 22 Nov 2024 11:53:47 -0500 X-MC-Unique: LE3bJlDgOaezpPUYZMTDZQ-1 X-Mimecast-MFC-AGG-ID: LE3bJlDgOaezpPUYZMTDZQ Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3825a721afaso1342391f8f.0 for ; Fri, 22 Nov 2024 08:53:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732294426; x=1732899226; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w7gWFPFku3QLT8XlXtgoiQQkUicIsKGEIVInaWJdYww=; b=CtPOEegLdpmB0j2hi7q7bSMgmys7vySp4FCD85BQoqeSpPjsXCrE8R8VCwdNKbV+29 XMzRW0ygWto4692Wp4MEk97LpjOcIlZvNsrOSRxe87ONZGzgb7Gio5SyNVORz+wpcx5K KH9ZLFedwA9YTl6eQqkiWGl7LtQzX9QNot0BizIFHrQTNBUhpIdYCYPp3xgjiiz2/NAP LeuDyJAWV2GWPZeQv3cptr9VI/F1dC5Z9pn9O/7lFRQ7+7onBU5/yjiO7PhGfoNdLYie CMTkw+wvLgQBU353v958NmDPWgxTPNEAOo/QZX7LVZOYsUGTZxUodNtSOmyneJxXXYEi TM4Q== X-Forwarded-Encrypted: i=1; AJvYcCUC8kwLK8auljU6AZrGG1FgI8p7lpIzwPstqpF8wYs2UIdcpP6RMW/A8nX0AutXaKhfLO9sY++U1KTNmg==@sourceware.org X-Gm-Message-State: AOJu0YxmjDOqt0flTIQyV0WSag0y2O2suC2kIx17ozkLOcUpnyee5e+R +kxyBpYViGMsIzRa8RuShsuMoWmgFpDyqnG4vSfwzu7KWznEbrcTUpeIg+19OTeyMSdePBlgzmb WIfGzE4qcX9DUHL3Kb6w6JornpnzJpY1oTuJG+9UKXqvDUw1w7E07t1bvXKR4r75Xi2w= X-Gm-Gg: ASbGncsKCkZxq46bNy1ViyS6VPSJdtU8mA7f13SkQg9KIh6pH1Xa+hqHqY8Kh+oaehf Cyzc8YK94bGD3yH+6lN+rWrDerlUjk8LfY5woWfBmTKAYh2Yp4ZfAcBacy0K9HoLUQQQ1WNWDmu tgLuATxbvF9PHwO8FupAELCFmhf6P4JcIY75K9hFc1bueIg0r+PAdHLAo7DOMhS3pxssVV++DAK /3DSaMAYwgY5+KvgX4mMFiDwda7FBW37Tdokt42MMT+ivz+p9nvN4UXCqUx1mp6tjm1lpREhbsC HA== X-Received: by 2002:a5d:59ae:0:b0:382:4a0d:5ce5 with SMTP id ffacd0b85a97d-38260b4fbc9mr2431500f8f.12.1732294426305; Fri, 22 Nov 2024 08:53:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIKiFwE7UoaF+RFbLKpVgSIPlM7CnvjgE0VChY++qbVoo6E0PYHHBwPkNSD6bHfCY+LSQPbA== X-Received: by 2002:a5d:59ae:0:b0:382:4a0d:5ce5 with SMTP id ffacd0b85a97d-38260b4fbc9mr2431486f8f.12.1732294425929; Fri, 22 Nov 2024 08:53:45 -0800 (PST) Received: from localhost (197.209.200.146.dyn.plus.net. [146.200.209.197]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fbed6b5sm2924294f8f.89.2024.11.22.08.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 08:53:45 -0800 (PST) From: Andrew Burgess To: Bernd Edlinger , gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: handle DW_AT_entry_pc pointing at an empty sub-range In-Reply-To: References: <34cfe440ffd0e53843bfaf92494d29a6951fa9fd.1732114887.git.aburgess@redhat.com> Date: Fri, 22 Nov 2024 16:53:44 +0000 Message-ID: <87y11bw6p3.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3r8a0Rlarpk2BPlo4zALoSt_eoQ933I2dIDyTgP3dRQ_1732294427 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Bernd Edlinger writes: > Hmm, sorry, but I think this goes in the wrong direction. > > On 11/20/24 16:01, Andrew Burgess wrote: >> The test gdb.cp/step-and-next-inline.exp creates a test binary called >> step-and-next-inline-no-header. This test includes a function >> `tree_check` which is inlined 3 times. >> >> When testing with some older versions of gcc (I've tried 8.4.0, 9.3.1) >> we see the following DWARF representing one of the inline instances of >> tree_check: >> >> <2><8d9>: Abbrev Number: 38 (DW_TAG_inlined_subroutine) >> <8da> DW_AT_abstract_origin: <0x9ee> >> <8de> DW_AT_entry_pc : 0x401165 >> <8e6> DW_AT_GNU_entry_view: 0 >> <8e7> DW_AT_ranges : 0x30 >> <8eb> DW_AT_call_file : 1 >> <8ec> DW_AT_call_line : 52 >> <8ed> DW_AT_call_column : 10 >> <8ee> DW_AT_sibling : <0x92d> >> >> ... >> >> <1><9ee>: Abbrev Number: 46 (DW_TAG_subprogram) >> <9ef> DW_AT_external : 1 >> <9ef> DW_AT_name : (indirect string, offset: 0xe8): tree_check >> <9f3> DW_AT_decl_file : 1 >> <9f4> DW_AT_decl_line : 38 >> <9f5> DW_AT_decl_column : 1 >> <9f6> DW_AT_linkage_name: (indirect string, offset: 0x2f2): _Z10tree_checkP4treei >> <9fa> DW_AT_type : <0x9e8> >> <9fe> DW_AT_inline : 3 (declared as inline and inlined) >> <9ff> DW_AT_sibling : <0xa22> >> >> ... >> >> Contents of the .debug_ranges section: >> >> Offset Begin End >> ... >> 00000030 0000000000401165 0000000000401165 (start == end) >> 00000030 0000000000401169 0000000000401173 >> 00000030 0000000000401040 0000000000401045 >> 00000030 >> ... >> >> Notice that one of the sub-ranges of tree-check is empty, this is the >> line marked 'start == end'. As the end address is the first address >> after the range, this range cover absolutely no code. >> >> But notice too that the DW_AT_entry_pc for the inline instance points >> at this empty range. >> >> Further, notice that despite the ordering of the sub-ranges, the empty >> range is actually in the middle of the region defined by the lowest >> address to the highest address. The ordering is not a problem, the >> DWARF spec doesn't require that ranges be in any particular order. >> >> However, this empty range is causing issues with GDB newly acquire >> DW_AT_entry_pc support. >> >> GDB already rejects, and has done for a long time, empty sub-ranges, >> after all, the DWARF spec is clear that such a range covers no code. >> >> The recent DW_AT_entry_pc patch also had GDB reject an entry-pc which >> was outside of the low/high bounds of a block. >> >> But in this case, the entry-pc value is within the bounds of a block, >> it's just not within any useful sub-range. As a consequence, GDB is >> storing the entry-pc value, and making use of it, but when GDB stops, >> and tries to work out which block the inferior is in, it fails to spot >> that the inferior is within tree_check, and instead reports the >> function into which tree_check was inlined. >> >> I've tested with newer versions of gcc (12.2.0 and 14.2.0) and with >> these versions gcc is still generating the empty sub-range, but now >> this empty sub-range is no longer the entry point. Here's the >> corresponding ranges table from gcc 14.2.0: >> > > Yeah, maybe not in this test case, but that is not true in general, > a quick check with gcc-15 shows that there still a number of such > empty range table entries in the gdb executable itself. > > Note that ignoring these entry_pc values is completely wrong, > and my patch series handles exactly these empty subranges, by not > ignoring them in the dwarf reader, and the debug experience is > completely normal when this happens. > > Furthermore, I think that having a break point at these PC values has > some benefit, because it is the earliest point in time, when all > the input parameter values of the inline function are available, > and can be inspected by gdb. I hear and understand your frustration. I'm absolutely not ignoring the work you've done. But I see this as a journey of small steps to get where you want to be. I agree with you 100% that dealing better with the empty sub-ranges is the right way to go, and indeed, I have just finished pulling the empty sub-range work from your series, and I plan to post those patches hopefully over the weekend, I'm just running final tests now. But, this patch does more than just deal with the case of entry-pc pointing at the empty sub-range. I believe that having a sanity check that the entry-pc is within any sub-range is the right thing for GDB to do, regardless of what we ultimately end up doing with empty ranges. I'm hoping I can convince you that fixing this first is not going to prevent us merging your empty sub-range handling code next. > I think now it is time to consider merging the rest of my > patch. My top priority between now and year end is to merge either your patches, or equivalent functionality, into GDB. But, as you can tell from what I've posted, I think your series covers a lot of fixes which should be broken into separate commits. I think the work you have done is absolutely amazing, and makes huge improvements to GDB's handling of optimised code, I just don't want to rush things, but I'm certain we will get there. Thanks, Andrew