From patchwork Thu Dec 14 20:15:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 82165 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4E9A3861881 for ; Thu, 14 Dec 2023 20:15:49 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 2E08C3858D20 for ; Thu, 14 Dec 2023 20:15:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E08C3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2E08C3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702584935; cv=none; b=tP+m7LGOg1/pK8QA0v5sa22Df20TyJBAR1znwLPhxoiTDawS4Gbh6y2IuxCb52Jm/ZHfxMbeFd1l29faqZIZEZC2eNanZ007rg9QkCgS8yGMJop8e4ye04Ze9gF+IxfvSgtfmqtORz0RqwkZhin59PLi6j2GDYQAduSdSjcGYsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702584935; c=relaxed/simple; bh=hAONyAhq0KEiGw8imxeMhd6ShgXskJfBaYDcNg9Hxb0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=duL8XIUjORCNN2n+j/ovy0kShfil8jhVJOKGPnniNKGMoeMG3nSi+8Eib7JDZ3j2qxlx+VEk4rZASkGJP0ae3qW2sIyaVAWrZshiFGv7/BfIXiF85Vs7hZWlW1HDBy0JGf5xDCKzG3Rih/V0zUm1TUWgyPkopCpMSxFtVR9Co6o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-35f77a076e1so2745905ab.1 for ; Thu, 14 Dec 2023 12:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1702584933; x=1703189733; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZekxNHrNtO5XoyEZFKkovLaeCABGw1ACTiRo4zim2fc=; b=f962HOrl46j0wk5hjG3OyByEbvu7ItiORQCNXefDCBHx362FTvrZoVAeKTNkuqP5hg NgAIhPVJ2xmcI59b9WKn7fxMSwEzc5mOUBvx+vQgev9lAJ8pEtCsZBiLQzC8jei8kkey Xg51UA8pJaieaO3CJjDn4ZyQldaOi9C9HVVO4Bb0H7JPaj5BBbvTWJHlkOODcH2MSghB iDl/xsdw6jNkqCN1ZRzmAmZGpllEX+hlNWtYpyT2742hip45Ip9qx+OLrNTD/AAzA7t1 POUSXr9kUekikeyEg9YOX5ED1nB+Wjn3+dJhpfptwQwJbwn2gKiqDH7r3x0hdKvtelUB /wCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702584933; x=1703189733; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZekxNHrNtO5XoyEZFKkovLaeCABGw1ACTiRo4zim2fc=; b=EhBNeZ3pDCE26PtUVBIdUfLq7QGJbau8eCFKda1M7RvdrKqcudppdewp345BWOgZon iGkeECJ+uhV6228toK3PMBPaZo9AcBApaT6SovZus7zbMwSQ967ZXvr5ltHmhbiLYaM1 tHmDxYbFRQyqIa0vUVCjGrjIyFlJ8dl+eZilorA5l65EW6F4pGBFgyDVgRQb38+7D+ov UAphAEGnCaCcdiFSnQ97rtufsEVLg/2W8xGKRgPk3vjJoS7VdjTlpk2PHzmbwjrrprvd PDuwpZ3LwgtTo6cCs+TwEPa7VYxM+xm+r9DfnCxwGlCold3aXj3NkGMyiM4foj6seIzM Czug== X-Gm-Message-State: AOJu0YzSMHJ3MftfFo5rsY3XwbaOsCU/TGAa4M05llqpr7eNROQTamZT b9Qh54qnG05I5thjPxFeQCBS8n8mEjtPbgfbNu4= X-Google-Smtp-Source: AGHT+IEu6nLW2Jb4A8qvCADqFZ2LqghYwE5C8vR9dBYMvLKrF5yaiMjnonoMuoz3mwwHExgv6j8zoQ== X-Received: by 2002:a05:6e02:1ba1:b0:35d:4463:5dd2 with SMTP id n1-20020a056e021ba100b0035d44635dd2mr8883114ili.16.1702584933162; Thu, 14 Dec 2023 12:15:33 -0800 (PST) Received: from localhost.localdomain (71-211-161-25.hlrn.qwest.net. [71.211.161.25]) by smtp.gmail.com with ESMTPSA id g3-20020a92c7c3000000b0035d6800582dsm1241105ilk.37.2023.12.14.12.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 12:15:32 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Use unrelocated_addr in dwarf2_base_index_functions::find_per_cu Date: Thu, 14 Dec 2023 13:15:23 -0700 Message-ID: <20231214201523.3370294-1-tromey@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patchwork=sourceware.org@sourceware.org dwarf2_base_index_functions::find_per_cu is documented as using an unrelocated address. This patch changes the interface to use the unrelocated_addr type, just to be a bit more type-safe. Regression tested on x86-64 Fedora 38. --- gdb/dwarf2/cooked-index.c | 2 +- gdb/dwarf2/cooked-index.h | 7 ++++--- gdb/dwarf2/read.c | 15 ++++++++------- gdb/dwarf2/read.h | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index ba77f9cb373..785f1684988 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -501,7 +501,7 @@ cooked_index::~cooked_index () /* See cooked-index.h. */ dwarf2_per_cu_data * -cooked_index::lookup (CORE_ADDR addr) +cooked_index::lookup (unrelocated_addr addr) { for (const auto &index : m_vector) { diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 5675ea68bb8..fdf7d25673d 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -307,9 +307,10 @@ class cooked_index_shard /* Look up ADDR in the address map, and return either the corresponding CU, or nullptr if the address could not be found. */ - dwarf2_per_cu_data *lookup (CORE_ADDR addr) + dwarf2_per_cu_data *lookup (unrelocated_addr addr) { - return static_cast (m_addrmap->find (addr)); + return (static_cast + (m_addrmap->find ((CORE_ADDR) addr))); } /* Create a new cooked_index_entry and register it with this object. @@ -400,7 +401,7 @@ class cooked_index : public dwarf_scanner_base /* Look up ADDR in the address map, and return either the corresponding CU, or nullptr if the address could not be found. */ - dwarf2_per_cu_data *lookup (CORE_ADDR addr); + dwarf2_per_cu_data *lookup (unrelocated_addr addr); /* Return a new vector of all the addrmaps used by all the indexes held by this object. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 37cabe52ecc..009cb72daf1 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2988,12 +2988,12 @@ recursively_find_pc_sect_compunit_symtab (struct compunit_symtab *cust, dwarf2_per_cu_data * dwarf2_base_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd, - CORE_ADDR adjusted_pc) + unrelocated_addr adjusted_pc) { if (per_bfd->index_addrmap == nullptr) return nullptr; - void *obj = per_bfd->index_addrmap->find (adjusted_pc); + void *obj = per_bfd->index_addrmap->find ((CORE_ADDR) adjusted_pc); return static_cast (obj); } @@ -3010,8 +3010,8 @@ dwarf2_base_index_functions::find_pc_sect_compunit_symtab dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); CORE_ADDR baseaddr = objfile->text_section_offset (); - struct dwarf2_per_cu_data *data = find_per_cu (per_objfile->per_bfd, - pc - baseaddr); + struct dwarf2_per_cu_data *data + = find_per_cu (per_objfile->per_bfd, (unrelocated_addr) (pc - baseaddr)); if (data == nullptr) return nullptr; @@ -16486,7 +16486,7 @@ cooked_indexer::make_index (cutu_reader *reader) struct cooked_index_functions : public dwarf2_base_index_functions { dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd, - CORE_ADDR adjusted_pc) override; + unrelocated_addr adjusted_pc) override; struct compunit_symtab *find_compunit_symtab_by_address (struct objfile *objfile, CORE_ADDR address) override; @@ -16569,7 +16569,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions dwarf2_per_cu_data * cooked_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd, - CORE_ADDR adjusted_pc) + unrelocated_addr adjusted_pc) { cooked_index *table = (gdb::checked_static_cast @@ -16594,7 +16594,8 @@ cooked_index_functions::find_compunit_symtab_by_address return nullptr; CORE_ADDR baseaddr = objfile->data_section_offset (); - dwarf2_per_cu_data *per_cu = table->lookup (address - baseaddr); + dwarf2_per_cu_data *per_cu + = table->lookup ((unrelocated_addr) (address - baseaddr)); if (per_cu == nullptr) return nullptr; diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 6f97f641c8e..f28433ed91b 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -893,7 +893,7 @@ struct dwarf2_base_index_functions : public quick_symbol_functions /* A helper function that finds the per-cu object from an "adjusted" PC -- a PC with the base text offset removed. */ virtual dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd, - CORE_ADDR adjusted_pc); + unrelocated_addr adjusted_pc); struct compunit_symtab *find_pc_sect_compunit_symtab (struct objfile *objfile, struct bound_minimal_symbol msymbol,