summaryrefslogtreecommitdiffstats
path: root/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lldb][NFC] Remove ClangExternalASTSourceCommonRaphael Isemann2019-12-241-34/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | ClangExternalASTSourceCommon's purpose is to store a map from Decl*/Type* to ClangASTMetadata. Usually this data is accessed via the ClangASTContext interface which then grabs the current ExternalASTSource of its ASTContext, tries to cast it to ClangExternalASTSourceCommon and then accesses the metadata map. If the casting fails the setter does nothing and the getter returns a nullptr as if there was no known metadata for a type/decl. This system breaks as soon as any non-LLDB ExternalASTSource is added via a multiplexer to our existing ExternalASTSource (in which case we suddenly loose all out metadata as the casting always fails with an ExternalASTSource that is not inheriting from ClangExternalASTSourceCommon). This patch moves the metadata map to the ClangASTContext. This gets rid of all the fragile casting, the requirement that every ExternalASTSource in LLDB has to inherit from ClangExternalASTSourceCommon and simplifies the metadata implementation to a simple map lookup. As ClangExternalASTSourceCommon had no other purpose than storing metadata, this patch deletes this class and replaces all uses with clang::ExternalASTSource. No other code changes in this commit beside the AppleObjCDeclVendor which was the only code that did not use the ClangASTContext interface but directly accessed the ClangExternalASTSourceCommon.
* [lldb][NFC] Move definition of ClangASTMetadata out of ↵Raphael Isemann2019-12-161-23/+0
| | | | | | | | | | ClangExternalASTSourceCommon.h Changing metadata of a ClangASTContext currently requires to include the unrelated ClangExternalASTSourceCommon.h header because it actually defines the ClangASTMetadata class. This also removes the dependency from ClangASTImporter to ClangExternalASTSourceCommon.
* [lldb] Remove RTTI in ClangExternalASTSourceCommon based on a global map of ↵Raphael Isemann2019-12-151-36/+2
| | | | | | | | | | | | | | | | | | | | | | known instances Summary: Currently we do our RTTI check for ClangExternalASTSourceCommon by using this global map of ClangExternalASTSourceCommon where every instance is registering and deregistering itself on creation/destruction. Then we can do the RTTI check by looking up in this map from ClangASTContext. This patch removes this whole thing and just adds LLVM-style RTTI support to ClangExternalASTSourceCommon which is possible with D71397. Reviewers: labath, aprantl Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71398
* [lldb][NFC] Make metadata tracking type safeRaphael Isemann2019-12-131-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: LLDB associates additional information with Types and Declarations which it calls ClangASTMetadata. ClangASTMetadata is stored by the ClangASTSourceCommon which is implemented by having a large map of `void *` keys to associated `ClangASTMetadata` values. To make this whole mechanism even unsafer we also decided to use `clang::Decl *` as one of pointers we throw in there (beside `clang::Type *`). The Decl class hierarchy uses multiple inheritance which means that not all pointers have the same address when they are implicitly converted to pointers of their parent classes. For example `clang::Decl *` and `clang::DeclContext *` won't end up being the same address when they are implicitly converted from one of the many Decl-subclasses that inherit from both. As we use the addresses as the keys in our Metadata map, this means that any implicit type conversions to parent classes (or anything else that changes the addresses) will break our metadata tracking in obscure ways. Just to illustrate how broken this whole mechanism currently is: ```lang=cpp // m_ast is our ClangASTContext. Let's double check that from GetTranslationUnitDecl // in ClangASTContext and ASTContext return the same thing (one method just calls the other). assert(m_ast->GetTranslationUnitDecl() == m_ast->getASTContext()->getTranslationUnitDecl()); // Ok, both methods have the same TU*. Let's store metadata with the result of one method call. m_ast->SetMetadataAsUserID(m_ast->GetTranslationUnitDecl(), 1234U); // Retrieve the same Metadata for the TU by using the TU* from the other method... which fails? EXPECT_EQ(m_ast->GetMetadata(m_ast->getASTContext()->getTranslationUnitDecl())->GetUserID(), 1234U); // Turns out that getTranslationUnitDecl one time returns a TranslationUnitDecl* but the other time // we return one of the parent classes of TranslationUnitDecl (DeclContext). ``` This patch splits up the `void *` API into two where one does the `clang::Type *` tracking and one the `clang::Decl *` mapping. Type and Decl are disjoint class hierarchies so there is no implicit conversion possible that could influence the address values. I had to change the storing of `clang::QualType` opaque pointers to their `clang::Type *` equivalents as opaque pointers are already `void *` pointers to begin with. We don't seem to ever set any qualifier in any of these QualTypes to this conversion should be NFC. Reviewers: labath, shafik, aprantl Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71409
* [lldb] Don't search the metadata map three times when retrieving metadataRaphael Isemann2019-12-111-6/+3
| | | | | | HasMetadata checks if our metadata map knows the given object. GetMetadata also does this check and then does another search to actually retrieve the value. This can all just be one lookup.
* [lldb][NFC] Remove ClangExternalASTSourceCommon::g_TotalSizeOfMetadataRaphael Isemann2019-12-111-7/+0
| | | | Turns out this counter is doing literally nothing beside counting.
* [lldb][NFC] Make g_TotalSizeOfMetadata in ClangExternalASTSourceCommon.cpp ↵Raphael Isemann2019-12-101-1/+1
| | | | | | static Clang was warning that this global should be static (which makes sense).
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [TypeSystem] Guard the global `ASTSourceMap` with a mutexSean Callanan2017-07-251-4/+12
| | | | | | | | | | | | | | | | | s_source_map in ClangExternalASTSourceCommon.cpp is unguarded and therefore can break in multithreaded conditions. This can cause crashes in particular if multiple targets are being set up at once. This patch wraps s_source_map in a function that ensures exclusivity, and makes every user of it use that function instead. <rdar://problem/33429774> lldb crashes after "resume_off" Differential Revision: https://reviews.llvm.org/D35083 llvm-svn: 308993
* Move classes from Core -> Utility.Zachary Turner2017-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This moves the following classes from Core -> Utility. ConstString Error RegularExpression Stream StreamString The goal here is to get lldbUtility into a state where it has no dependendencies except on itself and LLVM, so it can be the starting point at which to start untangling LLDB's dependencies. These are all low level and very widely used classes, and previously lldbUtility had dependencies up to lldbCore in order to use these classes. So moving then down to lldbUtility makes sense from both the short term and long term perspective in solving this problem. Differential Revision: https://reviews.llvm.org/D29427 llvm-svn: 293941
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-73/+58
| | | | | | | | | | | | | | | | | | | | | | | *** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
* second pass over removal of Mutex and ConditionSaleem Abdulrasool2016-05-191-1/+0
| | | | llvm-svn: 270024
* Intentionally leak the ASTSourceMap instead of destroying it when LLDB quits.Sean Callanan2016-05-041-2/+3
| | | | | | <rdar://problem/25959792> llvm-svn: 268559
* Fixed an unfortunate reversed conditional thatSean Callanan2014-12-061-1/+1
| | | | | | resulted in hard-to-track-down crashes. Sigh. llvm-svn: 223575
* Now that we get types from modules, we occasionallySean Callanan2014-12-061-10/+28
| | | | | | | | | | encounter clang::ExternalASTSources that are not instances of ClangExternalASTSourceCommon. We used to blithely assume that all are, and so we could use static_cast<>. That's no longer the case, so we have to have these AST sources register themselves. llvm-svn: 223560
* Switch NULL to C++11 nullptr in source/Symbol and source/UtilityEd Maste2014-04-201-1/+1
| | | | | | Patch by Robert Matusewicz llvm-svn: 206713
* Don't use a "uintptr_t" for the metadata key, use a "void *". This removes ↵Greg Clayton2013-03-271-3/+34
| | | | | | all of the casts that were being used and cleans the code up a bit. Also added the ability to dump the metadata. llvm-svn: 178113
* This is the first phase of supporting the DW_AT_object_pointer tag. I ↵Jim Ingham2012-10-271-4/+10
| | | | | | | | | | expanded the decl metadata so it could hold this information, and then used it to look up unfound names in the object pointer if it exists. This gets "frame var" to work for unqualified references to ivars captured in blocks. But the expression parser is ignoring this information still. llvm-svn: 166860
* Added a mechanism for keeping track of where inSean Callanan2012-04-131-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the debug information individual Decls came from. We've had a metadata infrastructure for a while, which was intended to solve a problem we've since dealt with in a different way. (It was meant to keep track of which definition of an Objective-C class was the "true" definition, but we now find it by searching the symbols for the class symbol.) The metadata is attached to the ExternalASTSource, which means it has a one-to-one correspondence with AST contexts. I've repurposed the metadata infrastructure to hold the object file and DIE offset for the DWARF information corresponding to a Decl. There are methods in ClangASTContext that get and set this metadata, and the ClangASTImporter is capable of tracking down the metadata for Decls that have been copied out of the debug information into the parser's AST context without using any additional memory. To see the metadata, you just have to enable the expression log: - (lldb) log enable lldb expr - and watch the import messages. The high 32 bits of the metadata indicate the index of the object file in its containing DWARFDebugMap; I have also added a log which you can use to track that mapping: - (lldb) log enable dwarf map - This adds 64 bits per Decl, which in my testing hasn't turned out to be very much (debugging Clang produces around 6500 Decls in my tests). To track how much data is being consumed, I've also added a global variable g_TotalSizeOfMetadata which tracks the total number of Decls that have metadata in all active AST contexts. Right now this metadata is enormously useful for tracking down bugs in the debug info parser. In the future I also want to use this information to provide more intelligent error messages instead of printing empty source lines wherever Clang refers to the location where something is defined. llvm-svn: 154634
* Added the ability for clients to grab a set of symbol table indexes and thenGreg Clayton2011-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add them to a fast lookup map. lldb_private::Symtab now export the following public typedefs: namespace lldb_private { class Symtab { typedef std::vector<uint32_t> IndexCollection; typedef UniqueCStringMap<uint32_t> NameToIndexMap; }; } Clients can then find symbols by name and or type and end up with a Symtab::IndexCollection that is filled with indexes. These indexes can then be put into a name to index lookup map and control if the mangled and demangled names get added to the map: bool add_demangled = true; bool add_mangled = true; Symtab::NameToIndexMap name_to_index; symtab->AppendSymbolNamesToMap (indexes, add_demangled, add_mangled, name_to_index). This can be repeated as many times as needed to get a lookup table that you are happy with, and then this can be sorted: name_to_index.Sort(); Now name lookups can be done using a subset of the symbols you extracted from the symbol table. This is currently being used to extract objective C types from object files when there is no debug info in SymbolFileSymtab. Cleaned up how the objective C types were being vended to be more efficient and fixed some errors in the regular expression that was being used. llvm-svn: 145777
* Added ClangExternalASTSourceCommon, a local superclassSean Callanan2011-12-031-0/+40
for all our external AST sources that lets us associate arbitrary flags with the types we put into the AST contexts. Also added an API on ClangASTContext that allows access to these flags given only an ASTContext and a type. Because we don't have access to RTTI, and because at some point in the future we might encounter external AST sources that we didn't make (so they don't subclass ClangExternalASTSourceCommon) I added a magic number that we check before doing anything else, so that we can catch that problem as soon as it appears. llvm-svn: 145748
OpenPOWER on IntegriCloud