From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 8868B383801E for ; Mon, 26 Apr 2021 17:07:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8868B383801E 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-wm1-x32f.google.com with SMTP id i129so3385997wma.3 for ; Mon, 26 Apr 2021 10:07:09 -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=MLYVakSRNKoEtcur8TqO1HBPYPdoEfjq6bSZBaZ6Fc0=; b=S9ysKV9wiaHFgHhQSi+bJQ5ilp65JPcvu3mJJHnVQsFXUQ1pSNxUllos+fbZCjXTfQ yjb0irpIpySPDwPCZyoKI6+r34Bg8m121YOemcegbTbaWJ6J3bSXmHHV6OJ7WUIw30Zx EmTmUsa7RDYCGDRcDgDU8lj9i1Dy/nQ9oO2t4lfgHv3uV8A5EFqztkgM0W11id6JSzx1 3ZzUQ2wML32c02FOTb5cnFx3T4+8PC+H2nnuMHLf6yQr413WVRU3UaSdANWv/1Ie3yxg 2uWGwta8oM97LFSLe3lnl2fm0GoZVo07BBshyUQcl0Zyqso2Gt7keWWI9Za1CDa07fNf 1SVg== 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=MLYVakSRNKoEtcur8TqO1HBPYPdoEfjq6bSZBaZ6Fc0=; b=Xrr/lCK46h/fQjBrrEEPdW6BtYbzj8fZxFJhHwWy/Crl6u+vH1xYaSVd77TlpqcDSU 4UCtbNO2TRK3mzbvDHxtcFe/amEEWEzLFYt8mQ0t2q0aqihFYKJTgKh/YYeudp7lmLiy hBqhirL/tC2eiP9lKdxG3PnEWRsUpupZdq75eR1L+z+HvkA0P+nhkrBCnk+Q9+pV3ysc BIY/M6nvTLeyuc49oMz02+rzE6olyStsTZEcTS6kXPAvdt8W6EIxLhdislmH6VfH1tyh 7oCpjiniC6GEHRxbn2zY+CYjDAccqLK9Si4DZX0UuUmdkOVD6WgCAc4qEh0AsA/2tOQ6 NxRA== X-Gm-Message-State: AOAM531RTl8mKnG/f8kviN54vVCPkc2bSByKoOkWyj+uxcY0gvjqUmry NO3AptSalgzyeXiF81W8Yd3UXov1D4xOKQ== X-Google-Smtp-Source: ABdhPJzFyhwKJCFbYiWPI1A+Q2BTlUvZnaBRpC2wCWLpNwIzlM1r/cD1FThLOMtpiy7TyRsN30SVug== X-Received: by 2002:a7b:ca42:: with SMTP id m2mr20765887wml.67.1619456828297; Mon, 26 Apr 2021 10:07:08 -0700 (PDT) Received: from localhost (host109-151-46-70.range109-151.btcentralplus.com. [109.151.46.70]) by smtp.gmail.com with ESMTPSA id v185sm18697027wmb.25.2021.04.26.10.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 10:07:07 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCH 1/4] gdb: add new function quick_symbol_functions::has_unexpanded_symbols Date: Mon, 26 Apr 2021 18:07:00 +0100 Message-Id: <87ca93b987e114d57bb549ae72d6635148341e22.1619456691.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=-11.9 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: Mon, 26 Apr 2021 17:07:11 -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. 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_symbols): Define new function. * objfiles.h (struct objfile) : Declare. * psympriv.h (struct psymbol_functions) : Declare. * psymtab.c (psymbol_functions::has_unexpanded_symbols): Define new function. * quick-symbol.h (struct quick_symbol_functions) : Declare. * symfile-debug.c (objfile::has_unexpanded_symbols): 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 | 13 +++++++++++++ 7 files changed, 83 insertions(+) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 306971ef1b7..5ab0c59c7ae 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2275,6 +2275,8 @@ struct dwarf2_base_index_functions : public quick_symbol_functions { bool has_symbols (struct objfile *objfile) override; + bool has_unexpanded_symbols (struct objfile *objfile) override; + struct symtab *find_last_source_symtab (struct objfile *objfile) override; void forget_cached_source_info (struct objfile *objfile) override; @@ -4767,6 +4769,26 @@ dwarf2_base_index_functions::has_symbols (struct objfile *objfile) return true; } +/* See quick_symbol_functions::has_unexpanded_symbols in quick-symbol.h. */ + +bool +dwarf2_base_index_functions::has_unexpanded_symbols (struct objfile *objfile) +{ + dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); + + for (dwarf2_per_cu_data *per_cu : per_objfile->per_bfd->all_comp_units) + { + /* Is this already expanded? */ + if (per_objfile->symtab_set_p (per_cu)) + 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..72d9bab5555 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_symbols (); + /* See quick_symbol_functions. */ struct symtab *find_last_source_symtab (); diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 59dd66f57e5..1712ad978e6 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_symbols (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 75a307c89aa..cc5eb503902 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1185,6 +1185,24 @@ psymbol_functions::has_symbols (struct objfile *objfile) return m_partial_symtabs->psymtabs != NULL; } +/* See quick_symbol_functions::has_unexpanded_symbols in quick-symbol.h. */ + +bool +psymbol_functions::has_unexpanded_symbols (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..096053e75e9 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 symbols. A return value of + false indicates there are no unexpanded symbols, this might mean that + all of the symbols have been expanded (full debug has been read in), + or it might been that OBJFILE has no debug information. */ + virtual bool has_unexpanded_symbols (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..cfc3bed9222 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -100,6 +100,19 @@ objfile::has_partial_symbols () return retval; } +/* See objfiles.h. */ +bool +objfile::has_unexpanded_symbols () +{ + for (const auto &iter : qf) + { + if (iter->has_unexpanded_symbols (this)) + return true; + } + + return false; +} + struct symtab * objfile::find_last_source_symtab () { -- 2.25.4