From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MP2zD3WCjGiifgEAWB0awg (envelope-from ) for ; Fri, 01 Aug 2025 05:01:41 -0400 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=aMRmp19M; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3CBF91E102; Fri, 1 Aug 2025 05:01:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-10.1 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,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 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 AF8691E089 for ; Fri, 1 Aug 2025 05:01:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 60252385840E for ; Fri, 1 Aug 2025 09:01:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60252385840E 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=aMRmp19M 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 C6A6E385842D for ; Fri, 1 Aug 2025 08:58:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C6A6E385842D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 C6A6E385842D 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=1754038725; cv=none; b=oVX3GO6pqDjvaQvOfOu40ZkmO7YRRnXPS5ynsJxUe8iLRhcN2zGSZny7Y7pj8qPAjkzMyAba8nMG+DdBo2RTUhtFMNccexeozyxSARgWWPCbp6ODEP5R3uj0lW/FvRGNu1rXE8TRafNx9K1ehvesrgxf3L7G9sX/isIxZ3V1rxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754038725; c=relaxed/simple; bh=iWyQxq8T8KfrNAkN2P+e8Cvh59JktATRwqMuU1gYAtA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Hk5lHX70xOmbXxI9ZkLPD+7U2GBxhTBLrkAf9Cx/78g++GHkp0lnpAUWQKa91rHBGDKrC5mKGIQ4dcZc6ws6myAIcXqiDPUUSTJQPZ54eQijszhcANsnl3BA5kbAxhq01ZC0wId0ILAC4VCB4KHEoCnPcNjSXe9WUsmV0YMMhVY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6A6E385842D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754038725; h=from:from:reply-to:subject:subject: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=6a/khIkJTCx6jyiSFDVT48qpXuzQzvAduxe+OPhg4vQ=; b=aMRmp19Mp8UQJNCwSpoMGPzKoaR/IImGhuYveSjhmzBqlJ6b6VWs4oDkzM0czDue88urVN KnhMuspd31nFSjI9RQ20m8BQnKOc+pdT4NMbAnHDRjd/8SZfLFg6unHTpxqeSmgM1TosR+ B68pz4Sgub+wBVsfBFRu/jVZcq43xBM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-134-EfB0aA0FNMGARH0oArlnzQ-1; Fri, 01 Aug 2025 04:58:44 -0400 X-MC-Unique: EfB0aA0FNMGARH0oArlnzQ-1 X-Mimecast-MFC-AGG-ID: EfB0aA0FNMGARH0oArlnzQ_1754038723 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3b79c28f8ceso1368146f8f.3 for ; Fri, 01 Aug 2025 01:58:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754038723; x=1754643523; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6a/khIkJTCx6jyiSFDVT48qpXuzQzvAduxe+OPhg4vQ=; b=EIoszemUM9tk31aYN7MTYbp+30/979R7yxs0nVZmD9BQ0kljQVYNst6Uo7X7oQiMok lo0IzYpRfd53HVTq8flbf9u/N3qy0GnrfykhKLLlfSh9fJJzNGhAz9LxGrLuL6ebq2Hy 9LdV6YlerBI+ciFSA0Om892VeMiLd9rn3A/MZWpkwfesEm3p1iRrXI0RhwwfsJQ1Ldw1 pcxHqspughioSl6g2xHrkswbIleV8ESGkqSPprZ2p6lVZaw9ejHzCSv4O9PBX/TQzSJB /PQSBz3JS8ze580q7/umA5xmRsTvLAmoUgkexhDtaITQpbGMgKLWgILjfsFvbmT2lQTC fV4Q== X-Gm-Message-State: AOJu0YyN0QsQoyzjEzWafST64nURiIjBXLEBzsriHcAPJfK7P4yZ3OaP MVbF3CyegLEXeMfusgygoUpkrHGCf3sPuQ6tjvG5sIsDhUJu8Ab5TMAmfuP3x+neIir5FtYHqzP ihxmlDvC1q647+TuOccBAPLrzlgXy5FUvKu8tHn8BvxgUkJbT4ZKDwdOlGUMfYobntqyXMAoX7s dmfZ4O3mUys/ZSnoeBGyMK+/LT0AfdsjZFmoAhIyUKoFz0LBs= X-Gm-Gg: ASbGncvW+TBE8Ha7RJUup33A41nNt6oLCMSjRtI2G4YpgfjBtyoJBAg1QN6ECl+5JVY zIupcXN8px0NyCt3dbO0T85lwvNrUlIAPl6D17W3IwCifyLDd5TnnknT+4bFkDadGA5fHbtN473 scrr+cb5HFP+Iof1LLAvzmT+QWYdRAClkksr8AktRUZkkk8QARrHM4+uwAwCqBeeSUn6UG9HQ0L 9LmTbdcUE9NgPGi1fHAege4NGhTEmfjWgHquy+sRRf40HUijv5ATBaOlM93UdJHjc4yxl7/pRjv 6l/Ah6jVP42J6tGJdCDY4LOJKbYib4KOybOUCqLcuFr6GVwdj8BjOdWNV5U= X-Received: by 2002:a05:6000:250f:b0:3a5:527b:64c6 with SMTP id ffacd0b85a97d-3b794fe4d58mr9014542f8f.1.1754038722697; Fri, 01 Aug 2025 01:58:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+CTYEDwnHs7A9ocRWW5/cWfRQZ5Kcpj5G5StKHb2ODonaHODwHgTedCAMBVUjNHGb4vcA+A== X-Received: by 2002:a05:6000:250f:b0:3a5:527b:64c6 with SMTP id ffacd0b85a97d-3b794fe4d58mr9014512f8f.1.1754038722142; Fri, 01 Aug 2025 01:58:42 -0700 (PDT) Received: from localhost (27.81.93.209.dyn.plus.net. [209.93.81.27]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b79c469582sm5072255f8f.52.2025.08.01.01.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Aug 2025 01:58:41 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 6/7] gdb: record block end addresses while parsing DIEs Date: Fri, 1 Aug 2025 09:58:19 +0100 Message-ID: <1f39d6a3efa1e0bc7ab2216177fac01cc0b8cc71.1754038556.git.aburgess@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: UAgMTZaxpJ8PLfksUAL4B8erZRpYXCghoLp2tFAzgvI_1754038723 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 Continuing to work towards the goal of improving GDB's ability to debug optimised code, this commit stores a map from the end address of a block (or a block's sub-range) to the block pointer. This information is collected while parsing the DIEs. This new map is required after the last commit deferred building the address map. The optimised code fix ups require that we can map from an address back to a block, something the address map is perfect for. However, the optimised code fix ups will then adjust the block ranges, which means the address map is out of date. So, I saw a couple of choices, I could build the address map while parsing the DIES (as if the previous commit had not occurred), use the address map to lookup inline blocks, and then either update, or rebuild the full address map. Or, I could defer building the address map, and then create this "partial" address map that only holds the interesting, inline, blocks. I felt that maintaining this alternative, partial address map was probably cheaper, take a look at how new entries are added to the addrmap class compared to this gdb::unordered_map. Currently, nothing is done with this information, the information is recorded as the block ranges are recorded, and then discarded after the line table has been built. But in the next commit, this will be used to help adjust the ranges of some inline blocks, and this will improve GDB's ability to debug optimised code. There should be no user visible changes after this commit. --- gdb/dwarf2/cu.h | 7 +++++++ gdb/dwarf2/read.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h index 69f396c774a..c1c0d9fcaa2 100644 --- a/gdb/dwarf2/cu.h +++ b/gdb/dwarf2/cu.h @@ -269,6 +269,13 @@ struct dwarf2_cu return m_producer; } + /* The end addresses for some inline blocks. For blocks with multiple + sub-ranges, this is the end address of every sub-range within the + block. These are the inclusive end addresses, that is, these are the + last addresses inside the block's ranges. Only the first block that + ends at any given address will be recorded. */ + gdb::unordered_map inline_block_ends; + private: const char *m_producer = nullptr; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e553a47e970..cb3dace9fea 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6057,6 +6057,10 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) && cu->line_header != nullptr) dwarf_decode_lines (cu, unrel_low); + /* We no longer need to track the inline block end addresses. Release + memory associated with this. */ + cu->inline_block_ends.clear (); + /* Decode macro information, if present. Dwarf 2 macro information refers to information in the line number info statement program header, so we can only read it if we've read the header @@ -9856,6 +9860,10 @@ dwarf2_record_single_block_range (struct dwarf2_cu *cu, struct block *block, CORE_ADDR low, CORE_ADDR high, unrelocated_addr unrel_high) { + /* If this is the end of an inline block, then record its end address. */ + if (block->inlined_p () && block->function () != nullptr) + cu->inline_block_ends.insert ({unrel_high, block}); + cu->get_builder ()->record_block_range (block, low, high); } -- 2.47.1