diff options
Diffstat (limited to 'include/lldb/Target/ObjCLanguageRuntime.h')
-rw-r--r-- | include/lldb/Target/ObjCLanguageRuntime.h | 269 |
1 files changed, 43 insertions, 226 deletions
diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/include/lldb/Target/ObjCLanguageRuntime.h index 88874c767a1b..75f096fdedfe 100644 --- a/include/lldb/Target/ObjCLanguageRuntime.h +++ b/include/lldb/Target/ObjCLanguageRuntime.h @@ -1,4 +1,4 @@ -//===-- ObjCLanguageRuntime.h ---------------------------------------------------*- C++ -*-===// +//===-- ObjCLanguageRuntime.h -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,14 +14,17 @@ // C++ Includes #include <functional> #include <map> +#include <memory> #include <unordered_set> // Other libraries and framework includes +#include "llvm/Support/Casting.h" + // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Core/ThreadSafeDenseMap.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/DeclVendor.h" #include "lldb/Symbol/Type.h" #include "lldb/Target/LanguageRuntime.h" @@ -30,115 +33,19 @@ class CommandObjectObjC_ClassTable_Dump; namespace lldb_private { -class ClangUtilityFunction; +class UtilityFunction; class ObjCLanguageRuntime : public LanguageRuntime { public: - class MethodName + enum class ObjCRuntimeVersions { - public: - enum Type - { - eTypeUnspecified, - eTypeClassMethod, - eTypeInstanceMethod - }; - - MethodName () : - m_full(), - m_class(), - m_category(), - m_selector(), - m_type (eTypeUnspecified), - m_category_is_valid (false) - { - } - - MethodName (const char *name, bool strict) : - m_full(), - m_class(), - m_category(), - m_selector(), - m_type (eTypeUnspecified), - m_category_is_valid (false) - { - SetName (name, strict); - } - - void - Clear(); - - bool - IsValid (bool strict) const - { - // If "strict" is true, the name must have everything specified including - // the leading "+" or "-" on the method name - if (strict && m_type == eTypeUnspecified) - return false; - // Other than that, m_full will only be filled in if the objective C - // name is valid. - return (bool)m_full; - } - - bool - HasCategory() - { - return (bool)GetCategory(); - } - - Type - GetType () const - { - return m_type; - } - - const ConstString & - GetFullName () const - { - return m_full; - } - - ConstString - GetFullNameWithoutCategory (bool empty_if_no_category); - - bool - SetName (const char *name, bool strict); - - const ConstString & - GetClassName (); - - const ConstString & - GetClassNameWithCategory (); - - const ConstString & - GetCategory (); - - const ConstString & - GetSelector (); - - // Get all possible names for a method. Examples: - // If name is "+[NSString(my_additions) myStringWithCString:]" - // names[0] => "+[NSString(my_additions) myStringWithCString:]" - // names[1] => "+[NSString myStringWithCString:]" - // If name is specified without the leading '+' or '-' like "[NSString(my_additions) myStringWithCString:]" - // names[0] => "+[NSString(my_additions) myStringWithCString:]" - // names[1] => "-[NSString(my_additions) myStringWithCString:]" - // names[2] => "+[NSString myStringWithCString:]" - // names[3] => "-[NSString myStringWithCString:]" - size_t - GetFullNames (std::vector<ConstString> &names, bool append); - protected: - ConstString m_full; // Full name: "+[NSString(my_additions) myStringWithCString:]" - ConstString m_class; // Class name: "NSString" - ConstString m_class_category; // Class with category: "NSString(my_additions)" - ConstString m_category; // Category: "my_additions" - ConstString m_selector; // Selector: "myStringWithCString:" - Type m_type; - bool m_category_is_valid; - + eObjC_VersionUnknown = 0, + eAppleObjC_V1 = 1, + eAppleObjC_V2 = 2 }; + typedef lldb::addr_t ObjCISA; class ClassDescriptor; @@ -150,7 +57,6 @@ public: class ClassDescriptor { public: - ClassDescriptor() : m_is_kvo (eLazyBoolCalculate), m_is_cf (eLazyBoolCalculate), @@ -159,10 +65,8 @@ public: } virtual - ~ClassDescriptor () - { - } - + ~ClassDescriptor() = default; + virtual ConstString GetClassName () = 0; @@ -203,12 +107,12 @@ public: virtual bool IsValid () = 0; - + virtual bool - GetTaggedPointerInfo (uint64_t* info_bits = NULL, - uint64_t* value_bits = NULL, - uint64_t* payload = NULL) = 0; - + GetTaggedPointerInfo(uint64_t* info_bits = nullptr, + uint64_t* value_bits = nullptr, + uint64_t* payload = nullptr) = 0; + virtual uint64_t GetInstanceSize () = 0; @@ -247,7 +151,7 @@ public: struct iVarDescriptor { ConstString m_name; - ClangASTType m_type; + CompilerType m_type; uint64_t m_size; int32_t m_offset; }; @@ -281,12 +185,12 @@ public: class EncodingToType { public: - virtual ClangASTType RealizeType (ClangASTContext& ast_ctx, const char* name, bool for_expression); - virtual ClangASTType RealizeType (const char* name, bool for_expression); - - virtual ClangASTType RealizeType (clang::ASTContext& ast_ctx, const char* name, bool for_expression) = 0; - virtual ~EncodingToType(); + + virtual CompilerType RealizeType (ClangASTContext& ast_ctx, const char* name, bool for_expression); + virtual CompilerType RealizeType (const char* name, bool for_expression); + + virtual CompilerType RealizeType (clang::ASTContext& ast_ctx, const char* name, bool for_expression) = 0; protected: std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_ap; @@ -297,10 +201,10 @@ public: public: ObjCExceptionPrecondition(); - virtual ~ObjCExceptionPrecondition() {} + ~ObjCExceptionPrecondition() override = default; bool EvaluatePrecondition(StoppointCallbackContext &context) override; - void DescribePrecondition(Stream &stream, lldb::DescriptionLevel level) override; + void GetDescription(Stream &stream, lldb::DescriptionLevel level) override; Error ConfigurePrecondition(Args &args) override; protected: @@ -313,21 +217,24 @@ public: class TaggedPointerVendor { public: + virtual + ~TaggedPointerVendor() = default; + virtual bool IsPossibleTaggedPointer (lldb::addr_t ptr) = 0; virtual ObjCLanguageRuntime::ClassDescriptorSP GetClassDescriptor (lldb::addr_t ptr) = 0; - - virtual - ~TaggedPointerVendor () { } + protected: - TaggedPointerVendor () = default; + TaggedPointerVendor() = default; private: DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendor); }; + ~ObjCLanguageRuntime() override; + virtual TaggedPointerVendor* GetTaggedPointerVendor () { @@ -354,9 +261,6 @@ public: ClassDescriptorSP GetNonKVOClassDescriptor (ObjCISA isa); - virtual - ~ObjCLanguageRuntime(); - lldb::LanguageType GetLanguageType () const override { @@ -393,13 +297,13 @@ public: lldb::TypeSP LookupInCompleteClassCache (ConstString &name); - virtual ClangUtilityFunction * + virtual UtilityFunction * CreateObjectChecker (const char *) = 0; virtual ObjCRuntimeVersions - GetRuntimeVersion () + GetRuntimeVersion () const { - return eObjC_VersionUnknown; + return ObjCRuntimeVersions::eObjC_VersionUnknown; } bool @@ -433,14 +337,14 @@ public: virtual DeclVendor * GetDeclVendor() { - return NULL; + return nullptr; } // Finds the byte offset of the child_type ivar in parent_type. If it can't find the // offset, returns LLDB_INVALID_IVAR_OFFSET. virtual size_t - GetByteOffsetForIvar (ClangASTType &parent_qual_type, const char *ivar_name); + GetByteOffsetForIvar (CompilerType &parent_qual_type, const char *ivar_name); // Given the name of an Objective-C runtime symbol (e.g., ivar offset symbol), // try to determine from the runtime what the value of that symbol would be. @@ -451,94 +355,6 @@ public: return LLDB_INVALID_ADDRESS; } - //------------------------------------------------------------------ - /// Chop up an objective C function prototype. - /// - /// Chop up an objective C function fullname and optionally fill in - /// any non-NULL ConstString objects. If a ConstString * is NULL, - /// then this name doesn't get filled in - /// - /// @param[in] name - /// A fully specified objective C function name. The string might - /// contain a category and it includes the leading "+" or "-" and - /// the square brackets, no types for the arguments, just the plain - /// selector. A few examples: - /// "-[NSStringDrawingContext init]" - /// "-[NSStringDrawingContext addString:inRect:]" - /// "-[NSString(NSStringDrawing) sizeWithAttributes:]" - /// "+[NSString(NSStringDrawing) usesFontLeading]" - /// - /// @param[out] class_name - /// If non-NULL, this string will be filled in with the class - /// name including the category. The examples above would return: - /// "NSStringDrawingContext" - /// "NSStringDrawingContext" - /// "NSString(NSStringDrawing)" - /// "NSString(NSStringDrawing)" - /// - /// @param[out] selector_name - /// If non-NULL, this string will be filled in with the selector - /// name. The examples above would return: - /// "init" - /// "addString:inRect:" - /// "sizeWithAttributes:" - /// "usesFontLeading" - /// - /// @param[out] name_sans_category - /// If non-NULL, this string will be filled in with the class - /// name _without_ the category. If there is no category, and empty - /// string will be returned (as the result would be normally returned - /// in the "class_name" argument). The examples above would return: - /// <empty> - /// <empty> - /// "-[NSString sizeWithAttributes:]" - /// "+[NSString usesFontLeading]" - /// - /// @param[out] class_name_sans_category - /// If non-NULL, this string will be filled in with the prototype - /// name _without_ the category. If there is no category, and empty - /// string will be returned (as this is already the value that was - /// passed in). The examples above would return: - /// <empty> - /// <empty> - /// "NSString" - /// "NSString" - /// - /// @return - /// Returns the number of strings that were successfully filled - /// in. - //------------------------------------------------------------------ -// static uint32_t -// ParseMethodName (const char *name, -// ConstString *class_name, // Class name (with category if there is one) -// ConstString *selector_name, // selector only -// ConstString *name_sans_category, // full function name with no category (empty if no category) -// ConstString *class_name_sans_category);// Class name without category (empty if no category) - - static bool - IsPossibleObjCMethodName (const char *name) - { - if (!name) - return false; - bool starts_right = (name[0] == '+' || name[0] == '-') && name[1] == '['; - bool ends_right = (name[strlen(name) - 1] == ']'); - return (starts_right && ends_right); - } - - static bool - IsPossibleObjCSelector (const char *name) - { - if (!name) - return false; - - if (strchr(name, ':') == NULL) - return true; - else if (name[strlen(name) - 1] == ':') - return true; - else - return false; - } - bool HasNewLiteralsAndIndexing () { @@ -560,7 +376,7 @@ public: } bool - GetTypeBitSize (const ClangASTType& clang_type, + GetTypeBitSize (const CompilerType& compiler_type, uint64_t &size) override; protected: @@ -568,13 +384,12 @@ protected: // Classes that inherit from ObjCLanguageRuntime can see and modify these //------------------------------------------------------------------ ObjCLanguageRuntime(Process *process); - + virtual bool CalculateHasNewLiteralsAndIndexing() { return false; } - bool ISAIsCached (ObjCISA isa) const { @@ -621,11 +436,13 @@ private: sel_addr = LLDB_INVALID_ADDRESS; class_addr = LLDB_INVALID_ADDRESS; } + ClassAndSel (lldb::addr_t in_sel_addr, lldb::addr_t in_class_addr) : class_addr (in_class_addr), sel_addr(in_sel_addr) { } + bool operator== (const ClassAndSel &rhs) { if (class_addr == rhs.class_addr @@ -702,4 +519,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ObjCLanguageRuntime_h_ +#endif // liblldb_ObjCLanguageRuntime_h_ |