2012-02-01 09:46:19 +08:00
|
|
|
//===-- ObjCLanguageRuntime.cpp ---------------------------------*- C++ -*-===//
|
2010-09-23 10:01:19 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2010-09-30 08:54:27 +08:00
|
|
|
#include "clang/AST/Type.h"
|
2010-09-23 10:01:19 +08:00
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
#include "lldb/Core/MappedHash.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
2010-09-23 10:01:19 +08:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
2013-01-30 08:18:29 +08:00
|
|
|
#include "lldb/Core/Timer.h"
|
2010-09-30 08:54:27 +08:00
|
|
|
#include "lldb/Core/ValueObject.h"
|
|
|
|
#include "lldb/Symbol/ClangASTContext.h"
|
2015-03-04 03:23:09 +08:00
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
2016-02-11 05:28:13 +08:00
|
|
|
#include "lldb/Symbol/SymbolFile.h"
|
2011-05-03 02:13:59 +08:00
|
|
|
#include "lldb/Symbol/Type.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/TypeList.h"
|
2010-09-28 09:25:32 +08:00
|
|
|
#include "lldb/Target/ObjCLanguageRuntime.h"
|
2012-02-23 07:57:45 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2017-03-04 04:56:28 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
2010-09-23 10:01:19 +08:00
|
|
|
|
2013-01-30 08:18:29 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
|
2010-09-23 10:01:19 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::~ObjCLanguageRuntime() {}
|
|
|
|
|
|
|
|
ObjCLanguageRuntime::ObjCLanguageRuntime(Process *process)
|
|
|
|
: LanguageRuntime(process), m_impl_cache(),
|
|
|
|
m_has_new_literals_and_indexing(eLazyBoolCalculate),
|
|
|
|
m_isa_to_descriptor(), m_hash_to_isa_map(), m_type_size_cache(),
|
|
|
|
m_isa_to_descriptor_stop_id(UINT32_MAX), m_complete_class_cache(),
|
|
|
|
m_negative_complete_class_cache() {}
|
|
|
|
|
|
|
|
bool ObjCLanguageRuntime::AddClass(ObjCISA isa,
|
|
|
|
const ClassDescriptorSP &descriptor_sp,
|
|
|
|
const char *class_name) {
|
|
|
|
if (isa != 0) {
|
|
|
|
m_isa_to_descriptor[isa] = descriptor_sp;
|
|
|
|
// class_name is assumed to be valid
|
|
|
|
m_hash_to_isa_map.insert(
|
|
|
|
std::make_pair(MappedHash::HashStringUsingDJB(class_name), isa));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2010-09-23 10:01:19 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void ObjCLanguageRuntime::AddToMethodCache(lldb::addr_t class_addr,
|
|
|
|
lldb::addr_t selector,
|
|
|
|
lldb::addr_t impl_addr) {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
|
|
|
|
if (log) {
|
|
|
|
log->Printf("Caching: class 0x%" PRIx64 " selector 0x%" PRIx64
|
|
|
|
" implementation 0x%" PRIx64 ".",
|
|
|
|
class_addr, selector, impl_addr);
|
|
|
|
}
|
|
|
|
m_impl_cache.insert(std::pair<ClassAndSel, lldb::addr_t>(
|
|
|
|
ClassAndSel(class_addr, selector), impl_addr));
|
2010-09-28 09:25:32 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::addr_t ObjCLanguageRuntime::LookupInMethodCache(lldb::addr_t class_addr,
|
|
|
|
lldb::addr_t selector) {
|
|
|
|
MsgImplMap::iterator pos, end = m_impl_cache.end();
|
|
|
|
pos = m_impl_cache.find(ClassAndSel(class_addr, selector));
|
|
|
|
if (pos != end)
|
|
|
|
return (*pos).second;
|
|
|
|
return LLDB_INVALID_ADDRESS;
|
2013-02-14 06:56:14 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::TypeSP
|
|
|
|
ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) {
|
|
|
|
CompleteClassMap::iterator complete_class_iter =
|
|
|
|
m_complete_class_cache.find(name);
|
2010-09-28 09:25:32 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (complete_class_iter != m_complete_class_cache.end()) {
|
|
|
|
// Check the weak pointer to make sure the type hasn't been unloaded
|
|
|
|
TypeSP complete_type_sp(complete_class_iter->second.lock());
|
2011-05-03 02:13:59 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (complete_type_sp)
|
|
|
|
return complete_type_sp;
|
|
|
|
else
|
|
|
|
m_complete_class_cache.erase(name);
|
|
|
|
}
|
2011-06-25 06:03:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (m_negative_complete_class_cache.count(name) > 0)
|
|
|
|
return TypeSP();
|
|
|
|
|
|
|
|
const ModuleList &modules = m_process->GetTarget().GetImages();
|
|
|
|
|
|
|
|
SymbolContextList sc_list;
|
|
|
|
const size_t matching_symbols =
|
|
|
|
modules.FindSymbolsWithNameAndType(name, eSymbolTypeObjCClass, sc_list);
|
|
|
|
|
|
|
|
if (matching_symbols) {
|
|
|
|
SymbolContext sc;
|
|
|
|
|
|
|
|
sc_list.GetContextAtIndex(0, sc);
|
|
|
|
|
|
|
|
ModuleSP module_sp(sc.module_sp);
|
|
|
|
|
|
|
|
if (!module_sp)
|
|
|
|
return TypeSP();
|
|
|
|
|
|
|
|
const SymbolContext null_sc;
|
|
|
|
const bool exact_match = true;
|
|
|
|
const uint32_t max_matches = UINT32_MAX;
|
|
|
|
TypeList types;
|
|
|
|
|
|
|
|
llvm::DenseSet<SymbolFile *> searched_symbol_files;
|
|
|
|
const uint32_t num_types = module_sp->FindTypes(
|
|
|
|
null_sc, name, exact_match, max_matches, searched_symbol_files, types);
|
|
|
|
|
|
|
|
if (num_types) {
|
|
|
|
uint32_t i;
|
|
|
|
for (i = 0; i < num_types; ++i) {
|
|
|
|
TypeSP type_sp(types.GetTypeAtIndex(i));
|
|
|
|
|
|
|
|
if (ClangASTContext::IsObjCObjectOrInterfaceType(
|
|
|
|
type_sp->GetForwardCompilerType())) {
|
|
|
|
if (type_sp->IsCompleteObjCClass()) {
|
|
|
|
m_complete_class_cache[name] = type_sp;
|
|
|
|
return type_sp;
|
|
|
|
}
|
2012-02-23 07:57:45 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-02-23 07:57:45 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
m_negative_complete_class_cache.insert(name);
|
|
|
|
return TypeSP();
|
2012-02-23 07:57:45 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
size_t ObjCLanguageRuntime::GetByteOffsetForIvar(CompilerType &parent_qual_type,
|
|
|
|
const char *ivar_name) {
|
|
|
|
return LLDB_INVALID_IVAR_OFFSET;
|
2011-06-25 06:03:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ObjCLanguageRuntime::ClassDescriptor::IsPointerValid(
|
|
|
|
lldb::addr_t value, uint32_t ptr_size, bool allow_NULLs, bool allow_tagged,
|
|
|
|
bool check_version_specific) const {
|
|
|
|
if (!value)
|
|
|
|
return allow_NULLs;
|
|
|
|
if ((value % 2) == 1 && allow_tagged)
|
|
|
|
return true;
|
|
|
|
if ((value % ptr_size) == 0)
|
|
|
|
return (check_version_specific ? CheckPointer(value, ptr_size) : true);
|
|
|
|
else
|
|
|
|
return false;
|
2012-09-05 02:47:54 +08:00
|
|
|
}
|
|
|
|
|
2012-09-12 05:44:01 +08:00
|
|
|
ObjCLanguageRuntime::ObjCISA
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::GetISA(const ConstString &name) {
|
|
|
|
ISAToDescriptorIterator pos = GetDescriptorIterator(name);
|
|
|
|
if (pos != m_isa_to_descriptor.end())
|
|
|
|
return pos->first;
|
|
|
|
return 0;
|
2012-09-12 05:44:01 +08:00
|
|
|
}
|
|
|
|
|
2013-02-14 06:56:14 +08:00
|
|
|
ObjCLanguageRuntime::ISAToDescriptorIterator
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::GetDescriptorIterator(const ConstString &name) {
|
|
|
|
ISAToDescriptorIterator end = m_isa_to_descriptor.end();
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
UpdateISAToDescriptorMap();
|
|
|
|
if (m_hash_to_isa_map.empty()) {
|
|
|
|
// No name hashes were provided, we need to just linearly power through
|
|
|
|
// the
|
|
|
|
// names and find a match
|
|
|
|
for (ISAToDescriptorIterator pos = m_isa_to_descriptor.begin();
|
|
|
|
pos != end; ++pos) {
|
|
|
|
if (pos->second->GetClassName() == name)
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Name hashes were provided, so use them to efficiently lookup name to
|
|
|
|
// isa/descriptor
|
|
|
|
const uint32_t name_hash =
|
|
|
|
MappedHash::HashStringUsingDJB(name.GetCString());
|
|
|
|
std::pair<HashToISAIterator, HashToISAIterator> range =
|
|
|
|
m_hash_to_isa_map.equal_range(name_hash);
|
|
|
|
for (HashToISAIterator range_pos = range.first; range_pos != range.second;
|
|
|
|
++range_pos) {
|
|
|
|
ISAToDescriptorIterator pos =
|
|
|
|
m_isa_to_descriptor.find(range_pos->second);
|
|
|
|
if (pos != m_isa_to_descriptor.end()) {
|
|
|
|
if (pos->second->GetClassName() == name)
|
|
|
|
return pos;
|
2013-02-14 06:56:14 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-02-14 06:56:14 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return end;
|
2013-02-14 06:56:14 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
std::pair<ObjCLanguageRuntime::ISAToDescriptorIterator,
|
|
|
|
ObjCLanguageRuntime::ISAToDescriptorIterator>
|
|
|
|
ObjCLanguageRuntime::GetDescriptorIteratorPair(bool update_if_needed) {
|
|
|
|
if (update_if_needed)
|
|
|
|
UpdateISAToDescriptorMapIfNeeded();
|
2015-05-07 05:01:07 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return std::pair<ObjCLanguageRuntime::ISAToDescriptorIterator,
|
|
|
|
ObjCLanguageRuntime::ISAToDescriptorIterator>(
|
|
|
|
m_isa_to_descriptor.begin(), m_isa_to_descriptor.end());
|
|
|
|
}
|
2013-02-14 06:56:14 +08:00
|
|
|
|
2012-09-05 02:47:54 +08:00
|
|
|
ObjCLanguageRuntime::ObjCISA
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::GetParentClass(ObjCLanguageRuntime::ObjCISA isa) {
|
|
|
|
ClassDescriptorSP objc_class_sp(GetClassDescriptorFromISA(isa));
|
|
|
|
if (objc_class_sp) {
|
|
|
|
ClassDescriptorSP objc_super_class_sp(objc_class_sp->GetSuperclass());
|
|
|
|
if (objc_super_class_sp)
|
|
|
|
return objc_super_class_sp->GetISA();
|
|
|
|
}
|
|
|
|
return 0;
|
2012-09-05 02:47:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ConstString
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa) {
|
|
|
|
ClassDescriptorSP objc_class_sp(GetNonKVOClassDescriptor(isa));
|
|
|
|
if (objc_class_sp)
|
|
|
|
return objc_class_sp->GetClassName();
|
|
|
|
return ConstString();
|
2012-10-10 01:51:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ObjCLanguageRuntime::ClassDescriptorSP
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::GetClassDescriptorFromClassName(
|
|
|
|
const ConstString &class_name) {
|
|
|
|
ISAToDescriptorIterator pos = GetDescriptorIterator(class_name);
|
|
|
|
if (pos != m_isa_to_descriptor.end())
|
|
|
|
return pos->second;
|
|
|
|
return ClassDescriptorSP();
|
2012-10-10 01:51:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ObjCLanguageRuntime::ClassDescriptorSP
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::GetClassDescriptor(ValueObject &valobj) {
|
|
|
|
ClassDescriptorSP objc_class_sp;
|
|
|
|
// if we get an invalid VO (which might still happen when playing around
|
|
|
|
// with pointers returned by the expression parser, don't consider this
|
|
|
|
// a valid ObjC object)
|
|
|
|
if (valobj.GetCompilerType().IsValid()) {
|
|
|
|
addr_t isa_pointer = valobj.GetPointerValue();
|
|
|
|
if (isa_pointer != LLDB_INVALID_ADDRESS) {
|
|
|
|
ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
|
|
|
|
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (process) {
|
|
|
|
Error error;
|
|
|
|
ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error);
|
|
|
|
if (isa != LLDB_INVALID_ADDRESS)
|
|
|
|
objc_class_sp = GetClassDescriptorFromISA(isa);
|
|
|
|
}
|
2012-10-10 01:51:53 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return objc_class_sp;
|
2012-10-10 01:51:53 +08:00
|
|
|
}
|
|
|
|
|
2012-10-12 02:07:21 +08:00
|
|
|
ObjCLanguageRuntime::ClassDescriptorSP
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::GetNonKVOClassDescriptor(ValueObject &valobj) {
|
|
|
|
ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp(
|
|
|
|
GetClassDescriptor(valobj));
|
|
|
|
if (objc_class_sp) {
|
|
|
|
if (!objc_class_sp->IsKVO())
|
|
|
|
return objc_class_sp;
|
|
|
|
|
|
|
|
ClassDescriptorSP non_kvo_objc_class_sp(objc_class_sp->GetSuperclass());
|
|
|
|
if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
|
|
|
|
return non_kvo_objc_class_sp;
|
|
|
|
}
|
|
|
|
return ClassDescriptorSP();
|
2012-10-12 02:07:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ObjCLanguageRuntime::ClassDescriptorSP
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::GetClassDescriptorFromISA(ObjCISA isa) {
|
|
|
|
if (isa) {
|
|
|
|
UpdateISAToDescriptorMap();
|
|
|
|
ObjCLanguageRuntime::ISAToDescriptorIterator pos =
|
|
|
|
m_isa_to_descriptor.find(isa);
|
|
|
|
if (pos != m_isa_to_descriptor.end())
|
|
|
|
return pos->second;
|
|
|
|
}
|
|
|
|
return ClassDescriptorSP();
|
2012-10-12 02:07:21 +08:00
|
|
|
}
|
|
|
|
|
2012-10-10 01:51:53 +08:00
|
|
|
ObjCLanguageRuntime::ClassDescriptorSP
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::GetNonKVOClassDescriptor(ObjCISA isa) {
|
|
|
|
if (isa) {
|
|
|
|
ClassDescriptorSP objc_class_sp = GetClassDescriptorFromISA(isa);
|
|
|
|
if (objc_class_sp && objc_class_sp->IsValid()) {
|
|
|
|
if (!objc_class_sp->IsKVO())
|
|
|
|
return objc_class_sp;
|
|
|
|
|
|
|
|
ClassDescriptorSP non_kvo_objc_class_sp(objc_class_sp->GetSuperclass());
|
|
|
|
if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
|
|
|
|
return non_kvo_objc_class_sp;
|
2012-09-05 02:47:54 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return ClassDescriptorSP();
|
2012-09-05 02:47:54 +08:00
|
|
|
}
|
2012-10-10 01:51:53 +08:00
|
|
|
|
2015-08-12 06:53:00 +08:00
|
|
|
CompilerType
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::EncodingToType::RealizeType(const char *name,
|
|
|
|
bool for_expression) {
|
|
|
|
if (m_scratch_ast_ctx_ap)
|
|
|
|
return RealizeType(*m_scratch_ast_ctx_ap, name, for_expression);
|
|
|
|
return CompilerType();
|
2014-08-20 05:46:37 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
CompilerType ObjCLanguageRuntime::EncodingToType::RealizeType(
|
|
|
|
ClangASTContext &ast_ctx, const char *name, bool for_expression) {
|
|
|
|
clang::ASTContext *clang_ast = ast_ctx.getASTContext();
|
|
|
|
if (!clang_ast)
|
|
|
|
return CompilerType();
|
|
|
|
return RealizeType(*clang_ast, name, for_expression);
|
2014-08-20 05:46:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ObjCLanguageRuntime::EncodingToType::~EncodingToType() {}
|
2012-10-10 01:51:53 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::EncodingToTypeSP ObjCLanguageRuntime::GetEncodingToType() {
|
|
|
|
return nullptr;
|
2014-08-20 05:46:37 +08:00
|
|
|
}
|
2015-01-28 08:45:42 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ObjCLanguageRuntime::GetTypeBitSize(const CompilerType &compiler_type,
|
|
|
|
uint64_t &size) {
|
|
|
|
void *opaque_ptr = compiler_type.GetOpaqueQualType();
|
|
|
|
size = m_type_size_cache.Lookup(opaque_ptr);
|
|
|
|
// an ObjC object will at least have an ISA, so 0 is definitely not OK
|
|
|
|
if (size > 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
ClassDescriptorSP class_descriptor_sp =
|
|
|
|
GetClassDescriptorFromClassName(compiler_type.GetTypeName());
|
|
|
|
if (!class_descriptor_sp)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int32_t max_offset = INT32_MIN;
|
|
|
|
uint64_t sizeof_max = 0;
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
for (size_t idx = 0; idx < class_descriptor_sp->GetNumIVars(); idx++) {
|
|
|
|
const auto &ivar = class_descriptor_sp->GetIVarAtIndex(idx);
|
|
|
|
int32_t cur_offset = ivar.m_offset;
|
|
|
|
if (cur_offset > max_offset) {
|
|
|
|
max_offset = cur_offset;
|
|
|
|
sizeof_max = ivar.m_size;
|
|
|
|
found = true;
|
2015-01-28 08:45:42 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
size = 8 * (max_offset + sizeof_max);
|
|
|
|
if (found)
|
|
|
|
m_type_size_cache.Insert(opaque_ptr, size);
|
|
|
|
|
|
|
|
return found;
|
2015-01-28 08:45:42 +08:00
|
|
|
}
|
2015-04-23 03:42:18 +08:00
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Exception breakpoint Precondition class for ObjC:
|
|
|
|
//------------------------------------------------------------------
|
2016-09-07 04:57:50 +08:00
|
|
|
void ObjCLanguageRuntime::ObjCExceptionPrecondition::AddClassName(
|
|
|
|
const char *class_name) {
|
|
|
|
m_class_names.insert(class_name);
|
2015-04-23 03:42:18 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ObjCLanguageRuntime::ObjCExceptionPrecondition::ObjCExceptionPrecondition() {}
|
2015-04-23 03:42:18 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool ObjCLanguageRuntime::ObjCExceptionPrecondition::EvaluatePrecondition(
|
|
|
|
StoppointCallbackContext &context) {
|
|
|
|
return true;
|
2015-04-23 03:42:18 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void ObjCLanguageRuntime::ObjCExceptionPrecondition::GetDescription(
|
|
|
|
Stream &stream, lldb::DescriptionLevel level) {}
|
2015-04-23 03:42:18 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
Error ObjCLanguageRuntime::ObjCExceptionPrecondition::ConfigurePrecondition(
|
|
|
|
Args &args) {
|
|
|
|
Error error;
|
|
|
|
if (args.GetArgumentCount() > 0)
|
|
|
|
error.SetErrorString(
|
|
|
|
"The ObjC Exception breakpoint doesn't support extra options.");
|
|
|
|
return error;
|
2015-04-23 03:42:18 +08:00
|
|
|
}
|