forked from OSchip/llvm-project
96 lines
3.0 KiB
C++
96 lines
3.0 KiB
C++
//===-- CPPLanguageRuntime.cpp -------------------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
#include "clang/AST/Type.h"
|
|
|
|
#include "lldb/Core/Log.h"
|
|
#include "lldb/Core/PluginManager.h"
|
|
#include "lldb/Core/ValueObject.h"
|
|
#include "lldb/Symbol/ClangASTContext.h"
|
|
#include "lldb/Symbol/Type.h"
|
|
#include "lldb/Target/ObjCLanguageRuntime.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
//----------------------------------------------------------------------
|
|
// Destructor
|
|
//----------------------------------------------------------------------
|
|
ObjCLanguageRuntime::~ObjCLanguageRuntime()
|
|
{
|
|
}
|
|
|
|
ObjCLanguageRuntime::ObjCLanguageRuntime (Process *process) :
|
|
LanguageRuntime (process)
|
|
{
|
|
|
|
}
|
|
|
|
void
|
|
ObjCLanguageRuntime::AddToMethodCache (lldb::addr_t class_addr, lldb::addr_t selector, lldb::addr_t impl_addr)
|
|
{
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
|
if (log)
|
|
{
|
|
log->Printf ("Caching: class 0x%llx selector 0x%llx implementation 0x%llx.", class_addr, selector, impl_addr);
|
|
}
|
|
m_impl_cache.insert (std::pair<ClassAndSel,lldb::addr_t> (ClassAndSel(class_addr, selector), impl_addr));
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
void
|
|
ObjCLanguageRuntime::AddToClassNameCache (lldb::addr_t class_addr, const char *name, lldb::TypeSP type_sp)
|
|
{
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
|
if (log)
|
|
{
|
|
log->Printf ("Caching: class 0x%llx name: %s.", class_addr, name);
|
|
}
|
|
|
|
TypeAndOrName class_type_or_name;
|
|
|
|
if (type_sp != NULL)
|
|
class_type_or_name.SetTypeSP (type_sp);
|
|
else if (name && *name != '\0')
|
|
class_type_or_name.SetName (name);
|
|
else
|
|
return;
|
|
m_class_name_cache.insert (std::pair<lldb::addr_t,TypeAndOrName> (class_addr, class_type_or_name));
|
|
}
|
|
|
|
void
|
|
ObjCLanguageRuntime::AddToClassNameCache (lldb::addr_t class_addr, const TypeAndOrName &class_type_or_name)
|
|
{
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
|
if (log)
|
|
{
|
|
log->Printf ("Caching: class 0x%llx name: %s.", class_addr, class_type_or_name.GetName().AsCString());
|
|
}
|
|
|
|
m_class_name_cache.insert (std::pair<lldb::addr_t,TypeAndOrName> (class_addr, class_type_or_name));
|
|
}
|
|
|
|
TypeAndOrName
|
|
ObjCLanguageRuntime::LookupInClassNameCache (lldb::addr_t class_addr)
|
|
{
|
|
ClassNameMap::iterator pos, end = m_class_name_cache.end();
|
|
pos = m_class_name_cache.find (class_addr);
|
|
if (pos != end)
|
|
return (*pos).second;
|
|
return TypeAndOrName ();
|
|
}
|