Differential D43886 Diff 173603 source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Changeset View
Changeset View
Standalone View
Standalone View
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Show All 23 Lines | |||||
#include "lldb/Symbol/CompilerType.h" | #include "lldb/Symbol/CompilerType.h" | ||||
#include "lldb/lldb-enumerations.h" | #include "lldb/lldb-enumerations.h" | ||||
#include "lldb/Core/ClangForward.h" | #include "lldb/Core/ClangForward.h" | ||||
#include "lldb/Core/Debugger.h" | #include "lldb/Core/Debugger.h" | ||||
#include "lldb/Core/Module.h" | #include "lldb/Core/Module.h" | ||||
#include "lldb/Core/PluginManager.h" | #include "lldb/Core/PluginManager.h" | ||||
#include "lldb/Core/Section.h" | #include "lldb/Core/Section.h" | ||||
#include "lldb/Core/ValueObjectConstResult.h" | |||||
#include "lldb/Core/ValueObjectVariable.h" | #include "lldb/Core/ValueObjectVariable.h" | ||||
#include "lldb/Expression/DiagnosticManager.h" | #include "lldb/Expression/DiagnosticManager.h" | ||||
#include "lldb/Expression/FunctionCaller.h" | #include "lldb/Expression/FunctionCaller.h" | ||||
#include "lldb/Expression/UtilityFunction.h" | #include "lldb/Expression/UtilityFunction.h" | ||||
#include "lldb/Interpreter/CommandObject.h" | #include "lldb/Interpreter/CommandObject.h" | ||||
#include "lldb/Interpreter/CommandObjectMultiword.h" | #include "lldb/Interpreter/CommandObjectMultiword.h" | ||||
#include "lldb/Interpreter/CommandReturnObject.h" | #include "lldb/Interpreter/CommandReturnObject.h" | ||||
#include "lldb/Interpreter/OptionArgParser.h" | #include "lldb/Interpreter/OptionArgParser.h" | ||||
#include "lldb/Interpreter/OptionValueBoolean.h" | #include "lldb/Interpreter/OptionValueBoolean.h" | ||||
#include "lldb/Symbol/ClangASTContext.h" | #include "lldb/Symbol/ClangASTContext.h" | ||||
#include "lldb/Symbol/ObjectFile.h" | #include "lldb/Symbol/ObjectFile.h" | ||||
#include "lldb/Symbol/Symbol.h" | #include "lldb/Symbol/Symbol.h" | ||||
#include "lldb/Symbol/TypeList.h" | #include "lldb/Symbol/TypeList.h" | ||||
#include "lldb/Symbol/VariableList.h" | #include "lldb/Symbol/VariableList.h" | ||||
#include "lldb/Target/ABI.h" | |||||
#include "lldb/Target/ExecutionContext.h" | #include "lldb/Target/ExecutionContext.h" | ||||
#include "lldb/Target/Platform.h" | #include "lldb/Target/Platform.h" | ||||
#include "lldb/Target/Process.h" | #include "lldb/Target/Process.h" | ||||
#include "lldb/Target/RegisterContext.h" | #include "lldb/Target/RegisterContext.h" | ||||
#include "lldb/Target/StackFrameRecognizer.h" | |||||
#include "lldb/Target/Target.h" | #include "lldb/Target/Target.h" | ||||
#include "lldb/Target/Thread.h" | #include "lldb/Target/Thread.h" | ||||
#include "lldb/Utility/ConstString.h" | #include "lldb/Utility/ConstString.h" | ||||
#include "lldb/Utility/Log.h" | #include "lldb/Utility/Log.h" | ||||
#include "lldb/Utility/Scalar.h" | #include "lldb/Utility/Scalar.h" | ||||
#include "lldb/Utility/Status.h" | #include "lldb/Utility/Status.h" | ||||
#include "lldb/Utility/Stream.h" | #include "lldb/Utility/Stream.h" | ||||
#include "lldb/Utility/StreamString.h" | #include "lldb/Utility/StreamString.h" | ||||
▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | if (symbol_load_addr != LLDB_INVALID_ADDRESS) { | ||||
return default_value; | return default_value; | ||||
} | } | ||||
} else { | } else { | ||||
error.SetErrorString("no symbol"); | error.SetErrorString("no symbol"); | ||||
return default_value; | return default_value; | ||||
} | } | ||||
} | } | ||||
static void RegisterObjCExceptionRecognizer(); | |||||
AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, | AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, | ||||
const ModuleSP &objc_module_sp) | const ModuleSP &objc_module_sp) | ||||
: AppleObjCRuntime(process), m_get_class_info_code(), | : AppleObjCRuntime(process), m_get_class_info_code(), | ||||
m_get_class_info_args(LLDB_INVALID_ADDRESS), | m_get_class_info_args(LLDB_INVALID_ADDRESS), | ||||
m_get_class_info_args_mutex(), m_get_shared_cache_class_info_code(), | m_get_class_info_args_mutex(), m_get_shared_cache_class_info_code(), | ||||
m_get_shared_cache_class_info_args(LLDB_INVALID_ADDRESS), | m_get_shared_cache_class_info_args(LLDB_INVALID_ADDRESS), | ||||
m_get_shared_cache_class_info_args_mutex(), m_decl_vendor_ap(), | m_get_shared_cache_class_info_args_mutex(), m_decl_vendor_ap(), | ||||
m_tagged_pointer_obfuscator(LLDB_INVALID_ADDRESS), | m_tagged_pointer_obfuscator(LLDB_INVALID_ADDRESS), | ||||
m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS), | m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS), | ||||
m_hash_signature(), | m_hash_signature(), | ||||
m_has_object_getClass(false), m_loaded_objc_opt(false), | m_has_object_getClass(false), m_loaded_objc_opt(false), | ||||
m_non_pointer_isa_cache_ap( | m_non_pointer_isa_cache_ap( | ||||
NonPointerISACache::CreateInstance(*this, objc_module_sp)), | NonPointerISACache::CreateInstance(*this, objc_module_sp)), | ||||
m_tagged_pointer_vendor_ap( | m_tagged_pointer_vendor_ap( | ||||
TaggedPointerVendorV2::CreateInstance(*this, objc_module_sp)), | TaggedPointerVendorV2::CreateInstance(*this, objc_module_sp)), | ||||
m_encoding_to_type_sp(), m_noclasses_warning_emitted(false), | m_encoding_to_type_sp(), m_noclasses_warning_emitted(false), | ||||
m_CFBoolean_values() { | m_CFBoolean_values() { | ||||
static const ConstString g_gdb_object_getClass("gdb_object_getClass"); | static const ConstString g_gdb_object_getClass("gdb_object_getClass"); | ||||
m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType( | m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType( | ||||
g_gdb_object_getClass, eSymbolTypeCode) != NULL); | g_gdb_object_getClass, eSymbolTypeCode) != NULL); | ||||
RegisterObjCExceptionRecognizer(); | |||||
} | } | ||||
bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress( | bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress( | ||||
ValueObject &in_value, lldb::DynamicValueType use_dynamic, | ValueObject &in_value, lldb::DynamicValueType use_dynamic, | ||||
TypeAndOrName &class_type_or_name, Address &address, | TypeAndOrName &class_type_or_name, Address &address, | ||||
Value::ValueType &value_type) { | Value::ValueType &value_type) { | ||||
// We should never get here with a null process... | // We should never get here with a null process... | ||||
assert(m_process != NULL); | assert(m_process != NULL); | ||||
▲ Show 20 Lines • Show All 2,183 Lines • ▼ Show 20 Lines | |||||
void AppleObjCRuntimeV2::GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, | void AppleObjCRuntimeV2::GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, | ||||
lldb::addr_t &cf_false) { | lldb::addr_t &cf_false) { | ||||
if (GetCFBooleanValuesIfNeeded()) { | if (GetCFBooleanValuesIfNeeded()) { | ||||
cf_true = m_CFBoolean_values->second; | cf_true = m_CFBoolean_values->second; | ||||
cf_false = m_CFBoolean_values->first; | cf_false = m_CFBoolean_values->first; | ||||
} else | } else | ||||
this->AppleObjCRuntime::GetValuesForGlobalCFBooleans(cf_true, cf_false); | this->AppleObjCRuntime::GetValuesForGlobalCFBooleans(cf_true, cf_false); | ||||
} | } | ||||
#pragma mark Frame recognizers | |||||
class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame { | |||||
public: | |||||
ObjCExceptionRecognizedStackFrame(StackFrameSP frame_sp) { | |||||
ThreadSP thread_sp = frame_sp->GetThread(); | |||||
ProcessSP process_sp = thread_sp->GetProcess(); | |||||
const lldb::ABISP &abi = process_sp->GetABI(); | |||||
if (!abi) return; | |||||
CompilerType voidstar = process_sp->GetTarget() | |||||
.GetScratchClangASTContext() | |||||
->GetBasicType(lldb::eBasicTypeVoid) | |||||
.GetPointerType(); | |||||
ValueList args; | |||||
Value input_value; | |||||
input_value.SetCompilerType(voidstar); | |||||
args.PushValue(input_value); | |||||
if (!abi->GetArgumentValues(*thread_sp, args)) return; | |||||
addr_t exception_addr = args.GetValueAtIndex(0)->GetScalar().ULongLong(); | |||||
Value value(exception_addr); | |||||
value.SetCompilerType(voidstar); | |||||
exception = ValueObjectConstResult::Create(frame_sp.get(), value, | |||||
ConstString("exception")); | |||||
exception = exception->GetDynamicValue(eDynamicDontRunTarget); | |||||
} | |||||
ValueObjectSP exception; | |||||
lldb::ValueObjectSP GetExceptionObject() override { return exception; } | |||||
}; | |||||
class ObjCExceptionThrowFrameRecognizer : public StackFrameRecognizer { | |||||
lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame) { | |||||
return lldb::RecognizedStackFrameSP( | |||||
new ObjCExceptionRecognizedStackFrame(frame)); | |||||
}; | |||||
}; | |||||
static void RegisterObjCExceptionRecognizer() { | |||||
static llvm::once_flag g_once_flag; | |||||
llvm::call_once(g_once_flag, []() { | |||||
StackFrameRecognizerManager::AddRecognizer( | |||||
StackFrameRecognizerSP(new ObjCExceptionThrowFrameRecognizer()), | |||||
ConstString("libobjc.A.dylib"), ConstString("objc_exception_throw"), | |||||
/*first_instruction_only*/ true); | |||||
}); | |||||
} |