2015-10-30 04:33:47 +08:00
|
|
|
//===-- ObjCLanguageRuntime.h -----------------------------------*- C++ -*-===//
|
2010-09-23 10:01:19 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-09-23 10:01:19 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-02-18 07:57:45 +08:00
|
|
|
#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_OBJCLANGUAGERUNTIME_H
|
|
|
|
#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_OBJCLANGUAGERUNTIME_H
|
2010-09-23 10:01:19 +08:00
|
|
|
|
2012-09-21 01:01:52 +08:00
|
|
|
#include <functional>
|
2010-09-28 09:25:32 +08:00
|
|
|
#include <map>
|
2015-10-30 04:33:47 +08:00
|
|
|
#include <memory>
|
2013-04-06 02:49:06 +08:00
|
|
|
#include <unordered_set>
|
2010-09-28 09:25:32 +08:00
|
|
|
|
2015-10-30 04:33:47 +08:00
|
|
|
#include "llvm/Support/Casting.h"
|
|
|
|
|
2019-06-22 03:43:07 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointPrecondition.h"
|
2010-09-28 09:25:32 +08:00
|
|
|
#include "lldb/Core/PluginInterface.h"
|
2015-01-28 08:45:42 +08:00
|
|
|
#include "lldb/Core/ThreadSafeDenseMap.h"
|
2015-08-12 06:53:00 +08:00
|
|
|
#include "lldb/Symbol/CompilerType.h"
|
2012-02-23 07:57:45 +08:00
|
|
|
#include "lldb/Symbol/Type.h"
|
2010-09-23 10:01:19 +08:00
|
|
|
#include "lldb/Target/LanguageRuntime.h"
|
|
|
|
#include "lldb/lldb-private.h"
|
|
|
|
|
2015-05-07 05:01:07 +08:00
|
|
|
class CommandObjectObjC_ClassTable_Dump;
|
|
|
|
|
2010-09-23 10:01:19 +08:00
|
|
|
namespace lldb_private {
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-02-04 07:55:18 +08:00
|
|
|
class TypeSystemClang;
|
2015-09-16 05:13:50 +08:00
|
|
|
class UtilityFunction;
|
2010-09-23 10:01:19 +08:00
|
|
|
|
|
|
|
class ObjCLanguageRuntime : public LanguageRuntime {
|
|
|
|
public:
|
2015-09-24 04:12:19 +08:00
|
|
|
enum class ObjCRuntimeVersions {
|
|
|
|
eObjC_VersionUnknown = 0,
|
|
|
|
eAppleObjC_V1 = 1,
|
|
|
|
eAppleObjC_V2 = 2
|
2013-04-19 06:45:39 +08:00
|
|
|
};
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-24 06:41:19 +08:00
|
|
|
typedef lldb::addr_t ObjCISA;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-05 02:47:54 +08:00
|
|
|
class ClassDescriptor;
|
2014-10-14 07:03:49 +08:00
|
|
|
typedef std::shared_ptr<ClassDescriptor> ClassDescriptorSP;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// the information that we want to support retrieving from an ObjC class this
|
|
|
|
// needs to be pure virtual since there are at least 2 different
|
|
|
|
// implementations of the runtime, and more might come
|
2012-09-05 02:47:54 +08:00
|
|
|
class ClassDescriptor {
|
2016-09-07 04:57:50 +08:00
|
|
|
public:
|
2012-09-25 07:30:10 +08:00
|
|
|
ClassDescriptor()
|
2012-09-05 02:47:54 +08:00
|
|
|
: m_is_kvo(eLazyBoolCalculate), m_is_cf(eLazyBoolCalculate),
|
|
|
|
m_type_wp() {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-05 02:47:54 +08:00
|
|
|
virtual ~ClassDescriptor() = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-05 02:47:54 +08:00
|
|
|
virtual ConstString GetClassName() = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-21 01:01:52 +08:00
|
|
|
virtual ClassDescriptorSP GetSuperclass() = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-08-20 05:46:37 +08:00
|
|
|
virtual ClassDescriptorSP GetMetaclass() const = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// virtual if any implementation has some other version-specific rules but
|
|
|
|
// for the known v1/v2 this is all that needs to be done
|
2012-09-05 02:47:54 +08:00
|
|
|
virtual bool IsKVO() {
|
|
|
|
if (m_is_kvo == eLazyBoolCalculate) {
|
2012-10-10 01:51:53 +08:00
|
|
|
const char *class_name = GetClassName().AsCString();
|
|
|
|
if (class_name && *class_name)
|
2012-09-05 02:47:54 +08:00
|
|
|
m_is_kvo =
|
2015-08-12 06:53:00 +08:00
|
|
|
(LazyBool)(strstr(class_name, "NSKVONotifying_") == class_name);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2015-08-12 06:53:00 +08:00
|
|
|
return (m_is_kvo == eLazyBoolYes);
|
2014-08-20 05:46:37 +08:00
|
|
|
}
|
2015-04-23 03:42:18 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// virtual if any implementation has some other version-specific rules but
|
|
|
|
// for the known v1/v2 this is all that needs to be done
|
2015-08-12 06:53:00 +08:00
|
|
|
virtual bool IsCFType() {
|
2012-09-05 02:47:54 +08:00
|
|
|
if (m_is_cf == eLazyBoolCalculate) {
|
2015-04-23 03:42:18 +08:00
|
|
|
const char *class_name = GetClassName().AsCString();
|
2012-09-25 07:30:10 +08:00
|
|
|
if (class_name && *class_name)
|
|
|
|
m_is_cf = (LazyBool)(strcmp(class_name, "__NSCFType") == 0 ||
|
|
|
|
strcmp(class_name, "NSCFType") == 0);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2015-04-23 03:42:18 +08:00
|
|
|
return (m_is_cf == eLazyBoolYes);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2015-04-23 03:42:18 +08:00
|
|
|
|
2015-10-30 04:33:47 +08:00
|
|
|
virtual bool IsValid() = 0;
|
2015-04-23 03:42:18 +08:00
|
|
|
|
|
|
|
virtual bool GetTaggedPointerInfo(uint64_t *info_bits = nullptr,
|
|
|
|
uint64_t *value_bits = nullptr,
|
2015-12-18 10:14:04 +08:00
|
|
|
uint64_t *payload = nullptr) = 0;
|
2015-04-23 03:42:18 +08:00
|
|
|
|
|
|
|
virtual uint64_t GetInstanceSize() = 0;
|
|
|
|
|
2015-05-14 08:46:47 +08:00
|
|
|
// use to implement version-specific additional constraints on pointers
|
|
|
|
virtual bool CheckPointer(lldb::addr_t value, uint32_t ptr_size) const {
|
2012-09-05 02:47:54 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-10-30 04:33:47 +08:00
|
|
|
virtual ObjCISA GetISA() = 0;
|
|
|
|
|
2015-05-14 08:46:47 +08:00
|
|
|
// This should return true iff the interface could be completed
|
|
|
|
virtual bool
|
|
|
|
Describe(std::function<void(ObjCISA)> const &superclass_func,
|
2014-08-21 00:54:11 +08:00
|
|
|
std::function<bool(const char *, const char *)> const
|
2015-05-14 08:46:47 +08:00
|
|
|
&instance_method_func,
|
2014-08-21 00:54:11 +08:00
|
|
|
std::function<bool(const char *, const char *)> const
|
2015-05-14 08:46:47 +08:00
|
|
|
&class_method_func,
|
|
|
|
std::function<bool(const char *, const char *, lldb::addr_t,
|
|
|
|
uint64_t)> const &ivar_func) const {
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2015-10-30 04:33:47 +08:00
|
|
|
|
|
|
|
lldb::TypeSP GetType() { return m_type_wp.lock(); }
|
2015-05-14 08:46:47 +08:00
|
|
|
|
|
|
|
void SetType(const lldb::TypeSP &type_sp) { m_type_wp = type_sp; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-05-14 08:46:47 +08:00
|
|
|
struct iVarDescriptor {
|
2014-08-20 05:46:37 +08:00
|
|
|
ConstString m_name;
|
2015-05-14 08:46:47 +08:00
|
|
|
CompilerType m_type;
|
|
|
|
uint64_t m_size;
|
2014-08-20 05:46:37 +08:00
|
|
|
int32_t m_offset;
|
2015-05-14 08:46:47 +08:00
|
|
|
};
|
2015-10-30 04:33:47 +08:00
|
|
|
|
2012-09-05 02:47:54 +08:00
|
|
|
virtual size_t GetNumIVars() { return 0; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-28 09:25:32 +08:00
|
|
|
virtual iVarDescriptor GetIVarAtIndex(size_t idx) {
|
2013-02-14 06:56:14 +08:00
|
|
|
return iVarDescriptor();
|
2012-09-14 05:11:40 +08:00
|
|
|
}
|
2012-10-12 02:07:21 +08:00
|
|
|
|
2012-09-05 02:47:54 +08:00
|
|
|
protected:
|
2012-10-26 00:54:22 +08:00
|
|
|
bool IsPointerValid(lldb::addr_t value, uint32_t ptr_size,
|
|
|
|
bool allow_NULLs = false, bool allow_tagged = false,
|
|
|
|
bool check_version_specific = false) const;
|
|
|
|
|
2012-09-14 05:11:40 +08:00
|
|
|
private:
|
2013-02-14 06:56:14 +08:00
|
|
|
LazyBool m_is_kvo;
|
|
|
|
LazyBool m_is_cf;
|
|
|
|
lldb::TypeWP m_type_wp;
|
2016-09-07 04:57:50 +08:00
|
|
|
};
|
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
class EncodingToType {
|
2016-09-07 04:57:50 +08:00
|
|
|
public:
|
2012-09-12 05:44:01 +08:00
|
|
|
virtual ~EncodingToType();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
[lldb][NFC] Rename ClangASTContext to TypeSystemClang
Summary:
This commit renames ClangASTContext to TypeSystemClang to better reflect what this class is actually supposed to do
(implement the TypeSystem interface for Clang). It also gets rid of the very confusing situation that we have both a
`clang::ASTContext` and a `ClangASTContext` in clang (which sometimes causes Clang people to think I'm fiddling
with Clang's ASTContext when I'm actually just doing LLDB work).
I also have plans to potentially have multiple clang::ASTContext instances associated with one ClangASTContext so
the ASTContext naming will then become even more confusing to people.
Reviewers: #lldb, aprantl, shafik, clayborg, labath, JDevlieghere, davide, espindola, jdoerfert, xiaobai
Reviewed By: clayborg, labath, xiaobai
Subscribers: wuzish, emaste, nemanjai, mgorny, kbarton, MaskRay, arphaman, jfb, usaxena95, jingham, xiaobai, abidh, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D72684
2020-01-23 17:04:13 +08:00
|
|
|
virtual CompilerType RealizeType(TypeSystemClang &ast_ctx, const char *name,
|
2019-12-26 21:52:43 +08:00
|
|
|
bool for_expression) = 0;
|
2012-09-12 05:44:01 +08:00
|
|
|
virtual CompilerType RealizeType(const char *name, bool for_expression);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-05 02:47:54 +08:00
|
|
|
protected:
|
[lldb][NFC] Rename ClangASTContext to TypeSystemClang
Summary:
This commit renames ClangASTContext to TypeSystemClang to better reflect what this class is actually supposed to do
(implement the TypeSystem interface for Clang). It also gets rid of the very confusing situation that we have both a
`clang::ASTContext` and a `ClangASTContext` in clang (which sometimes causes Clang people to think I'm fiddling
with Clang's ASTContext when I'm actually just doing LLDB work).
I also have plans to potentially have multiple clang::ASTContext instances associated with one ClangASTContext so
the ASTContext naming will then become even more confusing to people.
Reviewers: #lldb, aprantl, shafik, clayborg, labath, JDevlieghere, davide, espindola, jdoerfert, xiaobai
Reviewed By: clayborg, labath, xiaobai
Subscribers: wuzish, emaste, nemanjai, mgorny, kbarton, MaskRay, arphaman, jfb, usaxena95, jingham, xiaobai, abidh, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D72684
2020-01-23 17:04:13 +08:00
|
|
|
std::unique_ptr<TypeSystemClang> m_scratch_ast_ctx_up;
|
2016-09-07 04:57:50 +08:00
|
|
|
};
|
|
|
|
|
2019-06-22 03:43:07 +08:00
|
|
|
class ObjCExceptionPrecondition : public BreakpointPrecondition {
|
2016-09-07 04:57:50 +08:00
|
|
|
public:
|
2012-09-05 02:47:54 +08:00
|
|
|
ObjCExceptionPrecondition();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-30 04:33:47 +08:00
|
|
|
~ObjCExceptionPrecondition() override = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-04-23 03:42:18 +08:00
|
|
|
bool EvaluatePrecondition(StoppointCallbackContext &context) override;
|
2012-09-05 02:47:54 +08:00
|
|
|
void GetDescription(Stream &stream, lldb::DescriptionLevel level) override;
|
2017-05-12 12:51:55 +08:00
|
|
|
Status ConfigurePrecondition(Args &args) override;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-12-05 09:21:59 +08:00
|
|
|
protected:
|
|
|
|
void AddClassName(const char *class_name);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
private:
|
2015-04-23 03:42:18 +08:00
|
|
|
std::unordered_set<std::string> m_class_names;
|
2016-09-07 04:57:50 +08:00
|
|
|
};
|
|
|
|
|
2019-06-22 03:43:07 +08:00
|
|
|
static lldb::BreakpointPreconditionSP
|
|
|
|
GetBreakpointExceptionPrecondition(lldb::LanguageType language,
|
|
|
|
bool throw_bp);
|
|
|
|
|
2015-05-14 08:46:47 +08:00
|
|
|
class TaggedPointerVendor {
|
2016-09-07 04:57:50 +08:00
|
|
|
public:
|
2014-12-05 09:21:59 +08:00
|
|
|
virtual ~TaggedPointerVendor() = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-05-14 08:46:47 +08:00
|
|
|
virtual bool IsPossibleTaggedPointer(lldb::addr_t ptr) = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-12 02:07:21 +08:00
|
|
|
virtual ObjCLanguageRuntime::ClassDescriptorSP
|
2014-12-05 09:21:59 +08:00
|
|
|
GetClassDescriptor(lldb::addr_t ptr) = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-12-05 09:21:59 +08:00
|
|
|
protected:
|
|
|
|
TaggedPointerVendor() = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
private:
|
2015-05-14 08:46:47 +08:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendor);
|
2016-09-07 04:57:50 +08:00
|
|
|
};
|
|
|
|
|
2015-10-30 04:33:47 +08:00
|
|
|
~ObjCLanguageRuntime() override;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-06-09 02:45:00 +08:00
|
|
|
static char ID;
|
|
|
|
|
|
|
|
bool isA(const void *ClassID) const override {
|
|
|
|
return ClassID == &ID || LanguageRuntime::isA(ClassID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool classof(const LanguageRuntime *runtime) {
|
|
|
|
return runtime->isA(&ID);
|
|
|
|
}
|
|
|
|
|
2019-06-11 04:53:23 +08:00
|
|
|
static ObjCLanguageRuntime *Get(Process &process) {
|
|
|
|
return llvm::cast_or_null<ObjCLanguageRuntime>(
|
|
|
|
process.GetLanguageRuntime(lldb::eLanguageTypeObjC));
|
|
|
|
}
|
|
|
|
|
2015-10-30 04:33:47 +08:00
|
|
|
virtual TaggedPointerVendor *GetTaggedPointerVendor() { return nullptr; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-06-25 06:03:24 +08:00
|
|
|
typedef std::shared_ptr<EncodingToType> EncodingToTypeSP;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-08-12 06:53:00 +08:00
|
|
|
virtual EncodingToTypeSP GetEncodingToType();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-10 01:51:53 +08:00
|
|
|
virtual ClassDescriptorSP GetClassDescriptor(ValueObject &in_value);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-08-12 06:53:00 +08:00
|
|
|
ClassDescriptorSP GetNonKVOClassDescriptor(ValueObject &in_value);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-12 02:07:21 +08:00
|
|
|
virtual ClassDescriptorSP
|
2019-03-07 05:22:25 +08:00
|
|
|
GetClassDescriptorFromClassName(ConstString class_name);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
virtual ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
ClassDescriptorSP GetNonKVOClassDescriptor(ObjCISA isa);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
lldb::LanguageType GetLanguageType() const override {
|
|
|
|
return lldb::eLanguageTypeObjC;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
virtual bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
virtual bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
virtual bool HasReadObjCLibrary() = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
lldb::addr_t LookupInMethodCache(lldb::addr_t class_addr, lldb::addr_t sel);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
void AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t sel,
|
|
|
|
lldb::addr_t impl_addr);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-05-03 02:13:59 +08:00
|
|
|
TypeAndOrName LookupInClassNameCache(lldb::addr_t class_addr);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
void AddToClassNameCache(lldb::addr_t class_addr, const char *name,
|
2011-05-03 02:13:59 +08:00
|
|
|
lldb::TypeSP type_sp);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-05-03 02:13:59 +08:00
|
|
|
void AddToClassNameCache(lldb::addr_t class_addr,
|
|
|
|
const TypeAndOrName &class_or_type_name);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
lldb::TypeSP LookupInCompleteClassCache(ConstString &name);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-07-13 02:34:37 +08:00
|
|
|
llvm::Optional<CompilerType> GetRuntimeType(CompilerType base_type) override;
|
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
virtual UtilityFunction *CreateObjectChecker(const char *) = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-15 10:02:04 +08:00
|
|
|
virtual ObjCRuntimeVersions GetRuntimeVersion() const {
|
|
|
|
return ObjCRuntimeVersions::eObjC_VersionUnknown;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-03-08 10:39:03 +08:00
|
|
|
bool IsValidISA(ObjCISA isa) {
|
|
|
|
UpdateISAToDescriptorMap();
|
|
|
|
return m_isa_to_descriptor.count(isa) > 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-03-08 10:39:03 +08:00
|
|
|
virtual void UpdateISAToDescriptorMapIfNeeded() = 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-12 02:07:21 +08:00
|
|
|
void UpdateISAToDescriptorMap() {
|
2012-03-08 10:39:03 +08:00
|
|
|
if (m_process && m_process->GetStopID() != m_isa_to_descriptor_stop_id) {
|
|
|
|
UpdateISAToDescriptorMapIfNeeded();
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2019-03-07 05:22:25 +08:00
|
|
|
virtual ObjCISA GetISA(ConstString name);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-06 02:49:06 +08:00
|
|
|
virtual ObjCISA GetParentClass(ObjCISA isa);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-06-25 06:03:24 +08:00
|
|
|
// Finds the byte offset of the child_type ivar in parent_type. If it can't
|
2018-05-01 00:49:04 +08:00
|
|
|
// find the offset, returns LLDB_INVALID_IVAR_OFFSET.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-06 02:49:06 +08:00
|
|
|
virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type,
|
2013-02-14 06:56:14 +08:00
|
|
|
const char *ivar_name);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-06 02:49:06 +08:00
|
|
|
bool HasNewLiteralsAndIndexing() {
|
|
|
|
if (m_has_new_literals_and_indexing == eLazyBoolCalculate) {
|
2012-03-08 10:39:03 +08:00
|
|
|
if (CalculateHasNewLiteralsAndIndexing())
|
2013-04-06 02:49:06 +08:00
|
|
|
m_has_new_literals_and_indexing = eLazyBoolYes;
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2012-03-08 10:39:03 +08:00
|
|
|
m_has_new_literals_and_indexing = eLazyBoolNo;
|
2013-04-06 02:49:06 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-04-17 01:13:34 +08:00
|
|
|
return (m_has_new_literals_and_indexing == eLazyBoolYes);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2019-06-04 07:12:11 +08:00
|
|
|
void SymbolsDidLoad(const ModuleList &module_list) override {
|
2013-04-06 02:49:06 +08:00
|
|
|
m_negative_complete_class_cache.clear();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-09-24 11:54:50 +08:00
|
|
|
bool GetTypeBitSize(const CompilerType &compiler_type,
|
2015-04-17 01:13:34 +08:00
|
|
|
uint64_t &size) override;
|
|
|
|
|
2019-05-03 07:07:23 +08:00
|
|
|
/// Check whether the name is "self" or "_cmd" and should show up in
|
|
|
|
/// "frame variable".
|
2019-07-02 04:36:33 +08:00
|
|
|
bool IsWhitelistedRuntimeValue(ConstString name) override;
|
2019-05-03 07:07:23 +08:00
|
|
|
|
2010-09-23 10:01:19 +08:00
|
|
|
protected:
|
|
|
|
// Classes that inherit from ObjCLanguageRuntime can see and modify these
|
|
|
|
ObjCLanguageRuntime(Process *process);
|
2015-10-30 04:33:47 +08:00
|
|
|
|
2012-03-08 10:39:03 +08:00
|
|
|
virtual bool CalculateHasNewLiteralsAndIndexing() { return false; }
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
bool ISAIsCached(ObjCISA isa) const {
|
|
|
|
return m_isa_to_descriptor.find(isa) != m_isa_to_descriptor.end();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-03-08 10:39:03 +08:00
|
|
|
bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp) {
|
2013-02-14 06:56:14 +08:00
|
|
|
if (isa != 0) {
|
|
|
|
m_isa_to_descriptor[isa] = descriptor_sp;
|
2012-03-08 10:39:03 +08:00
|
|
|
return true;
|
|
|
|
}
|
2013-02-14 06:56:14 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp,
|
|
|
|
const char *class_name);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp,
|
|
|
|
uint32_t class_name_hash) {
|
|
|
|
if (isa != 0) {
|
|
|
|
m_isa_to_descriptor[isa] = descriptor_sp;
|
|
|
|
m_hash_to_isa_map.insert(std::make_pair(class_name_hash, isa));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-02-14 06:56:14 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
// We keep a map of <Class,Selector>->Implementation so we don't have to call
|
2018-05-01 00:49:04 +08:00
|
|
|
// the resolver function over and over.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
// FIXME: We need to watch for the loading of Protocols, and flush the cache
|
2010-09-28 09:25:32 +08:00
|
|
|
// for any
|
2013-02-14 06:56:14 +08:00
|
|
|
// class that we see so changed.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
struct ClassAndSel {
|
|
|
|
ClassAndSel() {
|
|
|
|
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 && sel_addr == rhs.sel_addr)
|
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2013-02-14 06:56:14 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-28 09:25:32 +08:00
|
|
|
bool operator<(const ClassAndSel &rhs) const {
|
|
|
|
if (class_addr < rhs.class_addr)
|
|
|
|
return true;
|
|
|
|
else if (class_addr > rhs.class_addr)
|
2013-02-14 06:56:14 +08:00
|
|
|
return false;
|
2010-09-28 09:25:32 +08:00
|
|
|
else {
|
|
|
|
if (sel_addr < rhs.sel_addr)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-09-28 09:25:32 +08:00
|
|
|
lldb::addr_t class_addr;
|
|
|
|
lldb::addr_t sel_addr;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<ClassAndSel, lldb::addr_t> MsgImplMap;
|
2013-02-14 06:56:14 +08:00
|
|
|
typedef std::map<ObjCISA, ClassDescriptorSP> ISAToDescriptorMap;
|
|
|
|
typedef std::multimap<uint32_t, ObjCISA> HashToISAMap;
|
|
|
|
typedef ISAToDescriptorMap::iterator ISAToDescriptorIterator;
|
|
|
|
typedef HashToISAMap::iterator HashToISAIterator;
|
2015-01-28 08:45:42 +08:00
|
|
|
typedef ThreadSafeDenseMap<void *, uint64_t> TypeSizeCache;
|
2013-02-14 06:56:14 +08:00
|
|
|
|
2011-05-03 02:13:59 +08:00
|
|
|
MsgImplMap m_impl_cache;
|
2012-03-08 10:39:03 +08:00
|
|
|
LazyBool m_has_new_literals_and_indexing;
|
2013-02-14 06:56:14 +08:00
|
|
|
ISAToDescriptorMap m_isa_to_descriptor;
|
|
|
|
HashToISAMap m_hash_to_isa_map;
|
2015-01-28 08:45:42 +08:00
|
|
|
TypeSizeCache m_type_size_cache;
|
2013-02-14 06:56:14 +08:00
|
|
|
|
2011-08-16 02:01:31 +08:00
|
|
|
protected:
|
2013-02-14 06:56:14 +08:00
|
|
|
uint32_t m_isa_to_descriptor_stop_id;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-23 07:57:45 +08:00
|
|
|
typedef std::map<ConstString, lldb::TypeWP> CompleteClassMap;
|
|
|
|
CompleteClassMap m_complete_class_cache;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-06 02:49:06 +08:00
|
|
|
struct ConstStringSetHelpers {
|
2019-03-07 05:22:25 +08:00
|
|
|
size_t operator()(ConstString arg) const // for hashing
|
2013-04-06 02:49:06 +08:00
|
|
|
{
|
|
|
|
return (size_t)arg.GetCString();
|
|
|
|
}
|
2019-03-07 05:22:25 +08:00
|
|
|
bool operator()(ConstString arg1,
|
|
|
|
ConstString arg2) const // for equality
|
2013-04-06 02:49:06 +08:00
|
|
|
{
|
|
|
|
return arg1.operator==(arg2);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
typedef std::unordered_set<ConstString, ConstStringSetHelpers,
|
|
|
|
ConstStringSetHelpers>
|
|
|
|
CompleteClassSet;
|
|
|
|
CompleteClassSet m_negative_complete_class_cache;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-03-07 05:22:25 +08:00
|
|
|
ISAToDescriptorIterator GetDescriptorIterator(ConstString name);
|
2013-04-06 02:49:06 +08:00
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
friend class ::CommandObjectObjC_ClassTable_Dump;
|
|
|
|
|
2015-05-07 05:01:07 +08:00
|
|
|
std::pair<ISAToDescriptorIterator, ISAToDescriptorIterator>
|
|
|
|
GetDescriptorIteratorPair(bool update_if_needed = true);
|
|
|
|
|
2015-04-17 01:13:34 +08:00
|
|
|
void ReadObjCLibraryIfNeeded(const ModuleList &module_list);
|
|
|
|
|
2010-09-23 10:01:19 +08:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(ObjCLanguageRuntime);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace lldb_private
|
|
|
|
|
2020-02-18 07:57:45 +08:00
|
|
|
#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_OBJCLANGUAGERUNTIME_H
|