From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EAVZAElB8WKr3CIAWB0awg (envelope-from ) for ; Mon, 08 Aug 2022 13:00:57 -0400 Received: by simark.ca (Postfix, from userid 112) id F33D41EA06; Mon, 8 Aug 2022 13:00:56 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=awWD1dR7; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 713691E9ED for ; Mon, 8 Aug 2022 13:00:56 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2472F3857036 for ; Mon, 8 Aug 2022 17:00:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2472F3857036 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1659978056; bh=SSlVB2Bi8oTspsVc7zSm3wttLgUuDtFcdrfgdLwuggk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=awWD1dR7+0iJK7HWHPqfmgGChNj5PFBA/5g+ovq3SuSHD/K4xMwuH4eSlepCl0bHm O9f0356+g+StqD+gqFU5eGfNnUnzFcl0cc7fnkREm2p3pLuECCtl03xITMk2stetTV kfeFdZFB+PeoZaIRB7EB9zDGPADqKAlcFb17miRU= Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id 1D59C3857000 for ; Mon, 8 Aug 2022 17:00:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D59C3857000 X-IronPort-AV: E=McAfee;i="6400,9594,10433"; a="354643402" X-IronPort-AV: E=Sophos;i="5.93,222,1654585200"; d="scan'208";a="354643402" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2022 10:00:31 -0700 X-IronPort-AV: E=Sophos;i="5.93,222,1654585200"; d="scan'208";a="580430680" Received: from labpcdell3650-003.iul.intel.com (HELO localhost) ([172.28.49.87]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2022 10:00:29 -0700 To: gdb-patches@sourceware.org Subject: [PATCH v5 1/3] gdb, dwarf: move part of dwarf2_get_pc_bounds into separate function Date: Mon, 8 Aug 2022 19:00:17 +0200 Message-Id: <20220808170019.86052-2-nils-christian.kempke@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220808170019.86052-1-nils-christian.kempke@intel.com> References: <20220808170019.86052-1-nils-christian.kempke@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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: , From: Nils-Christian Kempke via Gdb-patches Reply-To: Nils-Christian Kempke Cc: jinisusan.george@amd.com, tom@tromey.com, aburgess@redhat.com Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" This commit is in preparation of the next commit. There, we will add a second variation to retrieve the pc bounds for DIEs tagged with DW_TAG_entry_point. Instead of dwarf_get_pc_bounds_ranges_or_highlow_pc we will call a separate method for entry points. As the validity checks at the endo f dwarf2_get_pc_bounds are the same for both variants, we introduced the new dwarf_get_pc_bounds_ranges_or_highlow_pc method, outsourcing part of dwarf2_get_pc_bounds. This commit should have no functional impact on GDB. Signed-off-by: Nils-Christian Kempke --- gdb/dwarf2/read.c | 71 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 84faeb45238..569a7867084 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13036,20 +13036,19 @@ dwarf2_ranges_read_low_addrs (unsigned offset, struct dwarf2_cu *cu, }); } -/* Get low and high pc attributes from a die. See enum pc_bounds_kind - definition for the return value. *LOWPC and *HIGHPC are set iff - neither PC_BOUNDS_NOT_PRESENT nor PC_BOUNDS_INVALID are returned. */ +/* Determine the low and high pc using the DW_AT_low_pc and DW_AT_high_pc or + DW_AT_ranges attributes of a DIE. */ -static enum pc_bounds_kind -dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, - CORE_ADDR *highpc, struct dwarf2_cu *cu, - addrmap *map, void *datum) +static pc_bounds_kind +dwarf_get_pc_bounds_ranges_or_highlow_pc (die_info *die, CORE_ADDR *low, + CORE_ADDR *high, dwarf2_cu *cu, + addrmap *map, void *datum) { - dwarf2_per_objfile *per_objfile = cu->per_objfile; + gdb_assert (low != nullptr); + gdb_assert (high != nullptr); + struct attribute *attr; struct attribute *attr_high; - CORE_ADDR low = 0; - CORE_ADDR high = 0; enum pc_bounds_kind ret; attr_high = dwarf2_attr (die, DW_AT_high_pc, cu); @@ -13058,17 +13057,19 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, attr = dwarf2_attr (die, DW_AT_low_pc, cu); if (attr != nullptr) { - low = attr->as_address (); - high = attr_high->as_address (); + *low = attr->as_address (); + *high = attr_high->as_address (); if (cu->header.version >= 4 && attr_high->form_is_constant ()) - high += low; + *high += *low; + + /* Found consecutive range of addresses. */ + ret = PC_BOUNDS_HIGH_LOW; } else - /* Found high w/o low attribute. */ - return PC_BOUNDS_INVALID; - - /* Found consecutive range of addresses. */ - ret = PC_BOUNDS_HIGH_LOW; + { + /* Found high w/o low attribute. */ + ret = PC_BOUNDS_INVALID; + } } else { @@ -13086,16 +13087,44 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, /* Value of the DW_AT_ranges attribute is the offset in the .debug_ranges section. */ - if (!dwarf2_ranges_read (ranges_offset, &low, &high, cu, + if (!dwarf2_ranges_read (ranges_offset, low, high, cu, map, datum, die->tag)) return PC_BOUNDS_INVALID; /* Found discontinuous range of addresses. */ ret = PC_BOUNDS_RANGES; } else - return PC_BOUNDS_NOT_PRESENT; + { + /* Could not find high_pc or ranges attributed and thus no bounds + pair. */ + ret = PC_BOUNDS_NOT_PRESENT; + } } + return ret; +} + +/* Get low and high pc attributes from a die. See enum pc_bounds_kind + definition for the return value. *LOWPC and *HIGHPC are set iff + neither PC_BOUNDS_NOT_PRESENT nor PC_BOUNDS_INVALID are returned. */ + +static enum pc_bounds_kind +dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, + CORE_ADDR *highpc, struct dwarf2_cu *cu, + addrmap *map, void *datum) +{ + dwarf2_per_objfile *per_objfile = cu->per_objfile; + + CORE_ADDR low = 0; + CORE_ADDR high = 0; + enum pc_bounds_kind ret; + + ret = dwarf_get_pc_bounds_ranges_or_highlow_pc (die, &low, &high, cu, map, + datum); + + if (ret == PC_BOUNDS_NOT_PRESENT || ret == PC_BOUNDS_INVALID) + return ret; + /* partial_die_info::read has also the strict LOW < HIGH requirement. */ if (high <= low) return PC_BOUNDS_INVALID; @@ -13112,7 +13141,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, return PC_BOUNDS_INVALID; *lowpc = low; - if (highpc) + if (highpc != nullptr) *highpc = high; return ret; } -- 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928