aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-08-04[lldb][DWARFIndex] Adapt DebugNamesDWARFIndex::ProcessEntry to ↵Michael Buch1-38/+35
IterationAction (#152025) Continuation of https://github.com/llvm/llvm-project/pull/151489
2025-08-04[lldb][DWARFIndex] Adapt DWARFIndex GetTypes APIs to IterationAction (#151992)Michael Buch1-18/+22
Continuation of https://github.com/llvm/llvm-project/pull/151489
2025-08-04[lldb][DWARFIndex] Adapt DWARFIndex ObjC APIs to IterationAction (#151839)Michael Buch1-2/+2
Continuation of https://github.com/llvm/llvm-project/pull/151489
2025-08-02[lldb][DWARFIndex][NFC] Change GetNamespace/GetGlobalVariables APIs to use ↵Michael Buch1-19/+22
IterationAction (#151668) Continuation from https://github.com/llvm/llvm-project/pull/151489
2025-07-31[lldb][DWARFIndex][NFC] Change GetFunctions return type to IterationAction ↵Michael Buch1-9/+10
(#151489) The ultimate goal is to replace the return types of all the `DWARFIndex` callbacks to `IterationAction`. To reduce the blast radius and do this incrementally I'm doing this for `GetFunctions` only here. I added a `IterationActionAdaptor` helper (that will ultimately get removed once all APIs have been migrated) to avoid having to change too many other APIs that `GetFunctions` interacts with.
2025-07-22[lldb] Eliminate namespace lldb_private::dwarf (NFC) (#150073)Jonas Devlieghere1-4/+4
Eliminate the `lldb_private::dwarf` namespace, in favor of using `llvm::dwarf` directly. The latter is shorter, and this avoids ambiguity in the ABI plugins that define a `dwarf` namespace inside an anonymous namespace.
2024-12-17[lldb][DWARF] Remove obsolete calls to ↵Michael Buch1-5/+0
Supports_DW_AT_APPLE_objc_complete_type and DW_AT_decl_file_attributes_are_invalid (#120226) Depends on https://github.com/llvm/llvm-project/pull/120225 With `llvm-gcc` support being removed from LLDB, these APIs are now trivial and can be removed too.
2024-12-03[lldb] Fix "exact match" debug_names type queries (#118465)Pavel Labath1-1/+1
.. in the global namespace The problem was the interaction of #116989 with an optimization in GetTypesWithQuery. The optimization was only correct for non-exact matches, but that didn't matter before this PR due to the "second layer of defense". After that was removed, the query started returning more types than it should.
2024-10-29Improve namespace lookup using .debug_names parent chain (#110062)jeffreytan811-10/+54
## Summary This PR is a continuation of https://github.com/llvm/llvm-project/pull/108907 by using `.debug_names` parent chain faster lookup for namespaces. ## Implementation Similar to https://github.com/llvm/llvm-project/pull/108907. This PR adds a new API: `GetNamespacesWithParents` in `DWARFIndex` base class. The API performs the same function as `GetNamespaces()` with additional filtering using parents `CompilerDeclContext`. A default implementation is given in `DWARFIndex` class which parses debug info and performs the matching. In the `DebugNameDWARFIndex` override, parents `CompilerDeclContext` is cross checked with parent chain in `.debug_names` for much faster filtering before fallback to base implementation for final filtering. ## Performance Results For the same benchmark used in https://github.com/llvm/llvm-project/pull/108907, this PR improves: 48s => 28s --------- Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2024-10-09Improve type lookup using .debug_names parent chain (#108907)jeffreytan811-1/+122
## Summary This PR improves `SymbolFileDWARF::FindTypes()` by utilizing the newly added parent chain `DW_IDX_parent` in `.debug_names`. The proposal was originally discussed in [this RFC](https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151). ## Implementation To leverage the parent chain for `SymbolFileDWARF::FindTypes()`, this PR adds a new API: `GetTypesWithQuery` in `DWARFIndex` base class. The API performs the same function as `GetTypes` with additional filtering using `TypeQuery`. Since this only introduces filtering, the callback mechanisms at all call sites remain unchanged. A default implementation is given in `DWARFIndex` class which parses debug info and performs the matching. In the `DebugNameDWARFIndex` override, the parent_contexts in the `TypeQuery` is cross checked with parent chain in `.debug_names` for for much faster filtering before fallback to base implementation for final filtering. Unlike the `GetFullyQualifiedType` API, which fully consumes the `DW_IDX_parent` parent chain for exact matching, these new APIs perform partial subset matching for type/namespace queries. This is necessary to support queries involving anonymous or inline namespaces. For instance, a user might request `NS1::NS2::NS3::Foo`, while the index table's parent chain might contain `NS1::inline_NS2::NS3::Foo`, which would fail exact matching. ## Performance Results In one of our internal target using `.debug_names` + split dwarf. Expanding a "this" pointer in locals view in VSCode: 94s => 48s. (Not sure why I got 94s this time instead of 70s last week). --------- Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2024-09-16[lldb] Nits on uses of llvm::raw_string_ostream (NFC) (#108745)Youngsuk Kim1-1/+1
As specified in the docs, 1) raw_string_ostream is always unbuffered and 2) the underlying buffer may be used directly ( 65b13610a5226b84889b923bae884ba395ad084d for further reference ) * Don't call raw_string_ostream::flush(), which is essentially a no-op. * Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
2024-08-12Reapply "[lldb/DWARF] Search fallback to the manual index in ↵Pavel Labath1-0/+1
GetFullyQualified… (#102123)" This reverts commit 38b67c54ed858f60c0caebcfba4b61f9326684ca. I reverted the wrong patch -- sorry :(
2024-08-12Revert "[lldb/DWARF] Search fallback to the manual index in ↵Pavel Labath1-1/+0
GetFullyQualified… (#102123)" The test appears to be flaky. Revert it while I investigate. This reverts commits 7027cc6a073cb5ae7a0ce04fa4a2dbe714615da9 and 21ef272ec1974244710fc639f98674eae3f8b02c.
2024-08-12[lldb/DWARF] Search fallback to the manual index in GetFullyQualified… ↵Pavel Labath1-0/+1
(#102123) …Type This is needed to ensure we find a type if its definition is in a CU that wasn't indexed. This can happen if the definition is in some precompiled code (e.g. the c++ standard library) which was built with different flags than the rest of the binary.
2024-06-24Add support for using foreign type units in .debug_names. (#87740)Greg Clayton1-7/+86
This patch adds support for the new foreign type unit support in .debug_names. Features include: - don't manually index foreign TUs if we have info for them - only use the type unit entries that match the .dwo files when we have a .dwp file - fix type unit lookups for .dwo files - fix crashers that happen due to PeekDIEName() using wrong offsets where an entry had DW_IDX_comp_unit and DW_IDX_type_unit entries and when we had no type unit support, it would cause us to think it was a normal DIE in .debug_info from the main executable. --------- Co-authored-by: paperchalice <liujunchang97@outlook.com>
2024-06-11[lldb] Skip declaration DIEs in the debug_names index (#94744)Pavel Labath1-0/+5
This makes sure we try to process declaration DIEs that are erroneously present in the index. Until bd5c6367bd7, clang was emitting index entries for declaration DIEs with DW_AT_signature attributes. This makes sure to avoid returning those DIEs as the definitions of a type, but also makes sure to pass through DIEs referring to static constexpr member variables, which is a (probably nonconforming) extension used by dsymutil. It adds test cases for both of the scenarios. It is essentially a recommit of #91808.
2024-06-06Revert "[lldb][DebugNames] Only skip processing of DW_AT_declarations for ↵Pavel Labath1-5/+0
class/union types" and two follow-up commits. The reason is the crash we've discovered when processing -gsimple-template-names binaries. I'm committing a minimal reproducer as a separate patch. This reverts the following commits: - 51dd4eaaa29683c16151f5168e7f8645acbd6e6c (#92328) - 3d9d48523977af3590f7dd0edfd258454cb9e9cf (#93839) - afe6ab7586f7078cc410f6162bd9851e48e2a286 (#94400)
2024-06-04[lldb][DebugNames] Only skip processing of DW_AT_declarations for ↵Michael Buch1-1/+2
class/union types (#94400) This is a follow-up of https://github.com/llvm/llvm-project/pull/92328#issuecomment-2145849441 Clang attaches `DW_AT_declaration` to static inline data members and `dsymutil` indexes these constants. Skipping these caused the expression evaluator to fail to find such constants when using DWARFv5. Fixes `TestConstStaticIntegralMember.py` on DWARFv5.
2024-05-29[lldb/DWARF] Bypass the compres^Wconstruction of DIERefs in debug_names (#93296)Pavel Labath1-33/+25
DebugNamesDWARFIndex was jumping through hoops to construct a DIERef from an index entry only to jump through them back a short while later to construct a DWARFDIE. This used to be necessary as the index lookup was a two stage process, where we first enumerated all matches, and then examined them (so it was important that the enumeration was cheap -- does not trigger unnecessary parsing). However, now that the processing is callback based, we are always immediately examining the DWARFDIE right after finding the entry, and the DIERef just gets in the way.
2024-05-28 Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching ↵Zequan Wu1-0/+4
when parsing declaration DIEs. (#92328) This reapplies https://github.com/llvm/llvm-project/commit/9a7262c2601874e5aa64c5db19746770212d4b44 (#90663) and added https://github.com/llvm/llvm-project/pull/91808 as a fix. It was causing tests on macos to fail because `SymbolFileDWARF::GetForwardDeclCompilerTypeToDIE` returned the map owned by this symol file. When there were two symbol files, two different maps were created for caching from compiler type to DIE even if they are for the same module. The solution is to do the same as `SymbolFileDWARF::GetUniqueDWARFASTTypeMap`: inquery SymbolFileDWARFDebugMap first to get the shared underlying SymbolFile so the map is shared among multiple SymbolFileDWARF.
2024-05-21[lldb] Clean up unused includes in DebugNamesDWARFIndexPavel Labath1-1/+1
2024-05-21[lldb/dwarf] Fix DW_IDX_parent processing for split dwarf (#92745)Pavel Labath1-11/+15
DWARFDebugInfo only knows how to resolve references in its own file, but in split dwarf, the index entries will refer to DIEs in the separate (DWO) file. To resolve the DIERef correctly we'd either need to go through the SymbolFileDWARF to get the full logic for resolving a DIERef, or use the fact that ToDIERef already looks up the correct unit while computing its result. This patch does the latter. This bug manifested itself in not being able to find type definitions for types in namespaces, so I've modified one of our type resolving test cases to run with debug_names, and added a namespaced class into it (it originally contained only a top-level class).
2024-02-13[lldb][DWARFIndex] Use IDX_parent to implement GetFullyQualifiedType query ↵Felipe de Azevedo Piovezan1-0/+103
(#79932) This commit changes DebugNamesDWARFIndex so that it now overrides `GetFullyQualifiedType` and attempts to use DW_IDX_parent, when available, to speed up such queries. When this type of information is not available, the base-class implementation is used. With this commit, we now achieve the 4x speedups reported in [1]. [1]: https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/38
2024-01-04[lldb][nfc] Mark function as const (#76974)Felipe de Azevedo Piovezan1-1/+1
This function has no mutable behavior
2023-11-28Add support for parsing type unit entries in .debug_names. (#72952)Greg Clayton1-5/+15
This is a follow up patch after .debug_names can now emit local type unit entries when we compile with type units + DWARF5 + .debug_names. The pull request that added this functionality was: https://github.com/llvm/llvm-project/pull/70515 This patch makes sure that the DebugNamesDWARFIndex in LLDB will not manually need to parse type units if they have a valid index. It also fixes the index to be able to correctly extract name entries that reference type unit DIEs. Added a test to verify things work as expected.
2023-10-25Improve debug names index fetching global variables performance (#70231)jeffreytan811-2/+13
While using dwarf5 `.debug_names` in internal large targets, we noticed a performance issue (around 10 seconds delay) while `lldb-vscode` tries to show `scopes` for a compile unit. Profiling shows the bottleneck is inside `DebugNamesDWARFIndex::GetGlobalVariables` which linearly search all index entries belongs to a compile unit. This patch improves the performance by using the compile units list to filter first before checking index entries. This significantly improves the performance (drops from 10 seconds => under 1 second) in the split dwarf situation because each compile unit has its own named index. --------- Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2023-10-13[LLDB][NFC] Create a namespace for the DWARF plugin (#68150)Walter Erquinigo1-1/+2
As a followup of https://github.com/llvm/llvm-project/pull/67851, I'm defining a new namespace `lldb_plugin::dwarf` for the classes in this Plugins/SymbolFile/DWARF folder. This change is very NFC and helped me with exporting the necessary symbols for my out-of-tree language plugin. The only class that I didn't change is ClangDWARFASTParser, because that shouldn't be in the same namespace as the generic language-agnostic dwarf parser. It would be a good idea if other plugins follow the same namespace scheme.
2023-07-08[lldb] Consider TAG_imported_declaration in DebugNamesIndexFelipe de Azevedo Piovezan1-1/+3
In order to recognize namespace aliases as a namespace, the DW_TAG_imported_declaration has to be taken into account. The name of these DIEs is already included in all accelerator tables as of D143397. Two of the three Index classes already handle this correctly: 1. ManualDWARFIndex (as of D143398) 2. AppleDWARFIndex works by default with D143397, since apple has a table dedicated to namespaces. This commit updates the third index class, DWARF 5's DebugNamesDWARFIndex. As a result, it fixes the following test with DWARF 5: commands/expression/namespace-alias/TestInlineNamespaceAlias.py Differential Revision: https://reviews.llvm.org/D154730
2023-07-06[lldb][DebugNamesDWARF] Also use mangled name when matching regexFelipe de Azevedo Piovezan1-1/+2
When LLDB queries the debug names index with a regex, we should use the `Mangled` class wrapper, which attempts to match regex first against the mangled name and then against the demangled name. It is important to do so, otherwise queries like `frame var --regex A::` would never work. This is what is done for the Apple index as well. This fixes test/API/lang/cpp/class_static/main.cpp when compiled with DWARF 5. Differential Revision: https://reviews.llvm.org/D154617
2023-07-06[lldb][NFC] Remove unused parameter from DebugNames::ProcessEntryFelipe de Azevedo Piovezan1-11/+8
Differential Revision: https://reviews.llvm.org/D154610
2023-06-27[lldb][NFC] Prevent slicing when converting DataExtractorsFelipe de Azevedo Piovezan1-2/+2
LLDB's implementation of DWARFDataExtractor has a method that returns a llvm::DWARFDataExtractor. In some cases, like DebugNamesDWARFIndex::Create, we were passing an LLVM::DWARFDataExtractor to a function that expects a LLVM:DataExtractor by value. This is causing slicing of the derived class. While slicing is not inherently bad, it can be dangerous if the constructor of the derived class mutates the base class in a way that leaves it in an invalid state after slicing. Differential Revision: https://reviews.llvm.org/D153913
2023-06-14[lldb] Remove lldbassert from DebugNamesDWARFIndex::GetGlobalVariablesJonas Devlieghere1-1/+0
34a8e6eee666 changed SymbolFileDWARF::GetDwoNum to SymbolFileDWARF::GetFileIndex but changed the meaning from just DWO to DWO and OSO which changed the meaning of the assert. The assert was therefore removed from ManualDWARFIndex::GetGlobalVariables and ManualDWARFIndex::GetGlobalVariables but was still present in DebugNamesDWARFIndex::GetGlobalVariables. If we want to reintroduce the assert, we need something with the old semantics for all 3.
2023-02-22[LLDB] Enable 64 bit debug/type offsetAlexander Yermolovich1-2/+2
This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 With big binaries we can have .dwp files where .debug_info.dwo section can grow beyond 4GB. We would like to support this in LLVM and in LLDB. The plan is to enable manual parsing of cu/tu index in DWARF library (https://reviews.llvm.org/D137882), and then switch internal index data structure to 64 bit. For the second part is to enable 64bit offset support in LLDB with this patch. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D138618
2023-02-16Revert "[LLDB] Enable 64 bit debug/type offset"Alexander Yermolovich1-2/+2
This reverts commit 2062e90aa531e8445e5dc0e16222c0f246af1bf4.
2023-02-16[LLDB] Enable 64 bit debug/type offsetAlexander Yermolovich1-2/+2
This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 With big binaries we can have .dwp files where .debug_info.dwo section can grow beyond 4GB. We would like to support this in LLVM and in LLDB. The plan is to enable manual parsing of cu/tu index in DWARF library (https://reviews.llvm.org/D137882), and then switch internal index data structure to 64 bit. For the second part is to enable 64bit offset support in LLDB with this patch. Depends on D139955 Reviewed By: labath Differential Revision: https://reviews.llvm.org/D138618
2023-02-13Revert "[LLDB] Enable 64 bit debug/type offset"Alexander Yermolovich1-2/+2
This reverts commit f36fe009c0fc1d655bfc6168730bedfa1b36e622.
2023-02-13[LLDB] Enable 64 bit debug/type offsetAlexander Yermolovich1-2/+2
This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 With big binaries we can have .dwp files where .debug_info.dwo section can grow beyond 4GB. We would like to support this in LLVM and in LLDB. The plan is to enable manual parsing of cu/tu index in DWARF library (https://reviews.llvm.org/D137882), and then switch internal index data structure to 64 bit. For the second part is to enable 64bit offset support in LLDB with this patch. Depends on D139955 Reviewed By: labath Differential Revision: https://reviews.llvm.org/D138618
2023-01-07[lldb] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-4/+4
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-07[lldb] Add #include <optional> (NFC)Kazu Hirata1-0/+1
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-04[lldb] Use std::nullopt instead of None (NFC)Kazu Hirata1-3/+3
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-05[DebugInfo] llvm::Optional => std::optionalFangrui Song1-2/+2
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-08-04Re-submit "[lldb] Filter DIEs based on qualified name where possible"Alex Langford1-7/+6
This reverts commit 967df65a3610f98a3bc0ec0f2303641d7bad176c. This fixes test/Shell/SymbolFile/NativePDB/find-functions.cpp. When looking up functions with the PDB plugins, if we are looking for a full function name, we should use `GetName` to populate the `name` field instead of `GetLookupName` since `GetName` has the more complete information.
2022-08-04Revert "[lldb] Filter DIEs based on qualified name where possible"Alex Langford1-6/+7
This reverts commit befa77e59a7760d8c4fdd177b234e4a59500f61c. Looks like this broke a SymbolFileNativePDB test. I'll investigate and resubmit with a fix soon.
2022-08-04[lldb] Filter DIEs based on qualified name where possibleAlex Langford1-7/+6
Context: When setting a breakpoint by name, we invoke Module::FindFunctions to find the function(s) in question. However, we use a Module::LookupInfo to first process the user-provided name and figure out exactly what we're looking for. When we actually perform the function lookup, we search for the basename. After performing the search, we then filter out the results using Module::LookupInfo::Prune. For example, given a::b::foo we would first search for all instances of foo and then filter out the results to just names that have a::b::foo in them. As one can imagine, this involves a lot of debug info processing that we do not necessarily need to be doing. Instead of doing one large post-processing step after finding each instance of `foo`, we can filter them as we go to save time. Some numbers: Debugging LLDB and placing a breakpoint on llvm::itanium_demangle::StringView::begin without this change takes approximately 70 seconds and resolves 31,920 DIEs. With this change, placing the breakpoint takes around 30 seconds and resolves 8 DIEs. Differential Revision: https://reviews.llvm.org/D129682
2022-04-26Introduce new symbol on-demand for debug infoJeffrey Tan1-2/+2
This diff introduces a new symbol on-demand which skips loading a module's debug info unless explicitly asked on demand. This provides significant performance improvement for application with dynamic linking mode which has large number of modules. The feature can be turned on with: "settings set symbols.load-on-demand true" The feature works by creating a new SymbolFileOnDemand class for each module which wraps the actual SymbolFIle subclass as member variable. By default, most virtual methods on SymbolFileOnDemand are skipped so that it looks like there is no debug info for that module. But once the module's debug info is explicitly requested to be enabled (in the conditions mentioned below) SymbolFileOnDemand will allow all methods to pass through and forward to the actual SymbolFile which would hydrate module's debug info on-demand. In an internal benchmark, we are seeing more than 95% improvement for a 3000 modules application. Currently we are providing several ways to on demand hydrate a module's debug info: * Source line breakpoint: matching in supported files * Stack trace: resolving symbol context for an address * Symbolic breakpoint: symbol table match guided promotion * Global variable: symbol table match guided promotion In all above situations the module's debug info will be on-demand parsed and indexed. Some follow-ups for this feature: * Add a command that allows users to load debug info explicitly while using a new or existing command when this feature is enabled * Add settings for "never load any of these executables in Symbols On Demand" that takes a list of globs * Add settings for "always load the the debug info for executables in Symbols On Demand" that takes a list of globs * Add a new column in "image list" that shows up by default when Symbols On Demand is enable to show the status for each shlib like "not enabled for this", "debug info off" and "debug info on" (with a single character to short string, not the ones I just typed) Differential Revision: https://reviews.llvm.org/D121631
2022-03-03[LLDB] Remove cases of using namespace llvm:: from header fileShafik Yaghmour1-0/+1
We have using namespace llvm::dwarf in dwarf.h header globally. Replacing that with a using namespace within lldb_private::dwarf and moving to a using namespace lldb_private::dwarf in .cpp files and fully qualified names in the few header files. Differential Revision: https://reviews.llvm.org/D120836
2022-01-28[lldb] Convert DWARF log to the new APIPavel Labath1-1/+1
This also deletes some dead log statements (log initialization commented out).
2021-08-10[nfc] [lldb] Assertions for D106270 - [DWARF5] Fix offset check when using ↵Jan Kratochvil1-0/+1
.debug_names Skeleton vs. DWO units mismatch has been fixed in D106270. As they both have type DWARFUnit it is a bit difficult to debug. So it is better to make it safe against future changes. Reviewed By: kimanh, clayborg Differential Revision: https://reviews.llvm.org/D107659
2021-08-09[DWARF5] Fix offset check when using .debug_namesKim-Anh Tran1-1/+1
When going through the CU entries in the name index, make sure to compare the name entry's CU offset against the skeleton CU's offset. Previously there would be a mismatch, since the wrong offset was compared, and thus no suitable entry was found. Reviewed By: jankratochvil Differential Revision: https://reviews.llvm.org/D106270
2021-07-29[DWARF5] Only fallback to manual index if no entry was foundKim-Anh Tran1-2/+6
If we succeed at gathering global variables for a compile unit, there is no need to fallback to generating a manual index. Reviewed By: jankratochvil Differential Revision: https://reviews.llvm.org/D106355