From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 8B030388C037 for ; Wed, 19 May 2021 11:12:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8B030388C037 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x435.google.com with SMTP id q5so13583846wrs.4 for ; Wed, 19 May 2021 04:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q5OySROtThS4FezKgzohP5Kf8FqE5hhxcSDTgkpYNj4=; b=VxCcKiVPFS+J8/61Tu6HFsOpdpdw+pBSN3TxCe8BeR0ETTNid7ol4s1VpnjJsCBqp3 WOWa7lp5AnJfagSAwrbMpTE+X5eSNv7Fn8DEDVjiDaA/VswHfuFlYM0Depldfy9njKMc 4wtH7JjU988nhi6orTAIODSrXZ3T398rIEf8wtFFY+0gXFG4Db7Iv4FjgVLeBYosG+iN 0Lh73haC6PRoivv28Q1ngSKwJ15vhQb8CPMrq+7FmilVr3ow9wRNaStrI5cJnmwbEL6H UZs/Zu3j/n7oiswS+FwqfKivIPTQiOjG1xHFrAm/EzHl1S972Gvt9iqKu+ZFNkCYpVui yYrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q5OySROtThS4FezKgzohP5Kf8FqE5hhxcSDTgkpYNj4=; b=ifqmF5zdtJBCPvh/A0bwAtfI2g/eE6uef8wCE5L0JJi1wk+qIEzlfoyjqnZYXOKVeo ipgWSaRCrB+8st9ZAv57eC8MatJKy0P1P1ZuC0uyiacN5Jymbsw9D/ZmBn0KpeJSX7e6 qBFcfffRdnl8Kw9hLz2kKgCMIW9TD1nXDIN2CzDbLN7jFPnc74wqg2fXTSMPjDPAFM+Q /4DVnHWnugKpLDW7kMRdEdFSmc6vJjjHp+QC1jzSrZmwjX3Qqmdh4L/UYTbKlixf/v3X do5DqWND1P9fWRE9+jQcByyxOnEbQEOYD/v7vIL2m8a0EpAK0TOgocFlTYCTWONpoTCk o0vg== X-Gm-Message-State: AOAM532LMXTIcKJbBQv8c5vZ2qg6wPtJlsAJfqrpD+rRu0P7Yw74zcUW BncA91mxFsuPwkjNSobeWNxPf/X4rIoqYQ== X-Google-Smtp-Source: ABdhPJz0Io9hatVH1D3r9Fso9vlOULVK49HXaFQ9DEIRDAMfwLTugYrqLfF9omoPFB4OQeIzyTxNYQ== X-Received: by 2002:adf:dcd2:: with SMTP id x18mr13570395wrm.202.1621422767375; Wed, 19 May 2021 04:12:47 -0700 (PDT) Received: from localhost (host109-151-46-70.range109-151.btcentralplus.com. [109.151.46.70]) by smtp.gmail.com with ESMTPSA id f20sm23810588wmh.41.2021.05.19.04.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 04:12:46 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCHv2 1/5] gdb: add new function quick_symbol_functions::has_unexpanded_symbols Date: Wed, 19 May 2021 12:12:38 +0100 Message-Id: <247df5f35a3aeb475960ebbd20099b4577a2f2bc.1621421987.git.andrew.burgess@embecosm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 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 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 19 May 2021 11:12:50 -0000 Adds a new function to the quick_symbol_functions API to let us know if there are any unexpanded symbols. This functionality is required by a later commit. After this commit the functionality is unused, and untested. The new function objfile::has_unexpanded_symtabs is added to the symfile-debug.c file which is a little strange, but this is (currently) where many of the other objfile::* functions (that call onto the quick_symbol_functions) are defined, so I'm reluctant to break this pattern. There should be no user visible changes after this commit. gdb/ChangeLog: * dwarf2/read.c (struct dwarf2_base_index_functions) : Declare. (dwarf2_base_index_functions::has_unexpanded_symtabs): Define new function. * objfiles.h (struct objfile) : Declare. * psympriv.h (struct psymbol_functions) : Declare. * psymtab.c (psymbol_functions::has_unexpanded_symtabs): Define new function. * quick-symbol.h (struct quick_symbol_functions) : Declare. * symfile-debug.c (objfile::has_unexpanded_symtabs): Define new function. --- gdb/ChangeLog | 16 ++++++++++++++++ gdb/dwarf2/read.c | 22 ++++++++++++++++++++++ gdb/objfiles.h | 6 ++++++ gdb/psympriv.h | 2 ++ gdb/psymtab.c | 18 ++++++++++++++++++ gdb/quick-symbol.h | 6 ++++++ gdb/symfile-debug.c | 25 +++++++++++++++++++++++++ 7 files changed, 95 insertions(+) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 8a57aeee61c..f7d6332342e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2027,6 +2027,8 @@ struct dwarf2_base_index_functions : public quick_symbol_functions { bool has_symbols (struct objfile *objfile) override; + bool has_unexpanded_symtabs (struct objfile *objfile) override; + struct symtab *find_last_source_symtab (struct objfile *objfile) override; void forget_cached_source_info (struct objfile *objfile) override; @@ -4481,6 +4483,26 @@ dwarf2_base_index_functions::has_symbols (struct objfile *objfile) return true; } +/* See quick_symbol_functions::has_unexpanded_symtabs in quick-symbol.h. */ + +bool +dwarf2_base_index_functions::has_unexpanded_symtabs (struct objfile *objfile) +{ + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + + for (const auto &per_cu : per_objfile->per_bfd->all_comp_units) + { + /* Is this already expanded? */ + if (per_objfile->symtab_set_p (per_cu.get ())) + continue; + + /* It has not yet been expanded. */ + return true; + } + + return false; +} + /* DWARF-5 debug_names reader. */ /* DWARF-5 augmentation string for GDB's DW_IDX_GNU_* extension. */ diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 5a8a782a646..f947d699132 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -565,6 +565,12 @@ struct objfile bool has_partial_symbols (); + /* Return true if this objfile has any unexpanded symbols. A return + value of false indicates either, that this objfile has all its + symbols fully expanded (i.e. fully read in), or that this objfile has + no symbols at all (i.e. no debug information). */ + bool has_unexpanded_symtabs (); + /* See quick_symbol_functions. */ struct symtab *find_last_source_symtab (); diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 59dd66f57e5..3e51b972413 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -503,6 +503,8 @@ struct psymbol_functions : public quick_symbol_functions bool has_symbols (struct objfile *objfile) override; + bool has_unexpanded_symtabs (struct objfile *objfile) override; + struct symtab *find_last_source_symtab (struct objfile *objfile) override; void forget_cached_source_info (struct objfile *objfile) override; diff --git a/gdb/psymtab.c b/gdb/psymtab.c index fe32486e2fc..6b8ac010612 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1184,6 +1184,24 @@ psymbol_functions::has_symbols (struct objfile *objfile) return m_partial_symtabs->psymtabs != NULL; } +/* See quick_symbol_functions::has_unexpanded_symtabs in quick-symbol.h. */ + +bool +psymbol_functions::has_unexpanded_symtabs (struct objfile *objfile) +{ + for (partial_symtab *psymtab : require_partial_symbols (objfile)) + { + /* Is this already expanded? */ + if (psymtab->readin_p (objfile)) + continue; + + /* It has not yet been expanded. */ + return true; + } + + return false; +} + /* Helper function for psym_find_compunit_symtab_by_address that fills in m_psymbol_map for a given range of psymbols. */ diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index f06ceff41c2..7af0aebb9fe 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -86,6 +86,12 @@ struct quick_symbol_functions available. */ virtual bool has_symbols (struct objfile *objfile) = 0; + /* Return true if OBJFILE has any unexpanded symtabs. A return value of + false indicates there are no unexpanded symtabs, this might mean that + all of the symtabs have been expanded (full debug has been read in), + or it might been that OBJFILE has no debug information. */ + virtual bool has_unexpanded_symtabs (struct objfile *objfile) = 0; + /* Return the symbol table for the "last" file appearing in OBJFILE. */ virtual struct symtab *find_last_source_symtab (struct objfile *objfile) = 0; diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index b839194e2f7..a10af68f5b1 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -100,6 +100,31 @@ objfile::has_partial_symbols () return retval; } +/* See objfiles.h. */ +bool +objfile::has_unexpanded_symtabs () +{ + if (debug_symfile) + fprintf_filtered (gdb_stdlog, "qf->has_unexpanded_symtabs (%s)\n", + objfile_debug_name (this)); + + bool result = false; + for (const auto &iter : qf) + { + if (iter->has_unexpanded_symtabs (this)) + { + result = true; + break; + } + } + + if (debug_symfile) + fprintf_filtered (gdb_stdlog, "qf->has_unexpanded_symtabs (%s) = %d\n", + objfile_debug_name (this), (result ? 1 : 0)); + + return result; +} + struct symtab * objfile::find_last_source_symtab () { -- 2.25.4