From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id AJoKARvEfGhHdSoAWB0awg (envelope-from ) for ; Sun, 20 Jul 2025 06:25:31 -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=XM6rWRCt; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F0EBD1E11C; Sun, 20 Jul 2025 06:25:30 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.8 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_SBL_CSS,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 2CF801E0C2 for ; Sun, 20 Jul 2025 06:25:30 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7A7A385DC3D for ; Sun, 20 Jul 2025 10:25:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7A7A385DC3D 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=XM6rWRCt Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 7AED7385E007 for ; Sun, 20 Jul 2025 10:21:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AED7385E007 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 7AED7385E007 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1753006869; cv=none; b=OqeiNBRxDZo4H0kaQy4wYdRq7CKTl7IfF2jIft2veMVY2TXVtM1kQ8a7wOSxX7L2pYJ9hffFz3QATInyYR0OGxH/6qAKsEubznPUsFJ3O9L4+aPA2caDsvylYFaHKhKch4V9jvC2VDqyqMTKgeE/5SbLhP82HyRzkKRaCGHhVg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1753006869; c=relaxed/simple; bh=673TsrRiq3s7Plf9CvdXoi1CO5+4U8qdryQSs4FULuY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jNBGJ45qXhQTBQgIytmvubBJ7b+t2NsVvIwXz6qXFkoMBUkQadmIKujcxpYxZNxAZNgivm5DH6kj2BH5poEgb0w8xbFhlvpDae6PxzJMBlXj5To8v9LaVk+dJpvrS4PUJvFCHuhv3TKlOQK8QRzL1zdO7J871i3gWWNGKKbbirQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7AED7385E007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753006869; 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=uLiXNYBZNelGoyjXfZLLvaRvOHq+nFhONT4PX+wnp1U=; b=XM6rWRCth7P40zV+4MVz80i2gW5ZJtAPtsMIL30GCa7IhvbHOgqujbDuNxqYxKk+oBu4cx yQqPlKST4AMaDPQudKt4R7Pyy6sZ6reeXW1qyUpiJfh3MhRvsLte8lpp8/fgA8n5lJEOA1 U62z3f8lecjsaGq7l0QaNTGWqpii8Sg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-kBOVgRtVOoGrmDel0TBfPA-1; Sun, 20 Jul 2025 06:21:07 -0400 X-MC-Unique: kBOVgRtVOoGrmDel0TBfPA-1 X-Mimecast-MFC-AGG-ID: kBOVgRtVOoGrmDel0TBfPA_1753006866 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a58939191eso1515581f8f.0 for ; Sun, 20 Jul 2025 03:21:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753006865; x=1753611665; 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=uLiXNYBZNelGoyjXfZLLvaRvOHq+nFhONT4PX+wnp1U=; b=XoV15rpFP42jXDSio+wbEMSAwKYJiBYN04DISGLFwI/ES+TtsRcTYhqtRdE3QFifUR Z9WkXRp98pCGelOZx1bO5PWd6FQv3nbBnHunSbsKBbp4yNhkyxDeMD83lRXbnw8rjrnp xA+gdCs2M5OUKw0unMsQ4Zjjtacygr6gw9fBMYGRi892FablLEEHpvzC2ULQ6HAL3NkK 5CkyXN3AxskX6DeS8OgouElT5kWLAwTrQp5Gn33DvmyC/bvvT2JLbMpJ/hF7+kaGeI8/ T1ir/gd8CMr+GHt8c6g0CdXDQiNQdLcj2oNKe+hbCEuc9DQebZvd/bwlvBa8Wr6T4fwI OtCQ== X-Gm-Message-State: AOJu0Yyp1oiBsML6b5Ghd+R5PEAWUUZzUlNOKVryDChC7Y1ygaPMx+TP 8YD8UPA2Zp/eVH2FaIzRCwwQmyesQxdhgXEiG1JTj/zvX913KzCzd8FkY8sfleD5XzQpOD804lv ClMWQoJ8MqiAKGz4OIUIXrllXDSaHintPpihBKgt5H0QrDuOM/fJKKaMZfr/X2131oCFB1GzsJ0 2MRHIHMcIAlWqR35lixPsqDWkTlDXBFNWetQoKDuq5HCspR5U= X-Gm-Gg: ASbGncuSgrXR3XYlTgwly0u5h9ysxdoVNLRCfprQj2s44yRJaEGA9vFVXmcZAju4lM2 ODOjHyLx2kBOfrvYKvfR9MSXx26xINOWZ0TtNA2U0EgRWkOX4YYD3FR6c3iJlKNlNEVg4r3LLWB 4aKKwQtn+gBBV+RDWYX+s/elEk1uBFlpTwcAfPcceV0OexQWF6xmbv1fWNquqlnMRCchwSqor/F Sm0ap02EFv00bUTvgQfDPnjzKxL1TVAqKypFNwxLPNvlAzdwP62ItAlIE00fV9TzEL/09sS6gBg Ql3mREf22bxS8BGJup+UjCWvmxu8eAiZElJshP+Z/s90prZNPkSwwQk34o5HlQ== X-Received: by 2002:a05:6000:4284:b0:3a5:39ee:2619 with SMTP id ffacd0b85a97d-3b60e51bd54mr12313606f8f.47.1753006865357; Sun, 20 Jul 2025 03:21:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtcFpG4wsticEQDWXd5uWnIurT3i1BqlnRlZ+RopgeQ/QW9ptPvo7XM5jx8qP5zikEZSaGQQ== X-Received: by 2002:a05:6000:4284:b0:3a5:39ee:2619 with SMTP id ffacd0b85a97d-3b60e51bd54mr12313585f8f.47.1753006864809; Sun, 20 Jul 2025 03:21:04 -0700 (PDT) Received: from localhost (92.40.185.56.threembb.co.uk. [92.40.185.56]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca4d786sm7275666f8f.72.2025.07.20.03.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 03:21:04 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 6/7] gdb: record block end addresses while parsing DIEs Date: Sun, 20 Jul 2025 11:20:45 +0100 Message-ID: <47a4003bea404c60d9526cff04ef1e1df0f908e9.1753006060.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: ri-Yc8Dqnz6bI6OlJfSQOafwTLDQPTCj-0403MQHIG0_1753006866 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 47fbccbdb08..992cf008da0 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