diff options
author | Jim Ingham <jingham@apple.com> | 2010-09-28 01:25:32 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2010-09-28 01:25:32 +0000 |
commit | 5a369128f66b30f8ce003c641dc40be0e87c09ca (patch) | |
tree | 8ad8a725e41d77a94fc92b8ec66cd91dfa056560 /lldb/source/Target | |
parent | 7990df1ae259f218e1bcdfce24ecc932697cf061 (diff) | |
download | bcm5719-llvm-5a369128f66b30f8ce003c641dc40be0e87c09ca.tar.gz bcm5719-llvm-5a369128f66b30f8ce003c641dc40be0e87c09ca.zip |
Replace the vestigial Value::GetOpaqueCLangQualType with the more correct Value::GetValueOpaqueClangQualType.
But mostly, move the ObjC Trampoline handling code from the MacOSX dyld plugin to the AppleObjCRuntime classes.
llvm-svn: 114935
Diffstat (limited to 'lldb/source/Target')
-rw-r--r-- | lldb/source/Target/CPPLanguageRuntime.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Target/LanguageRuntime.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Target/ObjCLanguageRuntime.cpp | 27 | ||||
-rw-r--r-- | lldb/source/Target/ObjCObjectPrinter.cpp | 122 | ||||
-rw-r--r-- | lldb/source/Target/Process.cpp | 7 | ||||
-rw-r--r-- | lldb/source/Target/Thread.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Target/ThreadPlanStepThrough.cpp | 9 |
7 files changed, 55 insertions, 133 deletions
diff --git a/lldb/source/Target/CPPLanguageRuntime.cpp b/lldb/source/Target/CPPLanguageRuntime.cpp index 3e825bb2c3a..d694b7702b3 100644 --- a/lldb/source/Target/CPPLanguageRuntime.cpp +++ b/lldb/source/Target/CPPLanguageRuntime.cpp @@ -9,6 +9,7 @@ #include "lldb/Target/CPPLanguageRuntime.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Target/ExecutionContext.h" using namespace lldb; using namespace lldb_private; @@ -24,4 +25,11 @@ CPPLanguageRuntime::CPPLanguageRuntime (Process *process) : LanguageRuntime (process) { -}
\ No newline at end of file +} + +bool +CPPLanguageRuntime::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) +{ + // C++ has no generic way to do this. + return false; +} diff --git a/lldb/source/Target/LanguageRuntime.cpp b/lldb/source/Target/LanguageRuntime.cpp index 00c35f80633..3b5b3299844 100644 --- a/lldb/source/Target/LanguageRuntime.cpp +++ b/lldb/source/Target/LanguageRuntime.cpp @@ -35,7 +35,8 @@ LanguageRuntime::FindPlugin (Process *process, lldb::LanguageType language) //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -LanguageRuntime::LanguageRuntime(Process *process) +LanguageRuntime::LanguageRuntime(Process *process) : + m_process (process) { } diff --git a/lldb/source/Target/ObjCLanguageRuntime.cpp b/lldb/source/Target/ObjCLanguageRuntime.cpp index ab7e7e55a90..0a136336a26 100644 --- a/lldb/source/Target/ObjCLanguageRuntime.cpp +++ b/lldb/source/Target/ObjCLanguageRuntime.cpp @@ -7,8 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ObjCLanguageRuntime.h" +#include "lldb/Core/Log.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Target/ObjCLanguageRuntime.h" using namespace lldb; using namespace lldb_private; @@ -24,4 +25,26 @@ ObjCLanguageRuntime::ObjCLanguageRuntime (Process *process) : LanguageRuntime (process) { -}
\ No newline at end of file +} + +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%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; +} + diff --git a/lldb/source/Target/ObjCObjectPrinter.cpp b/lldb/source/Target/ObjCObjectPrinter.cpp deleted file mode 100644 index 72015e2d650..00000000000 --- a/lldb/source/Target/ObjCObjectPrinter.cpp +++ /dev/null @@ -1,122 +0,0 @@ -//===-- ObjCObjectPrinter.cpp -------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Core/StreamString.h" -#include "lldb/Expression/ClangFunction.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Target.h" - -#include "lldb/Target/ObjCObjectPrinter.h" - -using namespace lldb; -using namespace lldb_private; - -//---------------------------------------------------------------------- -// ObjCObjectPrinter constructor -//---------------------------------------------------------------------- -ObjCObjectPrinter::ObjCObjectPrinter (Process &process) : - m_process(process) -{ -} - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -ObjCObjectPrinter::~ObjCObjectPrinter () -{ -} - -bool -ObjCObjectPrinter::PrintObject (Stream &str, Value &object_ptr, ExecutionContext &exe_ctx) -{ - if (!exe_ctx.process) - return false; - - const Address *function_address = GetPrintForDebuggerAddr(); - - if (!function_address) - return false; - - const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString(); - ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); - - void *return_qualtype = ast_context->GetCStringType(true); - Value ret; - ret.SetContext(Value::eContextTypeOpaqueClangQualType, return_qualtype); - - ValueList arg_value_list; - arg_value_list.PushValue(object_ptr); - - ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list); - StreamString error_stream; - - lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS; - func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream); - // FIXME: Check result of ExecuteFunction. - ClangFunction::ExecutionResults results - = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, true, 1000, true, ret); - if (results != ClangFunction::eExecutionCompleted) - { - str.Printf("Error evaluating Print Object function: %d.\n", results); - return false; - } - - addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - - // poor man's strcpy - - Error error; - std::vector<char> desc; - while (1) - { - char byte = '\0'; - if (exe_ctx.process->ReadMemory(result_ptr + desc.size(), &byte, 1, error) != 1) - break; - - desc.push_back(byte); - - if (byte == '\0') - break; - } - - if (!desc.empty()) - { - str.PutCString(&desc.front()); - return true; - } - return false; -} - -Address * -ObjCObjectPrinter::GetPrintForDebuggerAddr() -{ - if (!m_PrintForDebugger_addr.get()) - { - ModuleList &modules = m_process.GetTarget().GetImages(); - - SymbolContextList contexts; - SymbolContext context; - - if((!modules.FindSymbolsWithNameAndType(ConstString ("_NSPrintForDebugger"), eSymbolTypeCode, contexts)) && - (!modules.FindSymbolsWithNameAndType(ConstString ("_CFPrintForDebugger"), eSymbolTypeCode, contexts))) - return NULL; - - contexts.GetContextAtIndex(0, context); - - m_PrintForDebugger_addr.reset(new Address(context.symbol->GetValue())); - } - - return m_PrintForDebugger_addr.get(); -} - diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 646a8e8a807..9086c15e805 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -84,7 +84,6 @@ Process::Process(Target &target, Listener &listener) : m_notifications (), m_listener(listener), m_unix_signals (), - m_objc_object_printer(*this), m_persistent_vars() { UpdateInstanceName(); @@ -1839,12 +1838,6 @@ Process::GetPersistentVariables() return m_persistent_vars; } -ObjCObjectPrinter & -Process::GetObjCObjectPrinter() -{ - return m_objc_object_printer; -} - uint32_t Process::ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids) { diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index d4fbfdf3bfb..fb4ad9a3bf2 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -16,6 +16,7 @@ #include "lldb/Host/Host.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" @@ -662,7 +663,16 @@ Thread::QueueThreadPlanForStepOut (bool abort_other_plans, SymbolContext *addr_c ThreadPlan * Thread::QueueThreadPlanForStepThrough (bool abort_other_plans, bool stop_other_threads) { + // Try the dynamic loader first: ThreadPlanSP thread_plan_sp(GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (*this, stop_other_threads)); + // If that didn't come up with anything, try the ObjC runtime plugin: + if (thread_plan_sp.get() == NULL) + { + ObjCLanguageRuntime *objc_runtime = GetProcess().GetObjCLanguageRuntime(); + if (objc_runtime) + thread_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (*this, stop_other_threads); + } + if (thread_plan_sp.get() == NULL) { thread_plan_sp.reset(new ThreadPlanStepThrough (*this, stop_other_threads)); diff --git a/lldb/source/Target/ThreadPlanStepThrough.cpp b/lldb/source/Target/ThreadPlanStepThrough.cpp index 7fb7538af3f..5aaa984b8ba 100644 --- a/lldb/source/Target/ThreadPlanStepThrough.cpp +++ b/lldb/source/Target/ThreadPlanStepThrough.cpp @@ -17,6 +17,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Target/DynamicLoader.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -93,6 +94,14 @@ ThreadPlanStepThrough::WillResume (StateType resume_state, bool current_plan) if (current_plan) { ThreadPlanSP sub_plan_sp(m_thread.GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (m_thread, m_stop_others)); + // If that didn't come up with anything, try the ObjC runtime plugin: + if (sub_plan_sp == NULL) + { + ObjCLanguageRuntime *objc_runtime = m_thread.GetProcess().GetObjCLanguageRuntime(); + if (objc_runtime) + sub_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (m_thread, m_stop_others); + } + if (sub_plan_sp != NULL) PushPlan (sub_plan_sp); } |