From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id E93833945C2D for ; Thu, 24 Mar 2022 05:22:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E93833945C2D Received: by mail-pj1-x102e.google.com with SMTP id mj15-20020a17090b368f00b001c637aa358eso8506388pjb.0 for ; Wed, 23 Mar 2022 22:22:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=3FHcwJj9wbL/RmN51u3ZjjJKKXHruZs+29jNtMWeHH0=; b=GMvZzcRfPv02ZObZy1n/Zm1ETOLWa/Udcu+XwWUTW0lWFDBiqZ8QQxqgPQjCJ7ZsO/ 00KeTGQyltRNO/JezjrmPUmSrE1BT7+VyMm+K+8xkbHaezSpNfcS+BCjV3XvfUdiNUGL szBN/qxM+HOGKZ47+FXKN/+48+uFH3/Rd+8mUcUBxytZ2Sg7KSjOG+S98Y0hfhl6KSfJ v/dbOKK5Fn7e/rdwlQafLVK/sP1vM+qSnFtnekXKcCrZhN79KKGQKZUEupfgYEcdkCpF r5WPTkOBEmEk7lDiHUqeagCPENwu/Lmkfj3fEOY+gE5H3P7LZzDs9IX/7NB8HZRDSAjK 87Iw== X-Gm-Message-State: AOAM531jUlQlRUlNeXzLCe3aN0x3PWqru0ygyqAdbbZ55WmZpg4UOFaw MD+E94X7mBO82qrKhvK8H1U= X-Google-Smtp-Source: ABdhPJySrEssBUWUmPyZccyUM6eXiNQcee5DGjWvduiePkG1TyzTdRVyk2TDagC/t2b4sNSvXAykJg== X-Received: by 2002:a17:902:8549:b0:153:563a:39a1 with SMTP id d9-20020a170902854900b00153563a39a1mr3983750plo.21.1648099350985; Wed, 23 Mar 2022 22:22:30 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id z6-20020a056a00240600b004e17ab23340sm1667408pfh.177.2022.03.23.22.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 22:22:30 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 36D8111403AC; Thu, 24 Mar 2022 15:52:27 +1030 (ACDT) Date: Thu, 24 Mar 2022 15:52:27 +1030 From: Alan Modra To: "Steinar H. Gunderson" Cc: Nick Clifton , binutils@sourceware.org, sesse@chromium.org Subject: Re: [PATCH] Add a trie to map quickly from address range to compilation unit. Message-ID: References: <20220321094030.1256430-1-sesse@google.com> <63191455-2374-5db9-f55e-ddf794c7d88e@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-3037.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2022 05:22:33 -0000 On Wed, Mar 23, 2022 at 11:24:20PM +0100, Steinar H. Gunderson via Binutils wrote: > But I noticed something else that's probably not good in the existing > code; the “found” variable leaks out of the loop from the last iteration > (only). So if you find a match without a line number of the > second-to-last compilation unit but not in the last, found = false on > return, but if you find a similar match in the last compilation unit, > found = true. > > I suppose this isn't intentional, but what is the intention? Should > there be a “found = false;” before the test on *linenumber_ptr? Huh, I remember looking at this code a while ago and finding it confusing. I think the code would be clearer, and behave the same on normal line number info with the following patch: * dwarf2.c (_bfd_dwarf2_find_nearest_line): Simplify setting of "found" in loop checking previous comp units with comp_unit_contains_address. diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 8b5ac6012e1..ca8403da6da 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -5195,16 +5195,16 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd, for (each = stash->f.all_comp_units; each; each = each->next_unit) { - bfd_vma range = (bfd_vma) -1; - - found = ((each->arange.high == 0 - || comp_unit_contains_address (each, addr)) - && (range = (comp_unit_find_nearest_line - (each, addr, &local_filename, - &local_function, &local_linenumber, - &local_discriminator))) != 0); - if (found) + bfd_vma range; + + if ((each->arange.high == 0 + || comp_unit_contains_address (each, addr)) + && (range = (comp_unit_find_nearest_line + (each, addr, &local_filename, + &local_function, &local_linenumber, + &local_discriminator))) != 0) { + found = true; /* PRs 15935 15994: Bogus debug information may have provided us with an erroneous match. We attempt to counter this by selecting the match that has the smallest address range @@ -5231,11 +5231,8 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd, } } - if (* linenumber_ptr) - { - found = true; - goto done; - } + if (found) + goto done; } /* Read each remaining comp. units checking each as they are read. */ -- Alan Modra Australia Development Lab, IBM